agentleFS
arpitnatharpitnath/claude-capsule-kit/templates/CLAUDE.md

claude-capsule-kit / templates

CLAUDE.md93 starsChanged 10 months agoMITView on GitHub

Context memory for Claude Code. Capsule (SQLite) stores session state automatically via JS hooks. No manual logging needed. For parallel multi-branch work, use the /crew skill. It handles team setup, worktree creation, and teammate spawning automatically. When to use crews (not regular sub-agents): - 2+ independent workstreams that benefit from separate git branches - Work that should happen in parallel on isolated worktrees - Tasks where teammates need their own branch to commit on Config: .crew-config.json in project root defines…

The file

We split this CLAUDE.md into the rules it gives an agent

8 rules. About 0 are common, 3 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Directory structure: NEVER create files in .claude/.

    line 13
  2. Very specific:

    Read: search <term>, files, agents, sessions, recent, stats

    line 22
  3. Distinctive:

    NEVER use Task/Explore for dependency queries, file search, or code search.

    line 24
  4. Distinctive:

    Agent routing: Use specialized agents via Task tool.

    line 25
  5. Very specific:

    Production safety: All sub-agents are read-only (Read, Grep, Glob only).

    line 32
  6. Distinctive:

    NEVER use Task/Explore for dependency queries.

    line 110
  7. Very specific:

    Read specific chunk: $HOME/.claude/bin/progressive-reader --path <file> --chunk N

    line 126
  8. Very specific:

    If you get MaxFileReadTokenExceededError, IMMEDIATELY switch to progressive-reader.

    line 130

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.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
CLAUDE.md

Capsule Kit v3.0

Context memory for Claude Code. Capsule (SQLite) stores session state automatically via JS hooks. No manual logging needed.

Requirements

  • Git: Required for session tracking
  • Node.js: Required for Capsule hooks (blink-query npm package)
  • Go 1.20+ (optional): For building dependency analysis tools (query-deps, impact-analysis, progressive-reader)

RULES

  1. Directory structure: NEVER create files in .claude/. Create in source dirs: tools/, hooks/, scripts/. The .claude/ directory is generated by install.
  2. Tool enforcement (enforced by PreToolUse hook):
    • Dependencies/imports: bash $HOME/.claude/cck/tools/query-deps/query-deps.sh <file>
    • Impact of changes: bash $HOME/.claude/cck/tools/impact-analysis/impact-analysis.sh <file>
    • Circular deps: bash $HOME/.claude/cck/tools/find-circular/find-circular.sh
    • Dead code: bash $HOME/.claude/cck/tools/find-dead-code/find-dead-code.sh
    • File search: Glob -- Code search: Grep
    • Large files (>50KB): $HOME/.claude/bin/progressive-reader --path <file> --list
    • Capsule context: bash $HOME/.claude/cck/tools/context-query/context-query.sh <command> [args]
      • Read: search <term>, files, agents, sessions, recent, stats
      • Write: save <ns> <title> <summary> [type], update <search> <new-summary>
    • NEVER use Task/Explore for dependency queries, file search, or code search.
  3. Agent routing: Use specialized agents via Task tool. Spawn in PARALLEL when independent.
    • Errors/bugs: error-detective | Debugging: debugger | Code review: code-reviewer
    • Refactoring: refactoring-specialist | Architecture: architecture-explorer
    • Security: security-engineer | Database: database-navigator | Git: git-workflow-manager
    • Production: devops-sre | Design: brainstorm-coordinator
    • 18 agents total available.
  4. Skills: /workflow (complex tasks), /debug (errors/bugs), /deep-context (understand codebase), /code-review (pre-commit), /crew (parallel multi-branch teams). Auto-activate on keywords.
  5. Production safety: All sub-agents are read-only (Read, Grep, Glob only). No Edit/Write/Bash.

Crew Mode (Agent Teams)

For parallel multi-branch work, use the /crew skill. It handles team setup, worktree creation, and teammate spawning automatically.

When to use crews (not regular sub-agents):

  • 2+ independent workstreams that benefit from separate git branches
  • Work that should happen in parallel on isolated worktrees
  • Tasks where teammates need their own branch to commit on

