agent-directives 0.1.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 (57) hide show
  1. package/README.md +385 -0
  2. package/directives/adaptive-routing.md +361 -0
  3. package/directives/architecture-boundaries.md +223 -0
  4. package/directives/codebase-navigation.md +325 -0
  5. package/directives/context-handoff.md +220 -0
  6. package/directives/error-memory.md +169 -0
  7. package/directives/exploration-mode.md +266 -0
  8. package/directives/session-decisions.md +193 -0
  9. package/directives/specification-driven-development.md +278 -0
  10. package/directives/task-framing.md +154 -0
  11. package/directives/test-driven-development.md +305 -0
  12. package/directives/type-driven-development.md +173 -0
  13. package/directives/verification.md +266 -0
  14. package/directives/workspace-isolation.md +219 -0
  15. package/dist/cli.d.ts +3 -0
  16. package/dist/cli.d.ts.map +1 -0
  17. package/dist/cli.js +232 -0
  18. package/dist/cli.js.map +1 -0
  19. package/dist/context-audit.d.ts +30 -0
  20. package/dist/context-audit.d.ts.map +1 -0
  21. package/dist/context-audit.js +75 -0
  22. package/dist/context-audit.js.map +1 -0
  23. package/dist/install.d.ts +18 -0
  24. package/dist/install.d.ts.map +1 -0
  25. package/dist/install.js +28 -0
  26. package/dist/install.js.map +1 -0
  27. package/dist/manifest.d.ts +25 -0
  28. package/dist/manifest.d.ts.map +1 -0
  29. package/dist/manifest.js +29 -0
  30. package/dist/manifest.js.map +1 -0
  31. package/dist/prompt.d.ts +3 -0
  32. package/dist/prompt.d.ts.map +1 -0
  33. package/dist/prompt.js +29 -0
  34. package/dist/prompt.js.map +1 -0
  35. package/dist/targets.d.ts +10 -0
  36. package/dist/targets.d.ts.map +1 -0
  37. package/dist/targets.js +32 -0
  38. package/dist/targets.js.map +1 -0
  39. package/manifest.json +387 -0
  40. package/package.json +74 -0
  41. package/skills/architecture-boundary-reviewer/SKILL.md +228 -0
  42. package/skills/code-reviewer/SKILL.md +77 -0
  43. package/skills/codebase-health-reviewer/SKILL.md +234 -0
  44. package/skills/harness-hooks-reviewer/SKILL.md +159 -0
  45. package/skills/implementation-task-planner/SKILL.md +205 -0
  46. package/skills/mcp-integration-reviewer/SKILL.md +157 -0
  47. package/skills/product-requirements-writer/SKILL.md +205 -0
  48. package/skills/production-readiness-reviewer/SKILL.md +240 -0
  49. package/skills/self-audit/SKILL.md +134 -0
  50. package/skills/spec-reviewer/SKILL.md +304 -0
  51. package/skills/subagent-driven-development/SKILL.md +236 -0
  52. package/skills/systematic-debugging/SKILL.md +313 -0
  53. package/skills/test-reviewer/SKILL.md +293 -0
  54. package/templates/AGENTS.md +120 -0
  55. package/templates/CLAUDE.md +115 -0
  56. package/templates/copilot-instructions.md +116 -0
  57. package/templates/decision-log.md +44 -0
