agentleFS
Neneka448Neneka448/gogoclaw/AGENTS.md

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.

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
  1. Distinctive:

    All commits must follow this format:

    line 3
  2. Distinctive:

    Prefer a scope that matches the primary directory or layer being changed.

    line 17
  3. Distinctive:

    If one change spans multiple files in the same feature path, use the most specific shared scope.

    line 19
  4. Distinctive:

    If a change crosses unrelated layers, use the dominant user-facing area instead of listing multiple scopes.

    line 20
  5. Very specific:

    If one change legitimately spans multiple primary layers, you may list multiple scopes separated by commas, such as feat(cli,config): ....

    line 21
  6. Distinctive:

    Keep multi-scope commit headers short and use them only when the change truly affects more than one primary layer.

    line 22
  7. Very specific:

    Use package-level test runs for focused iteration, for example go test ./internal/agent ./internal/gateway.

    line 95
  8. Very specific:

    All runtime code lives under internal/.

    line 103
  9. Very specific:

    Create internal/tools/<tool_name>.go.

    line 131
  10. Very specific:

    If the tool needs config-driven timeout, add a ToolConfig entry in the user's config JSON under "tools".

    line 180
  11. Very specific:

    Add the field to the relevant struct in internal/config/schema.go.

    line 184
  12. Very specific:

    If validation is needed, add a Validate* function next to the struct.

    line 186
  13. Very specific:

    Add the interface field to SystemContext in internal/context/system_context.go.

    line 193
  14. Very specific:

    If the service needs startup/shutdown, wire it into profileRuntime.ensureReady() and profileRuntime.close().

    line 195
  15. Very specific:

    Create internal/channels/<channel_name>.go implementing the channel interface.

    line 200
  16. Very specific:

    Add config fields to ChannelsConfig in internal/config/schema.go.

    line 202
  17. Very specific:

    When the agent decides a skill is relevant, it calls the get_skill tool which returns the full SKILL.md content.

    line 263
  18. Very specific:

    Create the skill directory under internal/workspace/templates/skills/<skill-name>/.

    line 270
  19. Very specific:

    Add SKILL.md with frontmatter + protocol.

    line 271
  20. Distinctive:

    Add any supporting files (scripts, references, templates).

    line 272
  21. Distinctive:

    Keep the trigger description precise — the agent uses it to decide relevance.

    line 278
  22. Distinctive:

    Write the protocol as imperative steps, not explanations.

    line 279
  23. Very specific:

    If the skill needs shell commands, put them in scripts/ and reference them from the protocol.

    line 280
  24. Distinctive:

    Use this as a decision guide.

    line 288

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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:

ScopeUse for
rootRepository entrypoints such as main.go and cmd/root.go
cliUser-facing command flow across cmd/ and internal/cli/
bootstrapRuntime assembly under internal/bootstrap/
configConfiguration schema, defaults, and loaders under internal/config/
agentAgent runtime, orchestration, and future code under internal/agent/
memoryMemory management and persistence under internal/memory/
toolsTool registry, execution, and adapters under internal/tools/
sessionSession lifecycle and state under internal/session/
gatewayGateway server and transport flow under cmd/gateway.go and internal/gateway/
channelsChannel integrations and dispatch under internal/channels/
message_busMessage queue and transport contracts under internal/message_bus/
providerModel/provider integrations under cmd/provider.go and internal/provider/
skillsSkill discovery and workspace skill loading under internal/skills/
systempromptPrompt assembly from workspace files under internal/systemprompt/
vectorstoreEmbedding persistence and sqlite-vec integration under internal/vectorstore/
workspaceWorkspace bootstrap templates and file scaffolding under internal/workspace/
utilsShared helpers under internal/utils/

Examples:

  • feat(cli): wire onboard command to config creation
  • refactor(config): centralize default profile values
  • feat(provider): add provider integration scaffolding
  • docs(utils): document shared helper conventions

Predicates

PredicateWhen to use
featIntroduces a new feature visible to users or callers
fixFixes a bug or incorrect behavior
choreMaintenance tasks: dependency updates, config changes, scaffolding
refactorCode restructuring with no behavior change
perfPerformance improvement
styleFormatting, whitespace, or lint-only changes (no logic change)
testAdding or updating tests
docsDocumentation only
buildChanges to build system, bundler config, or CI pipeline
revertReverts a previous commit

Runtime and Workflow Notes

  • Runtime wiring lives in internal/bootstrap/bootstrap.go; it resolves the default agent/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, and cmd/version.go. cmd/config.go, cmd/provider.go, and cmd/status.go are placeholders.
  • cmd/agent.go uses one-shot processing through Gateway.DirectProcessAndReturn; cmd/gateway.go runs long-lived channel processing through Gateway.Start.
  • In internal/agent/agent_loop.go, /new archives and resets the session, tool iterations are bounded by profile maxToolIterations, and unfinished loops emit a max-iterations assistant message.

