@jaybeeuu/agent-cortex 1.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/.beads/README.md +81 -0
  2. package/.beads/config.yaml +1 -0
  3. package/.beads/issues.jsonl +236 -0
  4. package/.beads/metadata.json +7 -0
  5. package/.claude-plugin/marketplace.json +16 -0
  6. package/.github/workflows/ci.test.ts +217 -0
  7. package/.github/workflows/ci.yml +35 -0
  8. package/.github/workflows/publish.yml +36 -0
  9. package/.junie/guidelines.md +87 -0
  10. package/.junie/mcp/mcp.json +10 -0
  11. package/AGENTS.md +102 -0
  12. package/CHANGELOG.md +705 -0
  13. package/README.md +209 -0
  14. package/agents/README.md +235 -0
  15. package/agents/plan.agent.md +56 -0
  16. package/agents/ralph-plan.agent.md +119 -0
  17. package/agents/ralph.agent.md +305 -0
  18. package/agents/strategy.agent.md +109 -0
  19. package/agents-native/ralph.md +193 -0
  20. package/bin/agent-cortex.mjs +27 -0
  21. package/claude/.claude-plugin/plugin.json +11 -0
  22. package/claude/.mcp.json +18 -0
  23. package/claude/agents/plan.md +56 -0
  24. package/claude/agents/ralph-plan.md +119 -0
  25. package/claude/agents/ralph.md +193 -0
  26. package/claude/agents/strategy.md +109 -0
  27. package/claude/hooks.json +23 -0
  28. package/claude/scripts/statusline-command.sh +124 -0
  29. package/docs/ideas/auto-model-selection.md +75 -0
  30. package/docs/ideas/improve-pi-system-prompt.md +34 -0
  31. package/docs/ideas/model-selector.md +40 -0
  32. package/docs/ideas/pi-task-memory.md +34 -0
  33. package/docs/ideas/qa-extension.md +43 -0
  34. package/docs/inspirations.md +33 -0
  35. package/docs/research/gas-city-research.md +256 -0
  36. package/docs/research/skill-design-research.md +286 -0
  37. package/docs/research/skill-improvements-analysis.md +117 -0
  38. package/docs/research/skill-patterns-research.md +24 -0
  39. package/docs/skills/skill-anatomy.md +149 -0
  40. package/docs/user-preferences.md +17 -0
  41. package/extensions/agent-modes/index.ts +507 -0
  42. package/extensions/auto-name.ts +107 -0
  43. package/extensions/context-loader.md +35 -0
  44. package/extensions/context-loader.ts +65 -0
  45. package/extensions/lib/tiny-model.ts +212 -0
  46. package/extensions/notify/index.ts +293 -0
  47. package/extensions/session-start.ts +44 -0
  48. package/extensions/skill-stats/README.md +74 -0
  49. package/extensions/skill-stats/context-loader.test.ts +107 -0
  50. package/extensions/skill-stats/discover.ts +119 -0
  51. package/extensions/skill-stats/format.ts +13 -0
  52. package/extensions/skill-stats/index.test.ts +452 -0
  53. package/extensions/skill-stats/index.ts +222 -0
  54. package/extensions/skill-stats/package.json +19 -0
  55. package/extensions/skill-stats/pnpm-lock.yaml +329 -0
  56. package/extensions/skill-stats/record.ts +48 -0
  57. package/extensions/skill-stats/store.ts +104 -0
  58. package/extensions/skill-stats/tsconfig.json +12 -0
  59. package/extensions/subagent/README.md +175 -0
  60. package/extensions/subagent/agents/planner.md +37 -0
  61. package/extensions/subagent/agents/reviewer.md +35 -0
  62. package/extensions/subagent/agents/scout.md +50 -0
  63. package/extensions/subagent/agents/worker.md +24 -0
  64. package/extensions/subagent/agents.ts +126 -0
  65. package/extensions/subagent/index.ts +1138 -0
  66. package/extensions/subagent/prompts/implement-and-review.md +10 -0
  67. package/extensions/subagent/prompts/implement.md +10 -0
  68. package/extensions/subagent/prompts/scout-and-plan.md +9 -0
  69. package/hooks.json +10 -0
  70. package/lib/cli.mjs +37 -0
  71. package/package.json +39 -0
  72. package/pi/keybindings.json +3 -0
  73. package/pi/settings.json +29 -0
  74. package/plugin.json +35 -0
  75. package/pnpm-workspace.yaml +7 -0
  76. package/scripts/build-claude-agents.mjs +179 -0
  77. package/scripts/install-instructions.sh +82 -0
  78. package/skills/engineering/design-an-interface/SKILL.md +94 -0
  79. package/skills/engineering/grill-with-docs/SKILL.md +88 -0
  80. package/skills/engineering/improve-codebase-architecture/REFERENCE.md +78 -0
  81. package/skills/engineering/improve-codebase-architecture/SKILL.md +81 -0
  82. package/skills/engineering/tdd/SKILL.md +150 -0
  83. package/skills/engineering/tdd/deep-modules.md +33 -0
  84. package/skills/engineering/tdd/interface-design.md +31 -0
  85. package/skills/engineering/tdd/mocking.md +59 -0
  86. package/skills/engineering/tdd/refactoring.md +10 -0
  87. package/skills/engineering/tdd/tests.md +61 -0
  88. package/skills/engineering/technical-direction/SKILL.md +86 -0
  89. package/skills/planning/classify-bead/SKILL.md +67 -0
  90. package/skills/planning/create-task/SKILL.md +96 -0
  91. package/skills/planning/create-task/pipeline.json +33 -0
  92. package/skills/planning/create-task/scripts/create-chores.ts +112 -0
  93. package/skills/planning/create-task/scripts/package.json +14 -0
  94. package/skills/planning/create-task/scripts/pnpm-lock.yaml +342 -0
  95. package/skills/planning/create-task/scripts/tsconfig.json +12 -0
  96. package/skills/planning/create-task/templates/code.md +40 -0
  97. package/skills/planning/create-task/templates/document.md +40 -0
  98. package/skills/planning/create-task/templates/fix.md +27 -0
  99. package/skills/planning/create-task/templates/review.md +36 -0
  100. package/skills/planning/create-task/templates/verify.md +43 -0
  101. package/skills/planning/prd-to-tasks/SKILL.md +227 -0
  102. package/skills/planning/record-idea/SKILL.md +62 -0
  103. package/skills/planning/record-idea/scripts/new-idea.sh +89 -0
  104. package/skills/planning/request-refactor-plan/SKILL.md +73 -0
  105. package/skills/planning/write-a-prd/SKILL.md +74 -0
  106. package/skills/planning/write-a-ticket/SKILL.md +97 -0
  107. package/skills/productivity/bd-tool/SKILL.md +90 -0
  108. package/skills/productivity/grill-me/SKILL.md +10 -0
  109. package/skills/productivity/handoff/SKILL.md +15 -0
  110. package/skills/productivity/init-beads/SKILL.md +93 -0
  111. package/skills/productivity/teach/GLOSSARY-FORMAT.md +35 -0
  112. package/skills/productivity/teach/LEARNING-RECORD-FORMAT.md +46 -0
  113. package/skills/productivity/teach/MISSION-FORMAT.md +31 -0
  114. package/skills/productivity/teach/RESOURCES-FORMAT.md +32 -0
  115. package/skills/productivity/teach/SKILL.md +109 -0
  116. package/skills/productivity/validate-agent-dir/scripts/package.json +15 -0
  117. package/skills/productivity/validate-agent-dir/scripts/pnpm-lock.yaml +329 -0
  118. package/skills/productivity/validate-agent-dir/scripts/pnpm-workspace.yaml +2 -0
  119. package/skills/productivity/validate-agent-dir/scripts/tsconfig.json +19 -0
  120. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.test.ts +317 -0
  121. package/skills/productivity/validate-agent-dir/scripts/validate-agent-dir.ts +127 -0
  122. package/skills/productivity/write-a-skill/SKILL.md +74 -0
  123. package/skills/review/maintain-agent-docs/REFERENCE.md +246 -0
  124. package/skills/review/maintain-agent-docs/SKILL.md +83 -0
  125. package/skills/review/refactor-skill/EXAMPLES.md +20 -0
  126. package/skills/review/refactor-skill/SKILL.md +148 -0
  127. package/skills/review/review-security/SKILL.md +107 -0
  128. package/skills/review/review-security/scripts/install-gitleaks.sh +43 -0
  129. package/skills/style/style-code/REFERENCE.md +38 -0
  130. package/skills/style/style-code/SKILL.md +113 -0
  131. package/skills/style/style-comms/SKILL.md +93 -0
  132. package/skills/style/style-documentation/SKILL.md +112 -0
  133. package/skills/style/style-tests/SKILL.md +97 -0
  134. package/skills/workflow/git-workflow/SKILL.md +85 -0
  135. package/skills/workflow/hitl-collab/SKILL.md +29 -0
  136. package/skills/workflow/plan/SKILL.md +272 -0
  137. package/skills/workflow/ralph/REFERENCE.md +202 -0
  138. package/skills/workflow/ralph/SKILL.md +105 -0
  139. package/skills/workflow/run-pipeline-stage/SKILL.md +151 -0
  140. package/skills/workflow/run-pipeline-stage/playbooks/code.md +17 -0
  141. package/skills/workflow/run-pipeline-stage/playbooks/document.md +18 -0
  142. package/skills/workflow/run-pipeline-stage/playbooks/fix.md +17 -0
  143. package/skills/workflow/run-pipeline-stage/playbooks/review.md +19 -0
  144. package/skills/workflow/run-pipeline-stage/playbooks/verify.md +14 -0
  145. package/skills/workflow/run-pipeline-stage/prompts/stage-runner.md +20 -0
  146. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.test.ts +783 -0
  147. package/skills/workflow/run-pipeline-stage/scripts/generate-progress.ts +586 -0
  148. package/skills/workflow/run-pipeline-stage/scripts/package.json +15 -0
  149. package/skills/workflow/run-pipeline-stage/scripts/pnpm-lock.yaml +342 -0
  150. package/skills/workflow/run-pipeline-stage/scripts/pnpm-workspace.yaml +2 -0
  151. package/skills/workflow/run-pipeline-stage/scripts/tsconfig.json +12 -0
  152. package/skills/workflow/using-agent-skills/SKILL.md +109 -0
  153. package/skills/workflow/using-agent-skills/scripts/validate-skill-structure.test.ts +73 -0
  154. package/test/cli.test.mjs +149 -0
