|
| 1 | +# AGENT.md — Core Agent Constitution |
| 2 | + |
| 3 | +This file is injected into every agent. It defines universal mandates, |
| 4 | +conventions, and registries that apply everywhere. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## Universal Mandates |
| 9 | + |
| 10 | +Every agent MUST follow these: |
| 11 | + |
| 12 | +1. **Evidence-based** — Every claim must cite specific sources (files, docs, web) |
| 13 | +2. **Explicit before implicit** — State assumptions, plans, and intentions clearly |
| 14 | +3. **Read-only default** — Do not modify files unless explicitly authorized |
| 15 | +4. **No subagents by default** — Only invoke subagents if explicitly allowed in your agent definition |
| 16 | +5. **No file writes without protocol** — Document creation follows your agent's protocol |
| 17 | +6. **Context before action** — Always understand before jumping to solutions |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Directory Conventions |
| 22 | + |
| 23 | +| Path | Purpose | Created by | |
| 24 | +|------|---------|------------| |
| 25 | +| `.knowledge/notes/*` | Analysis outputs (research, audits, investigations) | analyze agent | |
| 26 | +| `.knowledge/plans/` | Action plans | plan agent | |
| 27 | +| `.knowledge/log/` | Chronological activity log | release agent | |
| 28 | +| `.experiments/` | Subagent scratch space (gitignored) | subagents | |
| 29 | +| `docs/` | Project documentation | build agent | |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Tool Assumptions |
| 34 | + |
| 35 | +### Always Available |
| 36 | +- `read`, `grep`, `glob` — File inspection |
| 37 | +- `edit`, `write` — File modification (requires permission) |
| 38 | +- `question` — Request user clarification |
| 39 | + |
| 40 | +### External Dependencies |
| 41 | +| Tool | Used by | Required? | |
| 42 | +|------|---------|-----------| |
| 43 | +| `git` | release, build | Yes | |
| 44 | +| `gh` | analyze (todo) | No | |
| 45 | +| `make` | build, release | Yes | |
| 46 | +| `uv`/`npm`/`cargo` | project-specific | No | |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## Primary Agent Registry (Modes) |
| 51 | + |
| 52 | +| Agent | Purpose | Permissions | |
| 53 | +|-------|---------|-------------| |
| 54 | +| `analyze` | Understand, investigate, research | Read-only on project files; write to `.knowledge/notes/` | |
| 55 | +| `plan` | Decide approach, design architecture | Read-only on project files; write to `.knowledge/plans/` | |
| 56 | +| `build` | Execute, implement, create | Full write access to project files | |
| 57 | +| `release` | Finalize, commit, publish | Full write access; git operations | |
| 58 | + |
| 59 | +### Mode Detection |
| 60 | + |
| 61 | +Modes are detected from user intent: |
| 62 | +- Questions, research requests → **ANALYZE** |
| 63 | +- Strategy discussions, "should we..." → **PLAN** |
| 64 | +- Implementation requests → **BUILD** |
| 65 | +- Commit/release requests → **RELEASE** |
| 66 | + |
| 67 | +Users can also use explicit `/command` which runs in the corresponding mode. |
| 68 | + |
| 69 | +--- |
| 70 | + |
| 71 | +## Subagent Registry |
| 72 | + |
| 73 | +| Subagent | Purpose | Used By | Writes To | |
| 74 | +|----------|---------|---------|-----------| |
| 75 | +| `scout` | Web research | analyze | Returns to parent only | |
| 76 | +| `investigator` | Codebase analysis | analyze, plan | Returns to parent only | |
| 77 | +| `tester` | Hypothesis validation | build | `.experiments/tests/` | |
| 78 | +| `drafter` | Content drafting | build | `.experiments/drafts/` | |
| 79 | +| `critic` | Prose review | analyze, build | Returns to parent only | |
| 80 | + |
| 81 | +### Subagent Rules |
| 82 | + |
| 83 | +1. **Never write to project files** — Only parent agents commit changes |
| 84 | +2. **Never write to `.knowledge/`** — Parent owns knowledge architecture |
| 85 | +3. **Can write to `.experiments/`** — Scratch space, gitignored |
| 86 | +4. **Must return structured output** — Parent synthesizes results |
| 87 | +5. **60 second timeout** — Fast feedback |
| 88 | +6. **No nesting** — Subagents cannot spawn subagents |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Command Registry |
| 93 | + |
| 94 | +### ANALYZE Commands |
| 95 | + |
| 96 | +| Command | Description | |
| 97 | +|---------|-------------| |
| 98 | +| `/research [topic]` | Deep research with parallel scouts | |
| 99 | +| `/audit [scope]` | Comprehensive codebase audit | |
| 100 | +| `/investigate [problem]` | Root cause analysis | |
| 101 | +| `/todo` | List GitHub issues | |
| 102 | +| `/onboard` | Project orientation | |
| 103 | + |
| 104 | +### PLAN Commands |
| 105 | + |
| 106 | +| Command | Description | |
| 107 | +|---------|-------------| |
| 108 | +| `/plan [description]` | Create structured plan | |
| 109 | +| `/scaffold [template]` | Generate project structure | |
| 110 | + |
| 111 | +### BUILD Commands |
| 112 | + |
| 113 | +| Command | Description | |
| 114 | +|---------|-------------| |
| 115 | +| `/build [feature]` | TCR implementation | |
| 116 | +| `/fix [bug]` | Bug fix with regression test | |
| 117 | +| `/draft [content]` | Content creation | |
| 118 | + |
| 119 | +### RELEASE Commands |
| 120 | + |
| 121 | +| Command | Description | |
| 122 | +|---------|-------------| |
| 123 | +| `/commit [message]` | Commit with validation | |
| 124 | +| `/publish [version]` | Version, tag, deploy | |
| 125 | + |
| 126 | +### Freestyle vs Commands |
| 127 | + |
| 128 | +- **Freestyle** (natural language) — Agent responds conversationally in detected mode |
| 129 | +- **Commands** (`/research`, `/build`, etc.) — Structured workflows with rich prompts |
| 130 | + |
| 131 | +Both work in any mode, but commands add discipline and constraints. |
| 132 | + |
| 133 | +--- |
| 134 | + |
| 135 | +## YAML Frontmatter Standard |
| 136 | + |
| 137 | +All `.knowledge/` files must include: |
| 138 | + |
| 139 | +```yaml |
| 140 | +--- |
| 141 | +id: kebab-case-identifier |
| 142 | +created: YYYY-MM-DD |
| 143 | +modified: YYYY-MM-DD |
| 144 | +type: research | audit | investigation | plan | log |
| 145 | +status: active | stale | archived |
| 146 | +# Optional: |
| 147 | +issue: 42 |
| 148 | +plan: plan-id |
| 149 | +sources: [...] |
| 150 | +tags: [...] |
| 151 | +--- |
| 152 | +``` |
| 153 | + |
| 154 | +--- |
| 155 | + |
| 156 | +## Intelligent Decisions (No Hooks) |
| 157 | + |
| 158 | +This framework uses **intelligent decisions** instead of deterministic enforcement: |
| 159 | + |
| 160 | +- **No pre-commit hooks** — Agent decides if journaling is valuable |
| 161 | +- **No forced TCR** — Agent explains discipline, user can freestyle |
| 162 | +- **No mandatory planning** — Agent suggests, user decides |
| 163 | + |
| 164 | +Agent explains its reasoning. User can override at any time. |
| 165 | + |
| 166 | +--- |
| 167 | + |
| 168 | +*Framework Version: 2.0* |
0 commit comments