Workspace Prompt Composition

  • internal/systemprompt/service.go builds <system_prompt> from workspace AGENTS.md, SOUL.md, TOOLS.md, and USER.md; HEARTBEAT.md is 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 conditional get_skill usage.
  • internal/workspace/bootstrap_files.go only 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, and get_skill.
  • read_file, list_dir, and terminal are workspace-scoped and reject path traversal outside the configured workspace.
  • terminal executes bash -lc non-interactively with a default 30s timeout (internal/tools/terminal.go), and bootstrap can override timeout via config tool entry name: terminal.
  • Gateway lifecycle starts/stops VectorStore with 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 build and run full tests with make test (currently go 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

  1. Create internal/tools/<tool_name>.go. Implement the Tool interface:
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.

  1. Optionally implement additional interfaces if the tool needs richer lifecycle:
InterfacePurpose
MessageContextToolReceive the inbound message before each turn
TurnLifecycleToolStartTurn() called at the beginning of each turn
OutboundSuppressionToolSuppress tool result from being sent to the channel
SentMessageToolReport whether the tool sent a message this turn
  1. Build a ToolDescriptor with 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,
    }
}
  1. Register it in buildInvocationToolRegistry() inside internal/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
}
  1. If the tool needs config-driven timeout, add a ToolConfig entry in the user's config JSON under "tools".

Adding a New Config Field

  1. Add the field to the relevant struct in internal/config/schema.go.
  2. Set a sensible default in CreateDefaultConfig().
  3. If validation is needed, add a Validate* function next to the struct.
  4. The ConfigManager loads from JSON and caches — no extra wiring needed for reads.
  5. Consume the new field where needed (usually in internal/agent/invocation.go during buildProfileRuntime or buildExecutionContext).

Adding a New Service to SystemContext

  1. Define the service interface in its own package under internal/<service>/.
  2. Add the interface field to SystemContext in internal/context/system_context.go.
  3. Construct the service in buildProfileRuntime() in internal/agent/invocation.go.
  4. If the service needs startup/shutdown, wire it into profileRuntime.ensureReady() and profileRuntime.close().
  5. Access it via al.context.<ServiceName> in the agent loop or pass it to tools that need it.

Adding a New Channel

  1. Create internal/channels/<channel_name>.go implementing the channel interface.
  2. Register it in internal/bootstrap/bootstrap.go alongside the CLI and Feishu channels.
  3. Add config fields to ChannelsConfig in internal/config/schema.go.
  4. The gateway dispatches outbound messages to channels via ChannelRegistry — no agent loop changes needed.

Key Patterns

  • Workspace-scoped: Tools like read_file, list_dir, terminal reject paths outside the workspace. New tools that touch the filesystem should do the same.
  • OutputSink abstraction: Foreground mode writes to MessageBusOutputSink; background/cron mode uses NoopOutputSink. Tools that emit messages should go through OutputSink, not MessageBus directly.
  • 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 profileName and invocationMode in its config, and at execution time these are passed through the unified InvocationService path (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: profileRuntime uses sync.Once for 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. FilteredRegistry wraps 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 use

SKILL.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_skill to 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

  1. workspace.EnsureDefaultSkills() deploys embedded template skills on first run (skips if SKILL.md already exists).
  2. skills.LoadWorkspaceSkills(workspace) scans skills/*/SKILL.md, parses frontmatter, and builds the registry.
  3. systemprompt.Service.Build() injects skill names + metadata into the <skills> section of the system prompt.
  4. When the agent decides a skill is relevant, it calls the get_skill tool which returns the full SKILL.md content.
  5. 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:

  1. Create the skill directory under internal/workspace/templates/skills/<skill-name>/.
  2. Add SKILL.md with frontmatter + protocol.
  3. Add any supporting files (scripts, references, templates).
  4. The //go:embed templates/*.md templates/skills directive in bootstrap_files.go picks it up automatically.
  5. 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_cron to 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 moduleKey file(s)
Change how the agent reasons / loops over toolsagentagent_loop.go
Add/remove a built-in tooltools + agenttools/<name>.go, invocation.go (registration)
Change tool timeout or filteringconfig + agentschema.go, invocation.go
Add a new LLM or embedding providerproviderllm_provider.go or embedding_provider.go
Add a new chat channel (Slack, Discord, etc.)channels + bootstrapchannels/<name>.go, bootstrap.go
Change how messages are queued or routedmessage_bus or gatewaymessage_bus.go, sink.go, gateway.go
Change the system prompt structuresystempromptservice.go
Add a new workspace bootstrap fileworkspacebootstrap_files.go + templates/
Ship a new default skillworkspacetemplates/skills/<name>/SKILL.md
Change session persistence or archivalsessionsession.go
Change memory extraction or recallmemoryservice.go, store.go
Change embedding storagevectorstoresqlite_vec_service.go
Add a config field or profile optionconfigschema.go
Change startup wiring or service initializationbootstrap + agentbootstrap.go, invocation.go
Add a new invocation modecontextsystem_context.go
Change cron scheduling or executioncroncron_service.go, cron.go
Add/change MCP server integrationmcpservice.go
Add a new CLI commandcmdcmd/<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 from agent/ — they get invoked through context.InvocationService.
  • context/ is the shared dependency bag. Keep it as a plain struct with interfaces — no logic.
  • tools/ defines the Tool interface and implementations. Tools receive dependencies via constructor, not by reaching into SystemContext directly.
  • bootstrap/ is the only place that wires everything together for the gateway path. agent/invocation.go does the same for per-profile runtime.
  • workspace/ only handles file scaffolding. It does not read config or know about runtime state.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.