claude-os / framework
CLAUDE.md3 starsChanged 8 months agoApache-2.0View on GitHub
The main chat agent is a team lead, not a worker. Its context window must stay as lean as possible. Replace this section with your actual tech stack. The framework is language-agnostic -- the agent execution model works with any stack. Map directories to team names so agents know which files they own: When agents are spawned with file ownership rules, they stay in their lane. This prevents merge conflicts during parallel execution and keeps diffs clean. After EVERY set…
The file
We split this CLAUDE.md into the rules it gives an agent
8 rules. About 0 are common, 6 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 8
Never do work inline: Every task -- coding, research, exploration, testing, file reads beyond a quick glance -- MUST be delegated to a …
- Very specific: line 9
Use
TeamCreatefor multi-step or collaborative work: When a task involves 2+ agents that need to coordinate (e.g., backend + tests, … - Distinctive: line 19
Parallel by default: If tasks are independent, launch agents concurrently in a single message.
- Distinctive: line 57
When agents are spawned with file ownership rules, they stay in their lane.
- Distinctive: line 63
All datetimes in UTC internally, convert for display only
- Distinctive: line 66
Use typed models (Pydantic, dataclasses, etc.) for all shared data structures
- Distinctive: line 84
After EVERY set of code changes (commit, PR, phase completion), update all affected documentation before considering the work done.
- Distinctive: line 105
When compacting, always preserve: list of files modified in this session, active task context, module boundary rules, and the agent …
≈ “Common” is an estimate: at least 1 in 5 of the 29,248 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.
Files
Lean Context Framework
Agent Execution Model -- Non-Negotiable
The main chat agent is a team lead, not a worker. Its context window must stay as lean as possible.
Rules
- Never do work inline. Every task -- coding, research, exploration, testing, file reads beyond a quick glance -- MUST be delegated to a subagent (
Agenttool) or an agent team (TeamCreate+SendMessage). - Use
TeamCreatefor multi-step or collaborative work. When a task involves 2+ agents that need to coordinate (e.g., backend + tests, research + implementation), create a named team with a team-lead agent that owns the deliverable. - Use
Agent(subagent) for one-shot, isolated tasks. Quick searches, single-file edits, running a test suite -- these can be standalone subagents. But they still run outside the main context. - Even recon is delegated. Exploring the codebase, grepping for patterns, reading architecture docs -- spawn an
Exploreagent or ageneral-purposeagent. The main agent should receive a summary, not raw tool output. - Prefer
isolation: "worktree"for any agent that writes code. This prevents conflicts when multiple agents work in parallel. - Main agent responsibilities are limited to:
- Understanding the user's intent
- Deciding which agents/teams to spawn
- Routing messages between teams
- Summarizing results back to the user
- Saving memories when appropriate
- Parallel by default. If tasks are independent, launch agents concurrently in a single message. Sequential only when there's a true dependency.
Anti-Patterns (Do NOT Do)
- Reading large files directly in the main context
- Running grep/glob searches inline when an Explore agent can do it
- Writing or editing code in the main context
- Accumulating tool output that could have been summarized by a subagent
Tech Stack (EXAMPLE -- customize for your project)
- Python 3.12+, async throughout, type hints everywhere
- FastAPI for REST API
- SQLite via aiosqlite for persistence
- pytest + pytest-asyncio for tests
- ruff for linting, mypy for type checkingReplace this section with your actual tech stack. The framework is language-agnostic -- the agent execution model works with any stack.
File Ownership (TEMPLATE -- customize for your project)
Map directories to team names so agents know which files they own:
- {project}/core/ + tests/core/ -> engine
- {project}/api/ + tests/api/ -> api
- {project}/plugins/ + tests/plugins/ -> plugins
- {project}/db/ + pyproject.toml -> infra
- deploy/ + .github/ -> ops
- docs/ -> docs
- frontend/ -> frontendWhen agents are spawned with file ownership rules, they stay in their lane. This prevents merge conflicts during parallel execution and keeps diffs clean.
Code Rules (TEMPLATE -- customize for your project)
- All datetimes in UTC internally, convert for display only
- Error responses must be specific and actionable (e.g., "Rate limit exceeded: 0/60 calls remaining, resets in 42 seconds" not "API error")
- One file per module, no god files
- Use typed models (Pydantic, dataclasses, etc.) for all shared data structures
- Async functions everywhere -- no sync I/O in the hot path
Testing (TEMPLATE -- customize for your project)
- Mock external APIs in tests -- no real network calls
- Test categories:
- E2E tests: Full workflow from user action to observable result
- Property-based tests: Hypothesis for invariants and guarantees
- Resilience tests: Timeout, 500, malformed-data handling
- Edge cases: Boundary conditions, empty inputs, concurrent access
Documentation -- Non-Negotiable
After EVERY set of code changes (commit, PR, phase completion), update all affected documentation before considering the work done. This includes:
- Architecture docs -- if any architectural component changed
- Task tracking -- mark completed items, add newly discovered items
- Decision records -- if a non-trivial technical decision was made
Delegate doc updates to a subagent if needed, but they MUST happen. Stale docs are worse than no docs -- they actively mislead future agents and humans.
Token Budget Considerations
This framework is optimized for high-throughput usage (Max plan or equivalent with large token budgets). The lean-context pattern helps on ANY budget by keeping the main agent's context small, but some skills are inherently token-intensive:
- Multi-agent skills (
/audit,/debate,/launch-review) spawn 5-12 agents. Each agent consumes its own context window. - On lower-tier plans, start with single-agent skills (
/fix-issue,/test-all,/dep-audit) and scale up as you understand your token budget. - The core insight -- keeping the main agent lean -- saves tokens regardless of plan tier. A main agent that reads 10 files uses 10x more tokens than one that delegates to an Explore agent and receives a 20-line summary.
Compaction Preservation
When compacting, always preserve: list of files modified in this session, active task context, module boundary rules, and the agent execution model.
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.