Config: .crew-config.json in project root defines team profiles, teammates, roles, and branches. CLI: cck crew init|decompose|start|stop|status|doctor|activity|gc|discoveries|merge-preview|merge for manual control. Roles: developer, reviewer, tester, architect — set defaults for model, mode, and focus. Staleness: Configurable via stale_after_hours (default 4h). Teammates resume if still active. Crew grouping: Config supports crews array to group teammates (e.g. frontend, backend). Use --crew <name> to filter commands.

Key rule: Only crew teammates use git worktrees. Regular sub-agents (Task tool) work in the main project directory. Requires: Agent teams enabled in Claude Code. Setup guide: https://code.claude.com/docs/en/agent-teams

Context System (Capsule)

Context is handled fully automatically. The JS hooks capture everything:

HookTriggerWhat It Captures
session-start.jsSession beginsInjects last session summary, recent files, team activity
post-tool-use.jsAfter Read/Write/Edit/TaskFile operations (META), sub-agent invocations (SUMMARY)
session-end.jsSession endsSession summary with file count, agent count
pre-compact.jsBefore auto-compactSaves session continuity document while full context is still available
post-compact.jsAfter auto-compactRestores session continuity and injects saved context
pre-tool-use-read.shBefore Read tool callsLarge file blocking (>50KB), recent-read warnings, capsule context suggestions
pre-tool-use-task.shBefore Task tool callsDependency enforcement, file search suggestions, context-librarian suggestions
subagent-start.jsSubagent spawnedInjects crew context and relevant discoveries into subagent session
teammate-idle.jsTeammate goes idleSaves teammate state, triggers handoff context capture
worktree-lifecycle.jsWorktree created/removedRegisters/deregisters worktree in global registry, updates crew state
stop-failure.jsResponse stops with failureCaptures failure context, saves diagnostic info for next session
stop.shAfter responsesQuality check

Capsule Record Types

TypeMeaningConsumption Instruction
SUMMARYRead the summary directly, you have what you needSub-agent findings, discoveries
METAStructured data (JSON content field)File operations, session metadata, config
COLLECTIONBrowse children, pick what's relevantGroups of related records
SOURCESummary here, fetch source if you need depthExternal references
ALIASFollow the redirect to the target recordPointers

Capsule Namespace Reference

Solo mode:

session/{session_id}/files       -- File operation records (META)
session/{session_id}/subagents   -- Sub-agent invocation records (SUMMARY)
session                          -- Session summary records (META)
discoveries                      -- Architectural discoveries

Crew mode (Agent Teams with worktrees, shared capsule.db):

crew/{teammate_name}/session/{session_id}/files       -- Teammate file ops
crew/{teammate_name}/session/{session_id}/subagents   -- Teammate sub-agents
crew/{teammate_name}/session                          -- Teammate session summaries
crew/_shared/discoveries                              -- Shared team discoveries

Tool Enforcement Details

Dependency Analysis (ALWAYS use these tools)

QuestionCommand
What imports file X?bash $HOME/.claude/cck/tools/query-deps/query-deps.sh <file>
What breaks if I change X?bash $HOME/.claude/cck/tools/impact-analysis/impact-analysis.sh <file>
Circular dependencies?bash $HOME/.claude/cck/tools/find-circular/find-circular.sh
Dead/unused code?bash $HOME/.claude/cck/tools/find-dead-code/find-dead-code.sh

NEVER use Task/Explore for dependency queries. These tools use a pre-built graph — instant vs sequential scanning.

Capsule Context Query (mid-session access)

QuestionCommand
Search past contextbash $HOME/.claude/cck/tools/context-query/context-query.sh search <term>
Recent file operationsbash $HOME/.claude/cck/tools/context-query/context-query.sh files
Sub-agent historybash $HOME/.claude/cck/tools/context-query/context-query.sh agents
Session summariesbash $HOME/.claude/cck/tools/context-query/context-query.sh sessions
Save a discoverybash $HOME/.claude/cck/tools/context-query/context-query.sh save discoveries "<title>" "<summary>"
Update a recordbash $HOME/.claude/cck/tools/context-query/context-query.sh update "<title>" "<new summary>"

Large File Navigation (>50KB)

  1. Discover structure: $HOME/.claude/bin/progressive-reader --path <file> --list
  2. Read specific chunk: $HOME/.claude/bin/progressive-reader --path <file> --chunk N

Languages with AST parsing: TypeScript, JavaScript, Python, Go. Token savings: 75-97%.

If you get MaxFileReadTokenExceededError, IMMEDIATELY switch to progressive-reader.

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.