gogoclaw
AGENTS.md8 starsChanged 9 months agoMITView on GitHub
All commits must follow this format: Recommended scopes for this repository:
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
24 rules. About 0 are common, 9 are distinctive, and 15 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
15
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
All commits must follow this format:
- Distinctive: line 17
Prefer a scope that matches the primary directory or layer being changed.
- Distinctive: line 19
If one change spans multiple files in the same feature path, use the most specific shared scope.
- Distinctive: line 20
If a change crosses unrelated layers, use the dominant user-facing area instead of listing multiple scopes.
- Very specific: line 21
If one change legitimately spans multiple primary layers, you may list multiple scopes separated by commas, such as feat(cli,config): ....
- Distinctive: line 22
Keep multi-scope commit headers short and use them only when the change truly affects more than one primary layer.
- Very specific: line 95
Use package-level test runs for focused iteration, for example go test ./internal/agent ./internal/gateway.
- Very specific: line 103
All runtime code lives under internal/.
- Very specific: line 131
Create internal/tools/<tool_name>.go.
- Very specific: line 180
If the tool needs config-driven timeout, add a ToolConfig entry in the user's config JSON under "tools".
- Very specific: line 184
Add the field to the relevant struct in internal/config/schema.go.
- Very specific: line 186
If validation is needed, add a Validate* function next to the struct.
- Very specific: line 193
Add the interface field to SystemContext in internal/context/system_context.go.
- Very specific: line 195
If the service needs startup/shutdown, wire it into profileRuntime.ensureReady() and profileRuntime.close().
- Very specific: line 200
Create internal/channels/<channel_name>.go implementing the channel interface.
- Very specific: line 202
Add config fields to ChannelsConfig in internal/config/schema.go.
- Very specific: line 263
When the agent decides a skill is relevant, it calls the get_skill tool which returns the full SKILL.md content.
- Very specific: line 270
Create the skill directory under internal/workspace/templates/skills/<skill-name>/.
- Very specific: line 271
Add SKILL.md with frontmatter + protocol.
- Distinctive: line 272
Add any supporting files (scripts, references, templates).
- Distinctive: line 278
Keep the trigger description precise — the agent uses it to decide relevance.
- Distinctive: line 279
Write the protocol as imperative steps, not explanations.
- Very specific: line 280
If the skill needs shell commands, put them in scripts/ and reference them from the protocol.
- Distinctive: line 288
Use this as a decision guide.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Commit Message Convention
All commits must follow this format:
predicate(scope): summary
- detail point one
- detail point two- The summary line should be concise (≤ 72 characters), written in the imperative mood, lowercase, no trailing period.
- The bullet points are optional for trivial changes but required when the commit touches multiple concerns.
Scope Convention
- Prefer a scope that matches the primary directory or layer being changed.
- Scopes may be hierarchical using
/when that makes the target area clearer. - If one change spans multiple files in the same feature path, use the most specific shared scope.
- If a change crosses unrelated layers, use the dominant user-facing area instead of listing multiple scopes.
- If one change legitimately spans multiple primary layers, you may list multiple scopes separated by commas, such as
feat(cli,config): .... - Keep multi-scope commit headers short and use them only when the change truly affects more than one primary layer.
Recommended scopes for this repository:
| Scope | Use for |
root | Repository entrypoints such as main.go and cmd/root.go |
cli | User-facing command flow across cmd/ and internal/cli/ |
bootstrap | Runtime assembly under internal/bootstrap/ |
config | Configuration schema, defaults, and loaders under internal/config/ |
agent | Agent runtime, orchestration, and future code under internal/agent/ |
memory | Memory management and persistence under internal/memory/ |
tools | Tool registry, execution, and adapters under internal/tools/ |
session | Session lifecycle and state under internal/session/ |
gateway | Gateway server and transport flow under cmd/gateway.go and internal/gateway/ |
channels | Channel integrations and dispatch under internal/channels/ |
message_bus | Message queue and transport contracts under internal/message_bus/ |
provider | Model/provider integrations under cmd/provider.go and internal/provider/ |
skills | Skill discovery and workspace skill loading under internal/skills/ |
systemprompt | Prompt assembly from workspace files under internal/systemprompt/ |
vectorstore | Embedding persistence and sqlite-vec integration under internal/vectorstore/ |
workspace | Workspace bootstrap templates and file scaffolding under internal/workspace/ |
utils | Shared helpers under internal/utils/ |
Examples:
feat(cli): wire onboard command to config creationrefactor(config): centralize default profile valuesfeat(provider): add provider integration scaffoldingdocs(utils): document shared helper conventions
Predicates
| Predicate | When to use |
feat | Introduces a new feature visible to users or callers |
fix | Fixes a bug or incorrect behavior |
chore | Maintenance tasks: dependency updates, config changes, scaffolding |
refactor | Code restructuring with no behavior change |
perf | Performance improvement |
style | Formatting, whitespace, or lint-only changes (no logic change) |
test | Adding or updating tests |
docs | Documentation only |
build | Changes to build system, bundler config, or CI pipeline |
revert | Reverts a previous commit |
Runtime and Workflow Notes
- Runtime wiring lives in
internal/bootstrap/bootstrap.go; it resolves thedefaultagent/embedding profiles, builds providers, registers channels/tools, and constructs the gateway context. - User-facing command flow is currently implemented in
cmd/onboard.go,cmd/auth.go,cmd/agent.go,cmd/gateway.go, andcmd/version.go.cmd/config.go,cmd/provider.go, andcmd/status.goare placeholders. cmd/agent.gouses one-shot processing throughGateway.DirectProcessAndReturn;cmd/gateway.goruns long-lived channel processing throughGateway.Start.- In
internal/agent/agent_loop.go,/newarchives and resets the session, tool iterations are bounded by profilemaxToolIterations, and unfinished loops emit a max-iterations assistant message.
Workspace Prompt Composition
internal/systemprompt/service.gobuilds<system_prompt>from workspaceAGENTS.md,SOUL.md,TOOLS.md, andUSER.md;HEARTBEAT.mdis bootstrap state and not part of prompt assembly.- Skills are loaded from
skills/<name>/SKILL.md(internal/skills/), and skill metadata is injected into the system prompt to drive conditionalget_skillusage. internal/workspace/bootstrap_files.goonly creates missing bootstrap files, so existing workspace prompt files are intentionally preserved on re-run.
Tool and Integration Constraints
- Built-in model tools are registered in bootstrap:
read_file,list_dir,terminal,message, andget_skill. read_file,list_dir, andterminalare workspace-scoped and reject path traversal outside the configured workspace.terminalexecutesbash -lcnon-interactively with a default 30s timeout (internal/tools/terminal.go), and bootstrap can override timeout via config tool entryname: terminal.- Gateway lifecycle starts/stops
VectorStorewith channels (internal/gateway/gateway.go); sqlite-vec data is stored under<workspace>/sqlite-vec(internal/vectorstore/sqlite_vec_service.go).
Local Development Commands
- Build with
make buildand run full tests withmake test(currentlygo test ./...). - Use package-level test runs for focused iteration, for example
go test ./internal/agent ./internal/gateway.
Writing Code
Project Layout
All runtime code lives under internal/. Each subdirectory is a self-contained Go package with its own interface. The dependency graph flows inward: cmd/ → bootstrap/ → agent/ → everything else. Never import a sibling package's internals — depend on its exported interface.
cmd/ CLI entrypoints — thin wrappers that call bootstrap or gateway
internal/
agent/ ReAct loop + InvocationService (profile runtime lifecycle)
bootstrap/ Wires config → providers → channels → gateway
channels/ Inbound/outbound channel adapters (CLI, Feishu)
cli/ Onboarding and auth interactive flows
config/ JSON config schema, defaults, ConfigManager
context/ SystemContext (central dependency bag) + InvocationRequest
cron/ Cron scheduler + workspace-backed cron storage
gateway/ Message routing, worker pool, lifecycle
mcp/ Model Context Protocol client (stdio + HTTP transports)
memory/ 5W1H+R memory extraction, graph storage, recall
message_bus/ Inbound/Outbound queues + OutputSink abstraction
provider/ LLM and embedding provider adapters (OpenAI-compatible)
session/ Workspace-backed session persistence (JSON files)
skills/ Skill discovery from workspace skills/<name>/SKILL.md
systemprompt/ Prompt assembly from AGENTS.md, SOUL.md, TOOLS.md, USER.md + skills
tools/ Built-in tool implementations + ToolRegistry
vectorstore/ SQLite-vec backed embedding storage
workspace/ Embedded bootstrap templates + file scaffolding
utils/ Shared helpers (perf logging, etc.)Adding a New Built-in Tool
- Create
internal/tools/<tool_name>.go. Implement theToolinterface:
type Tool interface {
Execute(args string) (string, error)
}args is the raw JSON string from the LLM tool call. Parse it yourself with json.Unmarshal. Return a string result or error.
- Optionally implement additional interfaces if the tool needs richer lifecycle:
| Interface | Purpose |
MessageContextTool | Receive the inbound message before each turn |
TurnLifecycleTool | StartTurn() called at the beginning of each turn |
OutboundSuppressionTool | Suppress tool result from being sent to the channel |
SentMessageTool | Report whether the tool sent a message this turn |
- Build a
ToolDescriptorwith the OpenAI function schema:
func NewMyTool(workspace string) tools.ToolDescriptor {
return tools.ToolDescriptor{
Name: "my_tool",
Tool: &myTool{workspace: workspace},
ToolForLLM: openai.Tool{
Type: openai.ToolTypeFunction,
Function: &openai.FunctionDefinition{
Name: "my_tool",
Description: "What this tool does",
Parameters: jsonschema.Definition{ /* ... */ },
},
},
Timeout: tools.DefaultToolExecutionTimeout,
}
}- Register it in
buildInvocationToolRegistry()insideinternal/agent/invocation.go:
myTool := tools.NewMyTool(workspace)
myTool.Timeout = resolveInvocationToolTimeout(toolConfigIndex, "my_tool", tools.DefaultToolExecutionTimeout)
if err := registry.RegisterTool("my_tool", myTool); err != nil {
return nil, err
}- If the tool needs config-driven timeout, add a
ToolConfigentry in the user's config JSON under"tools".
Adding a New Config Field
- Add the field to the relevant struct in
internal/config/schema.go. - Set a sensible default in
CreateDefaultConfig(). - If validation is needed, add a
Validate*function next to the struct. - The
ConfigManagerloads from JSON and caches — no extra wiring needed for reads. - Consume the new field where needed (usually in
internal/agent/invocation.goduringbuildProfileRuntimeorbuildExecutionContext).
Adding a New Service to SystemContext
- Define the service interface in its own package under
internal/<service>/. - Add the interface field to
SystemContextininternal/context/system_context.go. - Construct the service in
buildProfileRuntime()ininternal/agent/invocation.go. - If the service needs startup/shutdown, wire it into
profileRuntime.ensureReady()andprofileRuntime.close(). - Access it via
al.context.<ServiceName>in the agent loop or pass it to tools that need it.
Adding a New Channel
- Create
internal/channels/<channel_name>.goimplementing the channel interface. - Register it in
internal/bootstrap/bootstrap.goalongside the CLI and Feishu channels. - Add config fields to
ChannelsConfigininternal/config/schema.go. - The gateway dispatches outbound messages to channels via
ChannelRegistry— no agent loop changes needed.
Key Patterns
- Workspace-scoped: Tools like
read_file,list_dir,terminalreject paths outside the workspace. New tools that touch the filesystem should do the same. - OutputSink abstraction: Foreground mode writes to
MessageBusOutputSink; background/cron mode usesNoopOutputSink. Tools that emit messages should go throughOutputSink, notMessageBusdirectly. - Cron as agent launcher: Cron is a profile-aware, mode-aware, file-oriented agent launcher — not a workflow engine or a second agent runtime. Each cron task stores
profileNameandinvocationModein its config, and at execution time these are passed through the unifiedInvocationServicepath (executeCronRequest→buildExecutionContext). Execution artifacts (manifest, session references) are written to the cron execution directory. Do not add orchestration logic, task DAGs, or channel coupling into the cron layer. - Lazy initialization:
profileRuntimeusessync.Oncefor startup. Services are built once per profile and cached. - Retry with backoff: LLM calls use exponential backoff with jitter (
chatCompletionWithRetry). Follow this pattern for any external call that can transiently fail. - Tool filtering: Profiles can set
allowedTools/forbiddenTools.FilteredRegistrywraps the inner registry. Wildcard"*"is supported.
Writing Skills
Skills are the primary extension mechanism. They are natural-language protocols that teach the agent how to handle a specific domain or task. There is no "scenes" abstraction — skills fill that role.
Skill File Structure
A skill lives in <workspace>/skills/<skill-name>/SKILL.md. The directory name is the skill name.
skills/
my-skill/
SKILL.md # Required — the skill protocol
references/ # Optional — supporting docs the skill can read
scripts/ # Optional — shell scripts the skill can execute
templates/ # Optional — file templates the skill can useSKILL.md Format
---
name: my-skill
description: One-line summary used for skill matching in the system prompt
trigger: When to activate this skill (natural language)
---
# My Skill
## When to Use
Describe the scenarios where this skill applies.
## Protocol
Step-by-step instructions the agent should follow.
## References
Point to files in the references/ directory if needed.- The YAML frontmatter is parsed and injected into the system prompt as JSON metadata.
- The agent sees skill names + metadata and decides whether to call
get_skillto load the full content. - The body after the frontmatter is the full protocol — write it as instructions the agent will follow literally.
How Skills Are Loaded at Runtime
workspace.EnsureDefaultSkills()deploys embedded template skills on first run (skips if SKILL.md already exists).skills.LoadWorkspaceSkills(workspace)scansskills/*/SKILL.md, parses frontmatter, and builds the registry.systemprompt.Service.Build()injects skill names + metadata into the<skills>section of the system prompt.- When the agent decides a skill is relevant, it calls the
get_skilltool which returns the full SKILL.md content. - The agent then follows the protocol in the skill body.
Adding a Default (Embedded) Skill
To ship a skill as part of the gogoclaw binary:
- Create the skill directory under
internal/workspace/templates/skills/<skill-name>/. - Add
SKILL.mdwith frontmatter + protocol. - Add any supporting files (scripts, references, templates).
- The
//go:embed templates/*.md templates/skillsdirective inbootstrap_files.gopicks it up automatically. EnsureDefaultSkills()deploys it to the workspace on first run. Existing skills are never overwritten.
Writing Effective Skills
- Keep the trigger description precise — the agent uses it to decide relevance.
- Write the protocol as imperative steps, not explanations.
- If the skill needs shell commands, put them in
scripts/and reference them from the protocol. - Skills can reference other workspace files via
read_file— instruct the agent to do so in the protocol. - A skill can call
create_cronto schedule follow-up work, enabling autonomous multi-step workflows.
When and How to Change Each Module
Use this as a decision guide. Find the behavior you want to change, then go to the right module.
| I want to… | Change this module | Key file(s) |
| Change how the agent reasons / loops over tools | agent | agent_loop.go |
| Add/remove a built-in tool | tools + agent | tools/<name>.go, invocation.go (registration) |
| Change tool timeout or filtering | config + agent | schema.go, invocation.go |
| Add a new LLM or embedding provider | provider | llm_provider.go or embedding_provider.go |
| Add a new chat channel (Slack, Discord, etc.) | channels + bootstrap | channels/<name>.go, bootstrap.go |
| Change how messages are queued or routed | message_bus or gateway | message_bus.go, sink.go, gateway.go |
| Change the system prompt structure | systemprompt | service.go |
| Add a new workspace bootstrap file | workspace | bootstrap_files.go + templates/ |
| Ship a new default skill | workspace | templates/skills/<name>/SKILL.md |
| Change session persistence or archival | session | session.go |
| Change memory extraction or recall | memory | service.go, store.go |
| Change embedding storage | vectorstore | sqlite_vec_service.go |
| Add a config field or profile option | config | schema.go |
| Change startup wiring or service initialization | bootstrap + agent | bootstrap.go, invocation.go |
| Add a new invocation mode | context | system_context.go |
| Change cron scheduling or execution | cron | cron_service.go, cron.go |
| Add/change MCP server integration | mcp | service.go |
| Add a new CLI command | cmd | cmd/<command>.go |
Cross-cutting changes
Some changes touch multiple modules. Common patterns:
Adding a new capability the agent can use (tool + config + registration):
config/schema.go → tools/<name>.go → agent/invocation.go (register) → optionally workspace/templates/TOOLS.md (document for the agent)
Adding a new autonomous behavior (skill + cron):
workspace/templates/skills/<name>/SKILL.md → skill protocol calls create_cron → cron/cron_service.go executes on schedule
Adding a new external integration (provider + config + bootstrap):
config/schema.go → provider/<name>.go → agent/invocation.go (construct) → context/system_context.go (if new field needed)
Module boundaries to respect
agent/owns the ReAct loop and profile runtime. Other packages should not import fromagent/— they get invoked throughcontext.InvocationService.context/is the shared dependency bag. Keep it as a plain struct with interfaces — no logic.tools/defines theToolinterface and implementations. Tools receive dependencies via constructor, not by reaching intoSystemContextdirectly.bootstrap/is the only place that wires everything together for the gateway path.agent/invocation.godoes the same for per-profile runtime.workspace/only handles file scaffolding. It does not read config or know about runtime state.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