package/README.md ADDED
@@ -0,0 +1,385 @@
1
+ # Agent Directives
2
+
3
+ A collection of reusable directives, skills, and templates for AI coding agents.
4
+ Extract the parts you need, drop them into your project, and customize the
5
+ placeholders. Everything works standalone — no framework lock-in, no hidden
6
+ dependencies between files.
7
+
8
+ ## What's Included
9
+
10
+ | Category | Files | What they do |
11
+ |----------|-------|--------------|
12
+ | **Workflow** | 10 directives | Govern how the agent works: adaptive routing, workspace isolation, context handoff, TDD, type-first, spec-driven, verification, task framing, exploration, architecture boundaries |
13
+ | **Navigation** | 1 directive | SAFE pattern for exploring codebases before implementation |
14
+ | **Memory** | 2 directives | Error memory and session decisions for persistent learning |
15
+ | **Skills** | 13 skills | Code reviewer, test reviewer, spec reviewer, product requirements writer, implementation task planner, subagent-driven development, self-audit, systematic debugging, architecture boundary reviewer, codebase health reviewer, production readiness reviewer, harness hooks reviewer, and MCP integration reviewer |
16
+ | **Templates** | 4 templates | Drop-in instruction files for AGENTS.md, CLAUDE.md, Copilot, and decision logs |
17
+ | **Tooling** | TypeScript scripts | Validate directive wiring, assemble eval scenarios, record loaded-file manifests, and generate eval health reports |
18
+
19
+ ## Quick Start
20
+
21
+ The repository contains two things you install into your own project:
22
+
23
+ 1. **Directive and skill files** — copied from `directives/` and `skills/`.
24
+ 2. **A root instruction file** — copied from `templates/` and renamed for your agent
25
+ (`AGENTS.md`, `CLAUDE.md`, or `.github/copilot-instructions.md`).
26
+
27
+ For a typical Codex/OpenAI-style project, run these commands from the repository
28
+ that should receive the instructions:
29
+
30
+ ```bash
31
+ cd /path/to/your-project
32
+
33
+ # Once published to npm:
34
+ npx agent-directives sync --tool codex --yes
35
+
36
+ # Until the first npm release is available, use the GitHub source package:
37
+ npx --yes github:pertrai1/agent-directives sync --tool codex --yes
38
+
39
+ # Add the root instruction file, then edit every <!-- FILL IN: ... --> placeholder.
40
+ curl -fsSL \
41
+ https://raw.githubusercontent.com/pertrai1/agent-directives/main/templates/AGENTS.md \
42
+ -o AGENTS.md
43
+ ```
44
+
45
+ If your project already has an `AGENTS.md`, `CLAUDE.md`, or Copilot instruction
46
+ file, do not overwrite it blindly. Merge the relevant sections from the matching
47
+ template instead.
48
+
49
+ After installation, open the root instruction file and:
50
+
51
+ 1. Fill in the project-specific placeholders.
52
+ 2. Keep `directives/adaptive-routing.md` as the first directive the agent loads.
53
+ 3. Delete directives or skills your team does not want, then remove matching rows
54
+ from the root instruction file.
55
+ 4. Run the check command for your target tool:
56
+
57
+ ```bash
58
+ npx --yes github:pertrai1/agent-directives check --tool codex
59
+ ```
60
+
61
+ ## Installing for Different Tools
62
+
63
+ | Tool | npm package command | GitHub source command | Root instruction file |
64
+ | --- | --- | --- | --- |
65
+ | Codex / OpenAI agents | `npx agent-directives sync --tool codex --yes` | `npx --yes github:pertrai1/agent-directives sync --tool codex --yes` | `templates/AGENTS.md` → `AGENTS.md` |
66
+ | Claude Code | `npx agent-directives sync --tool claude --yes` | `npx --yes github:pertrai1/agent-directives sync --tool claude --yes` | `templates/CLAUDE.md` → `CLAUDE.md` |
67
+ | GitHub Copilot | `npx agent-directives sync --tool copilot --yes` | `npx --yes github:pertrai1/agent-directives sync --tool copilot --yes` | `templates/copilot-instructions.md` → `.github/copilot-instructions.md` |
68
+ | Cursor | `npx agent-directives sync --tool cursor --yes` | `npx --yes github:pertrai1/agent-directives sync --tool cursor --yes` | Installed as `.cursor/rules/*.mdc` |
69
+
70
+ When `--tool` is omitted, the CLI tries to auto-detect the target from marker
71
+ files in the current directory. Passing `--tool` is safer for first-time setup.
72
+
73
+ ## CLI Reference
74
+
75
+ The `agent-directives` CLI reads `manifest.json` and copies the requested entries
76
+ into the current working directory. Use it from the project that should receive
77
+ the files.
78
+
79
+ ### Commands
80
+
81
+ ```bash
82
+ npx agent-directives list # List all entries
83
+ npx agent-directives list --required # Only required entries
84
+ npx agent-directives list --category review
85
+ npx agent-directives list --tool cursor
86
+ npx agent-directives list --type skill
87
+
88
+ npx agent-directives add code-reviewer --tool claude
89
+ npx agent-directives add code-reviewer --tool claude --force
90
+
91
+ npx agent-directives check --tool codex
92
+ npx agent-directives context-audit --tool codex --required
93
+ npx agent-directives context-audit --tool codex --required --max-tokens 12000
94
+ npx agent-directives sync --tool claude --yes
95
+ npx agent-directives sync --tool claude --force
96
+ ```
97
+
98
+ ### Context budget audit
99
+
100
+ Use `context-audit` to estimate how much prompt budget a tool/profile consumes before copying instructions into a project:
101
+
102
+ ```bash
103
+ npx agent-directives context-audit --tool codex --required
104
+ npx agent-directives context-audit --tool claude --max-tokens 20000
105
+ ```
106
+
107
+ The estimate uses a simple `characters / 4` heuristic and reports total tokens, required vs optional counts, and the largest directive/skill files. With `--max-tokens`, the command exits non-zero when the selected entries exceed the budget, making it usable in CI.
108
+
109
+ ### Tool auto-detection
110
+
111
+ When `--tool` is omitted, the CLI inspects the current directory for marker files:
112
+
113
+ | Marker | Tool |
114
+ | --- | --- |
115
+ | `.cursor/` | `cursor` |
116
+ | `.github/copilot-instructions.md` | `copilot` |
117
+ | `AGENTS.md` | `codex` |
118
+ | `CLAUDE.md` or `.claude/` | `claude` |
119
+
120
+ Pass `--tool` explicitly when auto-detection is ambiguous or wrong.
121
+
122
+ ### Install layout
123
+
124
+ For `claude`, `copilot`, and `codex`, the CLI preserves the source layout — each
125
+ entry is written to its declared path (`directives/<name>.md` or
126
+ `skills/<name>/SKILL.md`) relative to the current working directory. The root
127
+ instruction file is left to you so existing project instructions are not
128
+ accidentally overwritten.
129
+
130
+ For `cursor`, each entry is flattened to a single file in `.cursor/rules/<id>.mdc`.
131
+
132
+ ### Conflict handling
133
+
134
+ `agent-directives add` and `agent-directives sync` never silently overwrite a locally-modified file. If a target file already exists with content that differs from the source, the CLI reports a conflict and exits non-zero unless `--force` is passed. Files that already match the source are reported as `already up-to-date` and skipped.
135
+
136
+ ### Local development
137
+
138
+ ```bash
139
+ npm install
140
+ npm run cli -- list # invoke the CLI via npm
141
+ npm run test:cli # run CLI integration tests
142
+ npm run pack:check # build and inspect package contents
143
+ ```
144
+
145
+ ### Publishing
146
+
147
+ Releases use Changesets and GitHub Actions, matching the release flow used by
148
+ `eslint-plugin-llm-core`:
149
+
150
+ 1. Add a changeset for user-visible package changes:
151
+ `npm run changeset`.
152
+ 2. Merge the PR to `main`.
153
+ 3. The release workflow either opens/updates the `chore: version packages` PR or,
154
+ after that PR is merged, publishes the package with npm provenance and creates
155
+ a GitHub release.
156
+
157
+ Before publishing for the first time, configure npm trusted publishing for this
158
+ repository/package or provide equivalent npm automation credentials. The workflow
159
+ uses `id-token: write` and `npm publish --provenance`.
160
+
161
+ ## Directives vs Skills
162
+
163
+ | | Directive | Skill |
164
+ |---|---|---|
165
+ | **Nature** | Rule you follow | Persona you adopt |
166
+ | **When** | At a workflow phase | For a task type |
167
+ | **Output** | Constrained behavior | Structured findings |
168
+ | **Tone** | "Never do X" / "Always do Y" | "You are a specialist in..." |
169
+ | **Format** | Rules + forbidden patterns table | Frontmatter + review process + output format |
170
+
171
+ ## Directives
172
+
173
+ ### Adaptive Routing (`directives/adaptive-routing.md`)
174
+
175
+ Runs first and selects the lightest safe workflow based on task intent, risk,
176
+ and touched surfaces. Prevents loading every directive by default while still
177
+ escalating to Full, Debugging, Boundary, Review, Exploration, or Policy paths
178
+ when the task requires stronger evidence.
179
+
180
+ ### Workspace Isolation (`directives/workspace-isolation.md`)
181
+
182
+ Protects mutable work from leaking into a shared checkout. Detects existing
183
+ isolation first, prefers native workspace/worktree tooling when available, falls
184
+ back to `git worktree` only when needed, and requires setup/baseline proof in the
185
+ workspace where implementation will actually run.
186
+
187
+
188
+ ### Context Handoff (`directives/context-handoff.md`)
189
+
190
+ Compacts task state at directive, phase, PR, or session boundaries so later phases
191
+ can continue from a current handoff instead of accumulated chat history. Defines
192
+ `.agents/handoff.md` as the preferred active handoff file, rewrites it instead of
193
+ appending forever, and treats optional handoff logs as historical rather than
194
+ authoritative.
195
+
196
+ ### Test-Driven Development (`directives/test-driven-development.md`)
197
+
198
+ Strict RED/GREEN/REFACTOR cycle for behavior-changing code. Defines TDD rules, a
199
+ forbidden-patterns table, and makes TDD the default for fixes and review changes
200
+ that affect runtime behavior — while allowing adaptive routing to choose a lighter
201
+ path for purely mechanical or non-behavioral edits.
202
+
203
+ ### Type-First Development (`directives/type-driven-development.md`)
204
+
205
+ Define types before writing implementation code. Five-step flow: check, define,
206
+ verify, confirm (for complex types), and hand off to TDD. Keeps type-check
207
+ commands generic with TypeScript as an example.
208
+
209
+ ### Task Framing (`directives/task-framing.md`)
210
+
211
+ Intake checklist for non-trivial work. Eight-point framing checklist that
212
+ catches ambiguous requirements before implementation starts. Defines when a
213
+ proposal must precede implementation.
214
+
215
+ ### Codebase Navigation (`directives/codebase-navigation.md`)
216
+
217
+ SAFE exploration pattern (Survey, Anchor, Filter, Execute) with token budgets.
218
+ Five context-discipline rules that prevent the agent from reading too much
219
+ irrelevant code before starting work.
220
+
221
+ ### Architecture Boundaries (`directives/architecture-boundaries.md`)
222
+
223
+ Preserve the project's directed architecture graph before changing imports,
224
+ exports, folders, packages, services, or shared code. Requires agents to classify
225
+ touched files into zones, identify changed dependency edges, and verify no upward,
226
+ sideways, cyclic, or public-API-bypassing dependency was introduced. Includes
227
+ optional Fallow and GitNexus checks for tool-assisted boundary evidence.
228
+
229
+ ### Exploration Mode (`directives/exploration-mode.md`)
230
+
231
+ Pre-implementation investigation stance for thinking through problems before
232
+ committing to an approach. Curious, grounded, visual — no code during exploration.
233
+ Fills the gap between codebase navigation (how to search) and task framing
234
+ (how to scope).
235
+
236
+ ### Specification-Driven Development (`directives/specification-driven-development.md`)
237
+
238
+ Write specifications before code, implement against specs, verify after.
239
+ Five-phase loop: propose, design, specify, implement, verify. Operates above
240
+ TDD (correctness) and type-driven (shapes) — this directive defines what and why.
241
+
242
+ ### Verification Protocol (`directives/verification.md`)
243
+
244
+ Structured evidence of correctness before running quality gates. Produces a
245
+ verification summary a reviewer can scan in 30 seconds. Generic proof framework
246
+ covering functional, test coverage, integration, and documentation proof.
247
+
248
+ ### Error Memory (`directives/error-memory.md`)
249
+
250
+ Persistent memory for repeated mistakes. Four-condition write criteria prevent
251
+ the agent from logging trivial errors. Includes compaction pipeline and monthly
252
+ review with retirement mechanism.
253
+
254
+ ### Session Decisions (`directives/session-decisions.md`)
255
+
256
+ Durable decision capture at task completion. Four-condition write criteria, YAML
257
+ frontmatter schema for retrieval, progressive-disclosure workflow, and five
258
+ required sections (Title, Context, Decision, Rejected Alternatives, Consequences).
259
+
260
+ ## Skills
261
+
262
+ ### Code Reviewer (`skills/code-reviewer/SKILL.md`)
263
+
264
+ Baseline review skill for pull requests, branches, diffs, and local changes.
265
+ Checks correctness, security, performance, maintainability, tests, and merge risk
266
+ without inventing findings when the change is clean.
267
+
268
+ ### Test Reviewer (`skills/test-reviewer/SKILL.md`)
269
+
270
+ Detects tests that duplicate production logic, use shallow assertions, skip edge
271
+ cases, or assert on mocks instead of behavior. Six-step review process with
272
+ output format for flagged tests.
273
+
274
+ ### Spec Reviewer (`skills/spec-reviewer/SKILL.md`)
275
+
276
+ Reviews implementation against written specifications. Three-dimensional check:
277
+ completeness (all requirements implemented), correctness (code matches spec
278
+ intent), and coherence (design decisions followed). Natural pairing with
279
+ test-reviewer — one reviews tests, the other reviews implementation against specs.
280
+
281
+ ### Product Requirements Writer (`skills/product-requirements-writer/SKILL.md`)
282
+
283
+ Turns rough feature ideas, product requests, vague requirements, or problem
284
+ statements into concrete PRDs/specs before implementation planning. Asks only
285
+ essential clarifying questions, captures goals and non-goals, and stops before
286
+ coding.
287
+
288
+ ### Implementation Task Planner (`skills/implementation-task-planner/SKILL.md`)
289
+
290
+ Turns a PRD, issue, acceptance criteria, or requirements document into a staged
291
+ implementation task list with relevant files, likely tests, validation gates, and
292
+ review checkpoints. Grounds file paths in repo evidence or marks them tentative.
293
+
294
+ ### Subagent-Driven Development (`skills/subagent-driven-development/SKILL.md`)
295
+
296
+ Executes an existing implementation plan through delegated subagents or isolated
297
+ worker sessions while the parent agent owns task slicing, scope, review,
298
+ integration, and final verification. Prevents unsafe parallel writes and requires
299
+ self-contained worker prompts.
300
+
301
+ ### Self-Audit (`skills/self-audit/SKILL.md`)
302
+
303
+ Triage point between TDD and verification. After GREEN/REFACTOR, identifies the
304
+ single weakest assumption (Jenga Test), logs anomalies that passing tests mask,
305
+ and checks for sunk-cost trajectory across cycles. Each finding is routed: fix
306
+ now (loop back to RED), document for the PR reviewer, or ask the human. Output
307
+ goes in the PR body before the verification section.
308
+
309
+ ### Systematic Debugging (`skills/systematic-debugging/SKILL.md`)
310
+
311
+ Root-cause debugging process for bugs, failing tests, CI failures, regressions,
312
+ flaky behavior, and unexpected system behavior. Four phases — reproduce and
313
+ observe, localize the fault, form and test one hypothesis, then fix and prove —
314
+ prevent guess-and-check patches and require evidence before code changes.
315
+
316
+ ### Architecture Boundary Reviewer (`skills/architecture-boundary-reviewer/SKILL.md`)
317
+
318
+ Reviews whether a change preserves architectural zones, dependency direction,
319
+ public APIs, package/service boundaries, and DAG constraints. Catches illegal
320
+ imports, public API bypasses, cycles, and shared-code pollution that tests may
321
+ not reveal.
322
+
323
+ ### Codebase Health Reviewer (`skills/codebase-health-reviewer/SKILL.md`)
324
+
325
+ Interprets Fallow and fallback static-analysis output for TypeScript/JavaScript
326
+ codebase health: dead code, duplication, complexity, circular dependencies,
327
+ boundary violations, and architecture drift. Separates new regressions from
328
+ pre-existing cleanup follow-ups.
329
+
330
+ ### Production Readiness Reviewer (`skills/production-readiness-reviewer/SKILL.md`)
331
+
332
+ Reviews whether working code is safe to ship and operate when a change touches
333
+ persistence, external services, async jobs, auth/security/privacy, infra/config,
334
+ critical user paths, performance/scale, or cross-service compatibility. Focuses
335
+ on failure modes, observability, rollback/recovery, data safety, compatibility,
336
+ and scale.
337
+
338
+ ### Harness Hooks Reviewer (`skills/harness-hooks-reviewer/SKILL.md`)
339
+
340
+ Reviews agent harness hooks and deterministic automation such as start/stop hooks,
341
+ pre-action policy gates, post-change checks, and session logging. Focuses on
342
+ trigger scope, side effects, failure modes, timeouts, secret handling, and whether
343
+ the hook enforces deterministic behavior rather than vague prompt policy.
344
+
345
+ ### MCP Integration Reviewer (`skills/mcp-integration-reviewer/SKILL.md`)
346
+
347
+ Reviews MCP servers and agent-accessible tool surfaces such as internal API
348
+ bridges, structured search, docs/ticketing/analytics connectors, schemas, and
349
+ write-capable tools. Focuses on tool routing, strict validation, least privilege,
350
+ bounded output, auditability, write safety, and operational failure behavior.
351
+
352
+ ## Templates
353
+
354
+ | Template | For | Key difference |
355
+ |----------|-----|----------------|
356
+ | `templates/AGENTS.md` | Codex / general agents | Full directive table with file paths, boundary step, skills table |
357
+ | `templates/CLAUDE.md` | Claude Code | Directives by name with one-line descriptions |
358
+ | `templates/copilot-instructions.md` | GitHub Copilot | Condensed — key rules inlined, points to directives/ for details |
359
+ | `templates/decision-log.md` | Any | Blank template matching the session-decisions frontmatter schema |
360
+
361
+ ## Customization
362
+
363
+ These directives are opinionated defaults. Adjust them to fit your project:
364
+
365
+ - **Remove what you don't need** — if your project doesn't use TypeScript, drop type-driven-development
366
+ - **Relax rules for prototyping** — TDD and verification can slow down throwaway work
367
+ - **Add project-specific sections** — the templates have placeholder rows for extra commands
368
+ - **Change thresholds** — token budgets in codebase-navigation, condition counts in error-memory
369
+
370
+ Every directive works standalone. There are no hidden runtime dependencies. Directive
371
+ and skill frontmatter fields provide machine-readable routing hints, but the
372
+ markdown body remains the source of truth for human-readable instructions. Some
373
+ directives intentionally reference optional follow-on phases, such as context
374
+ handoff after long or multi-phase work.
375
+
376
+ ## Tool Compatibility
377
+
378
+ These files work with any tool that reads markdown instructions:
379
+
380
+ - **Claude Code** — drop into project root as `CLAUDE.md` or load from `.claude/`
381
+ - **GitHub Copilot** — use as `.github/copilot-instructions.md`
382
+ - **Codex / OpenAI agents** — use as `AGENTS.md`
383
+ - **Cursor / Windsurf / other IDE agents** — load from the tool's instruction directory
384
+
385
+ No special syntax, no tool-specific features required. Just markdown.