@@ -0,0 +1,127 @@
1
+ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ // ─── Types ────────────────────────────────────────────────────────────────────
5
+
6
+ export interface Frontmatter {
7
+ name: string;
8
+ description: string;
9
+ tools: string[];
10
+ model?: string;
11
+ argumentHint?: string;
12
+ [key: string]: unknown;
13
+ }
14
+
15
+ export interface AgentDir {
16
+ name: string;
17
+ agentMdPath: string;
18
+ harnesses: Map<string, { frontmatter: Frontmatter; sections: string[] }>;
19
+ }
20
+
21
+ export interface ValidationResult {
22
+ ok: boolean;
23
+ errors: string[];
24
+ }
25
+
26
+ // ─── Constants ────────────────────────────────────────────────────────────────
27
+
28
+ const REQUIRED_FIELDS = ["name", "description", "tools"] as const;
29
+ const KNOWN_OPTIONAL_FIELDS = ["model", "argumentHint"] as const;
30
+
31
+ // ─── Validation ───────────────────────────────────────────────────────────────
32
+
33
+ export function validateFrontmatter(fm: unknown): ValidationResult {
34
+ const errors: string[] = [];
35
+
36
+ if (typeof fm !== "object" || fm === null) {
37
+ return { ok: false, errors: ["frontmatter must be an object"] };
38
+ }
39
+
40
+ const record = fm as Record<string, unknown>;
41
+
42
+ // Check required fields
43
+ for (const field of REQUIRED_FIELDS) {
44
+ if (!(field in record)) {
45
+ errors.push(`missing required field: ${field}`);
46
+ }
47
+ }
48
+
49
+ // Validate name
50
+ if (typeof record.name === "string" && record.name.trim() === "") {
51
+ errors.push("name must not be empty");
52
+ }
53
+
54
+ // Validate description
55
+ if (typeof record.description === "string" && record.description.trim() === "") {
56
+ errors.push("description must not be empty");
57
+ }
58
+
59
+ // Validate tools
60
+ if ("tools" in record) {
61
+ if (!Array.isArray(record.tools)) {
62
+ errors.push("tools must be an array");
63
+ } else if (record.tools.length === 0) {
64
+ errors.push("tools must not be empty");
65
+ } else if (!record.tools.every((t) => typeof t === "string")) {
66
+ errors.push("tools must be an array of strings");
67
+ }
68
+ }
69
+
70
+ // Check for unknown fields
71
+ const knownFields = new Set([...REQUIRED_FIELDS, ...KNOWN_OPTIONAL_FIELDS]);
72
+ for (const key of Object.keys(record)) {
73
+ if (!knownFields.has(key as any)) {
74
+ errors.push(`unknown field: ${key}`);
75
+ }
76
+ }
77
+
78
+ return { ok: errors.length === 0, errors };
79
+ }
80
+
81
+ export function validateAgentDir(agentDirPath: string): ValidationResult {
82
+ const errors: string[] = [];
83
+
84
+ // Check agent.md exists
85
+ const agentMdPath = join(agentDirPath, "agent.md");
86
+ if (!existsSync(agentMdPath)) {
87
+ errors.push("missing agent.md");
88
+ }
89
+
90
+ // Check for at least one harness subdirectory with frontmatter.json
91
+ if (!existsSync(agentDirPath)) {
92
+ return { ok: false, errors: ["agent directory does not exist"] };
93
+ }
94
+
95
+ const entries = readdirSync(agentDirPath);
96
+ const harnessDirs = entries.filter((entry) => {
97
+ const fullPath = join(agentDirPath, entry);
98
+ return statSync(fullPath).isDirectory() && entry !== "node_modules";
99
+ });
100
+
101
+ if (harnessDirs.length === 0) {
102
+ errors.push("no harness subdirectories found (need at least one with frontmatter.json)");
103
+ }
104
+
105
+ // Validate each harness directory
106
+ for (const harnessDir of harnessDirs) {
107
+ const frontmatterPath = join(agentDirPath, harnessDir, "frontmatter.json");
108
+ if (!existsSync(frontmatterPath)) {
109
+ continue; // Skip directories without frontmatter.json
110
+ }
111
+
112
+ try {
113
+ const content = readFileSync(frontmatterPath, "utf-8");
114
+ const fm = JSON.parse(content);
115
+ const result = validateFrontmatter(fm);
116
+ if (!result.ok) {
117
+ for (const err of result.errors) {
118
+ errors.push(`${harnessDir}/frontmatter.json: ${err}`);
119
+ }
120
+ }
121
+ } catch (e) {
122
+ errors.push(`${harnessDir}/frontmatter.json: invalid JSON`);
123
+ }
124
+ }
125
+
126
+ return { ok: errors.length === 0, errors };
127
+ }
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: write-a-skill
3
+ description: "Create new agent skills with canonical anatomy, progressive disclosure, and reusable helpers. Use when the user says \"write a skill\", \"create a skill\", \"make me a skill\", or \"new skill\"."
4
+ ---
5
+
6
+ # Write a Skill
7
+
8
+ ## When to use
9
+
10
+ - The user asks to create a brand-new skill from scratch.
11
+ - The user says "write a skill", "create a skill", "make me a skill", or "new skill".
12
+ - A new capability needs to be packaged as a reusable skill with a deterministic workflow.
13
+
14
+ ## When NOT to use
15
+
16
+ - Refactoring an existing skill to the anatomy template — use `refactor-skill` instead.
17
+ - Minor copy-editing or typo fixes that do not need a full creation workflow.
18
+ - Skills that are not intended to be reusable (one-off scripts, ad-hoc instructions).
19
+
20
+ ## Workflow
21
+
22
+ ### 1. Gather requirements
23
+
24
+ Clarify the skill goal with the user. Ask what triggers users would actually say, what output the skill produces, and whether any deterministic helper scripts are needed.
25
+
26
+ ### 2. Draft from the anatomy template
27
+
28
+ Read `docs/skills/skill-anatomy.md` as the source of truth. Follow the annotated template for section ordering and front-matter fields. Target ~150 lines for `SKILL.md` but stay under the 150-line hard cap.
29
+
30
+ ### 3. Apply voice and tone rules
31
+
32
+ Write the body in imperative second-person: "Run X", "Check Y", "Report Z". Prefer positive framing over prohibitions. Add a one-sentence rationale for any non-obvious rule so the model can generalise from it. Avoid ALL-CAPS emphasis.
33
+
34
+ ### 4. Define front-matter fields
35
+
36
+ Required: `name` (kebab-case), `description` (two sentences, second starts with "Use when", includes 2-4 quoted trigger phrases). Optional: `argument-hint`, `disable-model-invocation` when the skill requires them.
37
+
38
+ ### 5. Split supporting docs when appropriate
39
+
40
+ Move long examples to `EXAMPLES.md`, output formats to `FORMAT.md`, and infrequently-needed edge cases to `REFERENCE.md`. Keep `SKILL.md` focused on the primary workflow.
41
+
42
+ ### 6. Run the review checklist
43
+
44
+ Verify the final document against the verification checklist below before finishing.
45
+
46
+ ## Red Flags
47
+
48
+ - **Writing without reading the anatomy template first** — The template defines section ordering, voice rules, and inclusion criteria for optional sections. Guessing leads to drift.
49
+ - **Padding sections with generic content** — Every section must earn its place with content specific to the skill's purpose. Copying generic filler from the template placeholder text produces a weak skill.
50
+ - **Skipping the trigger-phrase interview** — The description's trigger phrases are the main routing signal for the skill. Guessing what users say rather than asking produces a skill that is hard to invoke.
51
+
52
+ ## Cross-skill references
53
+
54
+ - Use `refactor-skill` when the task is upgrading an existing skill rather than creating a new one.
55
+ - Run `style-code` after writing to check that code conventions in any example snippets or bundled scripts are consistent.
56
+ - Run `review-security` before committing to check for leaked secrets in examples or documentation.
57
+
58
+ ## Examples
59
+
60
+ Input: "Write a skill that scans git diffs for secrets"
61
+ Output: A new `skills/review-security/SKILL.md` with front matter, When to use, Workflow, and Verification checklist following the anatomy template.
62
+
63
+ ## Verification checklist
64
+
65
+ - [ ] `docs/skills/skill-anatomy.md` was read before drafting
66
+ - [ ] Required sections present: `## When to use`, `## Workflow`, `## Verification checklist`
67
+ - [ ] Section order follows the anatomy template
68
+ - [ ] Description uses two-sentence format with 2-4 quoted trigger phrases
69
+ - [ ] Body uses imperative second-person voice with positive framing
70
+ - [ ] Rationale sentences added for non-obvious rules
71
+ - [ ] No ALL-CAPS emphasis
72
+ - [ ] `SKILL.md` ≤ 150 lines (`wc -l skills/<name>/SKILL.md`)
73
+ - [ ] Supporting docs split by purpose when `SKILL.md` exceeds ~150 lines
74
+ - [ ] Cross-skill references point to `refactor-skill` for upgrades where relevant
@@ -0,0 +1,246 @@
1
+ # Reference: Maintain Agent Docs
2
+
3
+ Detailed templates, examples, and anti-patterns for AGENTS.md and docs/ maintenance.
4
+
5
+ ## AGENTS.md Template
6
+
7
+ ```markdown
8
+ # AGENTS.md
9
+
10
+ Instructions for agents working on this repository.
11
+
12
+ ## What This Project Is
13
+
14
+ [One sentence describing the project's purpose.]
15
+
16
+ ## Commands
17
+
18
+ [List exact commands agents will need. Put these early — agents perform best when
19
+ they know what to run.]
20
+
21
+ | Task | Command |
22
+ |------|---------|
23
+ | Install | `npm install` |
24
+ | Build | `npm run build` |
25
+ | Test (all) | `npm test` |
26
+ | Test (single) | `npm test -- --grep "pattern"` |
27
+ | Lint | `npm run lint` |
28
+ | Type check | `npx tsc --noEmit` |
29
+
30
+ ## Project Structure
31
+
32
+ [Directory map with purposes. Focus on stable structure, not individual files.]
33
+
34
+ ## Code Style
35
+
36
+ [Conventions with concrete examples. Show a "good" snippet, not just rules.]
37
+
38
+ ## Testing
39
+
40
+ [Frameworks, coverage expectations, where tests live, naming conventions.]
41
+
42
+ ## Git Workflow
43
+
44
+ [Branch naming, commit conventions, PR process.]
45
+
46
+ ## Boundaries
47
+
48
+ [What agents must NOT do. Be explicit.]
49
+
50
+ - Never modify files in `vendor/` or `dist/`
51
+ - Never commit secrets or credentials
52
+ - Never delete migration files
53
+ ```
54
+
55
+ ## Section-by-Section Guidance
56
+
57
+ ### Commands
58
+
59
+ The highest-impact section. Put it near the top.
60
+
61
+ - Include exact flags and options, not just the base command
62
+ - Show the single-file variants (e.g. how to run one test, lint one file)
63
+ - If commands vary by environment, show a table
64
+
65
+ **Good:**
66
+
67
+ ```markdown
68
+ | Task | Command |
69
+ |------|---------|
70
+ | Test all | `pytest -v --tb=short` |
71
+ | Test one file | `pytest tests/test_auth.py -v` |
72
+ | Test with coverage | `pytest --cov=src --cov-report=term-missing` |
73
+ ```
74
+
75
+ **Bad:**
76
+
77
+ ```markdown
78
+ Run `pytest` to test.
79
+ ```
80
+
81
+ ### Project Structure
82
+
83
+ Show what each top-level directory is for. Avoid listing every file — the structure
84
+ changes; the purposes don't.
85
+
86
+ **Good:**
87
+
88
+ ```markdown
89
+ src/
90
+ ├── api/ # HTTP handlers and route definitions
91
+ ├── domain/ # Business logic, pure functions
92
+ ├── infra/ # Database, external service clients
93
+ └── shared/ # Cross-cutting utilities and types
94
+ ```
95
+
96
+ **Bad:**
97
+
98
+ ```markdown
99
+ src/
100
+ ├── api/
101
+ │ ├── routes.ts
102
+ │ ├── middleware.ts
103
+ │ ├── auth.ts
104
+ │ ├── users.ts
105
+ │ └── ...
106
+ ```
107
+
108
+ ### Boundaries
109
+
110
+ Frame as "never" rules. Agents follow prohibitions more reliably than preferences.
111
+
112
+ - Start each rule with "Never" or "Do not"
113
+ - Be specific about paths and actions
114
+ - Explain why if the reason isn't obvious
115
+
116
+ ### Code Style
117
+
118
+ Show, don't tell. A short before/after example communicates more than a list of rules.
119
+
120
+ **Good:**
121
+
122
+ ```markdown
123
+ ## Naming
124
+
125
+ ```ts
126
+ // ✅ Use descriptive names; Boolean variables start with is/has/should
127
+ const isAuthenticated = true;
128
+ const hasPermission = checkAccess(user, resource);
129
+
130
+ // ❌ Avoid abbreviations and generic names
131
+ const auth = true;
132
+ const flag = check(u, r);
133
+ `` `
134
+ ```
135
+
136
+ **Bad:**
137
+
138
+ ```markdown
139
+ ## Naming
140
+
141
+ - Use descriptive names
142
+ - Boolean variables should start with is, has, or should
143
+ - Avoid abbreviations
144
+ ```
145
+
146
+ ## docs/ Organisation
147
+
148
+ Keep docs/ flat and purpose-driven:
149
+
150
+ ```
151
+ docs/
152
+ ├── architecture.md # System design, module boundaries, data flow
153
+ ├── decisions/ # ADRs (Architecture Decision Records)
154
+ │ ├── 001-use-postgres.md
155
+ │ └── 002-event-sourcing.md
156
+ └── runbooks/ # Operational procedures
157
+ ├── deploy.md
158
+ └── incident-response.md
159
+ ```
160
+
161
+ - Each file should have one clear purpose
162
+ - Prefer updating an existing file over creating a new one
163
+ - Link from AGENTS.md into docs/ for detail — don't duplicate
164
+
165
+ ## Anti-Patterns
166
+
167
+ | Anti-pattern | Why it's harmful | Fix |
168
+ |---|---|---|
169
+ | **Listing every file** | Goes stale immediately; wastes tokens | Describe directory purposes instead |
170
+ | **"Be helpful"** | Too vague to change agent behaviour | Give specific instructions with examples |
171
+ | **Duplicating README content** | Two sources of truth that drift apart | Reference README, don't copy it |
172
+ | **No commands section** | Agents guess at commands, often wrong | Add exact commands with flags |
173
+ | **Aspirational docs** | Describes what you wish the code did | Document current reality only |
174
+ | **Monolithic AGENTS.md** | Everything in one file; bloats every conversation | Push detail to scoped files and docs/ |
175
+ | **Kitchen-sink instructions** | Agent processes every line, even irrelevant ones | Only include what the code can't answer |
176
+ | **Burying critical commands** | "Lost in the Middle" — attention drops with position | Put commands and boundaries first |
177
+
178
+ ## Progressive Disclosure In Practice
179
+
180
+ ### Why it matters
181
+
182
+ AGENTS.md is loaded into every agent conversation. Benchmarks show:
183
+
184
+ - Bloated context files reduce task success by 2-3% while increasing inference cost 20%+ (ETH Zurich, ICSE 2026)
185
+ - Instructions at position 10 in a config file receive 27% less attention than position 1 (Stanford, "Lost in the Middle")
186
+ - Agents process every instruction dutifully — even irrelevant ones — wasting attention budget
187
+
188
+ **Treat AGENTS.md as a cache for ambiguity resolution**, not a comprehensive manual.
189
+
190
+ ### The three-tier hierarchy
191
+
192
+ ```
193
+ Tier 1: AGENTS.md (root) ← always loaded
194
+ What the project is, build/test/lint commands, structure overview,
195
+ code style summary, git workflow, hard boundaries.
196
+ Target: under 100 lines.
197
+
198
+ Tier 2: .instructions.md (scoped) ← loaded when working in that path
199
+ Path-specific conventions, module-specific boundaries,
200
+ framework-specific patterns.
201
+ Example: src/api/.instructions.md with API-specific conventions.
202
+
203
+ Tier 3: docs/ (on-demand) ← agent reads when needed
204
+ Architecture docs, ADRs, runbooks, detailed design documents.
205
+ Referenced from AGENTS.md but not inlined.
206
+ ```
207
+
208
+ ### Scoped `.instructions.md` example
209
+
210
+ ```markdown
211
+ ---
212
+ applyTo: "src/api/**"
213
+ ---
214
+
215
+ # API Module Instructions
216
+
217
+ - All handlers return standardised error objects (see docs/architecture.md)
218
+ - Use Zod for request validation; never trust raw input
219
+ - Integration tests live alongside the handler files as `*.integration.test.ts`
220
+ ```
221
+
222
+ ### The audit question
223
+
224
+ For every line in AGENTS.md, ask:
225
+
226
+ > "Could an agent infer this by reading the code or running a command?"
227
+
228
+ If yes — remove it. If it only applies to one area — move it to a scoped file. Only what resolves genuine ambiguity earns a place in the root file.
229
+
230
+ ### Sizing guide
231
+
232
+ | File | Target | Rationale |
233
+ |---|---|---|
234
+ | AGENTS.md | < 100 lines | Always loaded; every line costs attention |
235
+ | Scoped .instructions.md | < 50 lines each | Loaded per-path; keep focused |
236
+ | docs/ files | No hard limit | Read on demand; depth is fine |
237
+
238
+ ## Drift Detection Heuristic
239
+
240
+ When auditing, look for these signals that docs have drifted:
241
+
242
+ 1. **Commands that fail** — try running them; if they error, the docs are stale
243
+ 2. **Directories that don't exist** — referenced paths that have been renamed or removed
244
+ 3. **Technologies not in package.json/requirements.txt** — docs mention tools the project no longer uses
245
+ 4. **Missing new tooling** — project has added linters, formatters, or CI steps not reflected in docs
246
+ 5. **Contradictions** — AGENTS.md says one thing, a nested .instructions.md says another
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: maintain-agent-docs
3
+ description: "Audit and update AGENTS.md and docs/ to keep agent-consumed documentation accurate, specific, and drift-free. Use when user wants to review, update, or improve AGENTS.md, docs/, or other documentation that agents rely on."
4
+ ---
5
+
6
+ # Maintain Agent Docs
7
+
8
+ Keep AGENTS.md and docs/ accurate, specific, and in sync with the codebase. Also invoke the `style-documentation` skill — its philosophy governs what to document and when.
9
+
10
+ ## When To Use
11
+
12
+ - After significant codebase changes (new tooling, renamed modules, changed workflows)
13
+ - When agents are producing poor results due to stale or missing instructions
14
+ - Periodic maintenance — or after major releases
15
+ - When onboarding a new repo to agent-assisted workflows
16
+
17
+ ## Process
18
+
19
+ ### 1. Audit
20
+
21
+ Scan the repository to build a picture of the current state:
22
+
23
+ - Read existing AGENTS.md (root and any nested copies) and docs/ contents
24
+ - Compare instructions against actual codebase: directory structure, runnable commands, conventions, tooling
25
+ - Check context budget: is AGENTS.md under 100 lines? Is detail pushed to scoped files?
26
+ - Flag issues, grouped by type:
27
+ - **Drift** — instructions that no longer match the codebase
28
+ - **Gaps** — important context missing entirely
29
+ - **Vagueness** — instructions too generic to be actionable
30
+ - **Bloat** — content that belongs in scoped files or docs/, not the root
31
+
32
+ Present findings as a numbered list. Do NOT fix anything yet.
33
+
34
+ ### 2. Propose changes
35
+
36
+ For each issue, propose a specific fix. Present all proposals for user review before applying.
37
+
38
+ ### 3. Apply changes
39
+
40
+ After approval, update files following the quality principles below.
41
+
42
+ ## Context Budget
43
+
44
+ AGENTS.md is injected into every agent conversation. Every line costs tokens and attention. Research shows bloated context files *reduce* task success while increasing cost 20%+ (ETH Zurich, ICSE 2026). Instructions buried past the first few sections receive significantly less attention ("Lost in the Middle", Stanford).
45
+
46
+ **AGENTS.md is an index of expensive truths** — only include what the codebase cannot answer on its own. If an agent could infer it by reading the code, it does not belong here.
47
+
48
+ ### Progressive disclosure hierarchy
49
+
50
+ Not everything belongs in the root file. Push detail to where it's needed:
51
+
52
+ 1. **AGENTS.md** (root) — project-wide truths: what it is, how to build/test/lint, structure overview, hard boundaries. Aim for under 100 lines.
53
+ 2. **Scoped `.instructions.md`** — path-specific guidance loaded only when the agent works in that area. Use `applyTo` globs to target file types or directories.
54
+ 3. **docs/** — deeper context (architecture, ADRs, runbooks) that agents can read on demand but shouldn't carry in every conversation.
55
+
56
+ When auditing, ask: "Does this line resolve an ambiguity that the code alone cannot?" If not, move it down a level or remove it.
57
+
58
+ ## Quality Principles
59
+
60
+ 1. **Specificity over generality** — `npm test -- --coverage` not "run the tests"
61
+ 2. **Commands up front** — build, test, lint commands in the first section, with exact flags. Position 1 gets the most attention; use it.
62
+ 3. **Examples over explanations** — one code snippet > one paragraph of prose
63
+ 4. **Six core areas** — commands, testing, project structure, code style, git workflow, boundaries
64
+ 5. **Explicit boundaries** — state what agents must NOT do
65
+ 6. **Tech stack with versions** — "React 18, TypeScript 5.x, Vite" not "a React project"
66
+ 7. **Drift-resistant** — reference stable concepts (directory purposes, architectural decisions) over volatile details (file lists that change weekly)
67
+ 8. **Progressive disclosure** — push path-specific or rarely-needed detail into scoped files or docs/, not the root AGENTS.md
68
+ 9. **No duplication** — reference other docs, don't restate their content
69
+ 10. **Sparse and maintained** — every line must earn its place; a short accurate file outperforms a comprehensive stale one
70
+
71
+ ## Structure Checklist
72
+
73
+ A well-maintained AGENTS.md covers:
74
+
75
+ - [ ] What the project is (one sentence)
76
+ - [ ] How to build, test, and lint (exact commands)
77
+ - [ ] Project structure (directory map with purposes)
78
+ - [ ] Code style and conventions (with examples)
79
+ - [ ] Git workflow (branching, commit, PR conventions)
80
+ - [ ] Boundaries (forbidden files, actions, patterns)
81
+ - [ ] Testing approach (frameworks, coverage expectations)
82
+
83
+ See [REFERENCE.md](REFERENCE.md) for templates, examples, and detailed section guidance.
@@ -0,0 +1,20 @@
1
+ # Examples
2
+
3
+ ## Template comparison output shape
4
+
5
+ The output of Step 2 (template comparison) drives the whole rewrite. Below is a compact before/after table showing what the comparison output looks like for a typical skill being refactored.
6
+
7
+ ```
8
+ Skill: review-security
9
+
10
+ | Dimension | Current state | Template says | Verdict |
11
+ |---|---|---|---|
12
+ | Front matter | name: review-security, no description field | name, description required | Partial — add description |
13
+ | Description | Missing entirely | 2 sentences, Use when ..., 2-4 triggers | Missing — add |
14
+ | When to use | Single sentence | Trigger phrases listed explicitly | Needs rewording |
15
+ | Workflow | 2 prose paragraphs | Numbered steps with outcomes | Needs restructuring |
16
+ | Verification checklist | Missing | Required section | Missing — add |
17
+ | Line length | 45 lines | ~150 target, 150 hard cap | Under — room to expand |
18
+ ```
19
+
20
+ The same structure applies to any skill. Dimensions that already align can be noted as "Aligned — no change needed", keeping the comparison honest rather than gap-focused.