agents-templated 2.1.0 → 2.2.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.
package/bin/cli.js CHANGED
@@ -10,6 +10,7 @@ const {
10
10
  LAYOUT,
11
11
  resolveRulesDir,
12
12
  resolveSkillsDir,
13
+ resolveSubagentsDir,
13
14
  hasAnyLayout,
14
15
  getLegacyMigrationPlan
15
16
  } = require('../lib/layout');
@@ -19,7 +20,8 @@ const {
19
20
  writeGeneratedInstructions,
20
21
  validateInstructionDrift,
21
22
  scaffoldSkill,
22
- scaffoldRule
23
+ scaffoldRule,
24
+ scaffoldSubagent
23
25
  } = require('../lib/instructions');
24
26
 
25
27
  // Resolve the templates directory - works in both dev and installed contexts
@@ -52,6 +54,7 @@ program
52
54
  .option('-r, --rules', 'Install agent rules only')
53
55
  .option('-s, --skills', 'Install skills only')
54
56
  .option('-g, --github', 'Install GitHub Copilot instructions')
57
+ .option('-S, --subagents', 'Install agent subagents only')
55
58
  .option('-p, --preset <name>', 'Use a preset configuration (nextjs, django-react, express-api, fastapi, go-api)')
56
59
  .option('-f, --force', 'Overwrite existing files')
57
60
  .action(async (options) => {
@@ -121,7 +124,8 @@ program
121
124
  { name: 'Documentation files (agent-docs/)', value: 'docs' },
122
125
  { name: 'Agent rules (.github/instructions/rules/*.mdc)', value: 'rules' },
123
126
  { name: 'Skills (.github/skills/*)', value: 'skills' },
124
- { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' }
127
+ { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' },
128
+ { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents' }
125
129
  ],
126
130
  default: ['all']
127
131
  },
@@ -143,6 +147,7 @@ program
143
147
  if (options.rules) choices.push('rules');
144
148
  if (options.skills) choices.push('skills');
145
149
  if (options.github) choices.push('github');
150
+ if (options.subagents) choices.push('subagents');
146
151
  }
147
152
 
148
153
  const installAll = choices.includes('all');
@@ -188,6 +193,17 @@ program
188
193
  console.log(chalk.gray(' ✓ Generic AGENTS (AGENTS.MD pointer)'));
189
194
  }
190
195
 
196
+ // Install agent subagents
197
+ if (installAll || choices.includes('subagents')) {
198
+ console.log(chalk.yellow('Installing agent subagents...'));
199
+ await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
200
+ await copyDirectory(
201
+ path.join(templateDir, 'agents', 'subagents'),
202
+ path.join(targetDir, LAYOUT.canonical.subagentsDir),
203
+ options.force
204
+ );
205
+ }
206
+
191
207
  console.log(chalk.green.bold('\nInstallation complete!\n'));
192
208
  console.log(chalk.cyan('Next steps:'));
193
209
  console.log(chalk.white(' 1. Review CLAUDE.md (canonical AI policy — edit this directly)'));
@@ -240,7 +256,8 @@ program
240
256
  { name: 'Documentation (agent-docs/)', value: 'docs' },
241
257
  { name: 'Agent Rules (security, testing, database, etc.)', value: 'rules' },
242
258
  { name: 'Skills (reusable agent capabilities)', value: 'skills' },
243
- { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' }
259
+ { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github' },
260
+ { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents' }
244
261
  ],
245
262
  validate: (answer) => {
246
263
  if (answer.length === 0) {
@@ -276,7 +293,8 @@ program
276
293
  { name: 'Documentation (agent-docs/)', value: 'docs', checked: true },
277
294
  { name: 'Agent Rules (security, testing, database, etc.)', value: 'rules', checked: true },
278
295
  { name: 'Skills (reusable agent capabilities)', value: 'skills', checked: true },
279
- { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github', checked: true }
296
+ { name: 'AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)', value: 'github', checked: true },
297
+ { name: 'Agent subagents (agents/subagents/*.md)', value: 'subagents', checked: true }
280
298
  ],
281
299
  validate: (answer) => {
282
300
  if (answer.length === 0) {
@@ -301,7 +319,8 @@ program
301
319
  docs: componentAnswers.components.includes('docs'),
302
320
  rules: componentAnswers.components.includes('rules'),
303
321
  skills: componentAnswers.components.includes('skills'),
304
- github: componentAnswers.components.includes('github')
322
+ github: componentAnswers.components.includes('github'),
323
+ subagents: componentAnswers.components.includes('subagents')
305
324
  };
306
325
 
307
326
  // Install documentation files
@@ -345,6 +364,17 @@ program
345
364
  console.log(chalk.gray(' ✓ Generic AGENTS (AGENTS.MD pointer)'));
346
365
  }
347
366
 
367
+ // Install agent subagents
368
+ if (options.subagents) {
369
+ console.log(chalk.yellow('Installing agent subagents...'));
370
+ await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
371
+ await copyDirectory(
372
+ path.join(templateDir, 'agents', 'subagents'),
373
+ path.join(targetDir, LAYOUT.canonical.subagentsDir),
374
+ options.force
375
+ );
376
+ }
377
+
348
378
  // Show summary and next steps
349
379
  console.log(chalk.green.bold('\n✅ Installation complete!\n'));
350
380
 
@@ -375,6 +405,7 @@ program
375
405
  console.log(chalk.yellow('rules') + ' - Agent rules (.github/instructions/rules/*.mdc)');
376
406
  console.log(chalk.yellow('skills') + ' - Agent skills (.github/skills/*)');
377
407
  console.log(chalk.yellow('github') + ' - AI Agent instructions (Cursor, Copilot, Claude, Generic AGENTS)');
408
+ console.log(chalk.yellow('subagents') + ' - Agent subagents (agents/subagents/*.md)');
378
409
  console.log(chalk.yellow('all') + ' - All components');
379
410
 
380
411
  console.log(chalk.blue.bold('\n\nAvailable Presets:\n'));
@@ -462,6 +493,15 @@ program
462
493
  warnings.push(`⚠ ${LAYOUT.canonical.skillsDir} directory missing - run 'agents-templated init --skills'`);
463
494
  }
464
495
 
496
+ // Check subagents
497
+ const subagentsDir = path.join(targetDir, LAYOUT.canonical.subagentsDir);
498
+ if (await fs.pathExists(subagentsDir)) {
499
+ const subagents = (await fs.readdir(subagentsDir)).filter(f => f.endsWith('.md') && f !== 'README.md');
500
+ passed.push(`✓ ${subagents.length} subagents installed in ${LAYOUT.canonical.subagentsDir}`);
501
+ } else {
502
+ warnings.push(`⚠ ${LAYOUT.canonical.subagentsDir} directory missing - run 'agents-templated init --subagents'`);
503
+ }
504
+
465
505
  // Check instruction pointer files and drift
466
506
  const instructionDrift = await validateInstructionDrift(targetDir);
467
507
  if (instructionDrift.missingCanonical) {
@@ -630,7 +670,7 @@ async function cleanupLegacyInstructionFiles(targetDir) {
630
670
 
631
671
  async function updateSelectedComponents(targetDir, templateDir, selectedComponents, overwrite = true) {
632
672
  const components = selectedComponents.includes('all')
633
- ? ['docs', 'rules', 'skills', 'github']
673
+ ? ['docs', 'rules', 'skills', 'github', 'subagents']
634
674
  : selectedComponents;
635
675
 
636
676
  if (components.includes('docs')) {
@@ -670,6 +710,16 @@ async function updateSelectedComponents(targetDir, templateDir, selectedComponen
670
710
  await cleanupLegacyInstructionFiles(targetDir);
671
711
  }
672
712
 
713
+ if (components.includes('subagents')) {
714
+ console.log(chalk.yellow('Updating agent subagents...'));
715
+ await fs.ensureDir(path.join(targetDir, LAYOUT.canonical.subagentsDir));
716
+ await copyDirectory(
717
+ path.join(templateDir, 'agents', 'subagents'),
718
+ path.join(targetDir, LAYOUT.canonical.subagentsDir),
719
+ overwrite
720
+ );
721
+ }
722
+
673
723
  if ((components.includes('docs') || components.includes('github')) && !components.includes('github')) {
674
724
  await writeGeneratedInstructions(targetDir, templateDir, overwrite);
675
725
  }
@@ -704,6 +754,7 @@ program
704
754
  .option('-r, --rules', 'Update agent rules only')
705
755
  .option('-s, --skills', 'Update skills only')
706
756
  .option('-g, --github', 'Update AI agent instruction files only')
757
+ .option('-S, --subagents', 'Update agent subagents only')
707
758
  .option('-c, --check-only', 'Only check for updates, don\'t install')
708
759
  .option('-f, --force', 'Force overwrite files during update')
709
760
  .action(async (options) => {
@@ -763,6 +814,7 @@ program
763
814
  if (options.all || options.rules) selectedComponents.push('rules');
764
815
  if (options.all || options.skills) selectedComponents.push('skills');
765
816
  if (options.all || options.github) selectedComponents.push('github');
817
+ if (options.all || options.subagents) selectedComponents.push('subagents');
766
818
 
767
819
  console.log(chalk.blue('📦 Updating selected components...\n'));
768
820
 
@@ -977,6 +1029,22 @@ program
977
1029
  }
978
1030
  });
979
1031
 
1032
+ program
1033
+ .command('new-subagent <name>')
1034
+ .description('Scaffold a new subagent in agents/subagents/<name>.md')
1035
+ .action(async (name) => {
1036
+ try {
1037
+ const targetDir = process.cwd();
1038
+ const relPath = await scaffoldSubagent(targetDir, name);
1039
+ console.log(chalk.green(`\n+ ${relPath}\n`));
1040
+ console.log(chalk.gray('Fill in Activation Conditions, Workflow, and Output Format.'));
1041
+ console.log(chalk.gray('Then add it to the Subagent modules table in CLAUDE.md.\n'));
1042
+ } catch (error) {
1043
+ console.error(chalk.red('Error:'), error.message);
1044
+ process.exit(1);
1045
+ }
1046
+ });
1047
+
980
1048
  program.parse(process.argv);
981
1049
 
982
1050
  // Show help if no command provided
@@ -157,11 +157,53 @@ async function scaffoldRule(targetDir, ruleName) {
157
157
  return `agents/rules/${ruleName}.mdc`;
158
158
  }
159
159
 
160
+ async function scaffoldSubagent(targetDir, name) {
161
+ const subagentFile = path.join(targetDir, 'agents', 'subagents', `${name}.md`);
162
+
163
+ if (await fs.pathExists(subagentFile)) {
164
+ throw new Error(`Subagent already exists: agents/subagents/${name}.md`);
165
+ }
166
+
167
+ const title = name.split('-').map(w => w[0].toUpperCase() + w.slice(1)).join(' ');
168
+ const content = [
169
+ `---`,
170
+ `name: ${name}`,
171
+ `description: TODO — describe when this subagent should activate.`,
172
+ `tools: ["Read", "Grep", "Glob"]`,
173
+ `model: claude-sonnet-4-5`,
174
+ `---`,
175
+ ``,
176
+ `# ${title}`,
177
+ ``,
178
+ `## Activation Conditions`,
179
+ ``,
180
+ `- TODO — when should this subagent activate?`,
181
+ ``,
182
+ `## Workflow`,
183
+ ``,
184
+ `1. TODO`,
185
+ ``,
186
+ `## Output Format`,
187
+ ``,
188
+ `- TODO`,
189
+ ``,
190
+ `## Guardrails`,
191
+ ``,
192
+ `- Do not override security or testing constraints.`,
193
+ ``
194
+ ].join('\n');
195
+
196
+ await fs.ensureDir(path.dirname(subagentFile));
197
+ await fs.writeFile(subagentFile, content, 'utf8');
198
+ return `agents/subagents/${name}.md`;
199
+ }
200
+
160
201
  module.exports = {
161
202
  CANONICAL_INSTRUCTION_FILE,
162
203
  POINTER_FILES,
163
204
  writeGeneratedInstructions,
164
205
  validateInstructionDrift,
165
206
  scaffoldSkill,
166
- scaffoldRule
207
+ scaffoldRule,
208
+ scaffoldSubagent
167
209
  };
package/lib/layout.js CHANGED
@@ -5,7 +5,8 @@ const LAYOUT = {
5
5
  canonical: {
6
6
  docsDir: 'agent-docs',
7
7
  rulesDir: '.github/instructions/rules',
8
- skillsDir: '.github/skills'
8
+ skillsDir: '.github/skills',
9
+ subagentsDir: 'agents/subagents'
9
10
  },
10
11
  legacy: {
11
12
  rulesDirs: ['agents/rules'],
@@ -39,10 +40,16 @@ function resolveSkillsDir(baseDir) {
39
40
  return firstExistingPath(baseDir, candidates) || LAYOUT.canonical.skillsDir;
40
41
  }
41
42
 
43
+ function resolveSubagentsDir(baseDir) {
44
+ const candidates = [LAYOUT.canonical.subagentsDir];
45
+ return firstExistingPath(baseDir, candidates) || LAYOUT.canonical.subagentsDir;
46
+ }
47
+
42
48
  async function hasAnyLayout(baseDir) {
43
49
  const checks = [
44
50
  path.join(baseDir, LAYOUT.canonical.rulesDir),
45
51
  path.join(baseDir, LAYOUT.canonical.skillsDir),
52
+ path.join(baseDir, LAYOUT.canonical.subagentsDir),
46
53
  ...LAYOUT.compatible.rulesDirs.map((relPath) => path.join(baseDir, relPath)),
47
54
  ...LAYOUT.compatible.skillsDirs.map((relPath) => path.join(baseDir, relPath)),
48
55
  ...LAYOUT.legacy.rulesDirs.map((relPath) => path.join(baseDir, relPath)),
@@ -90,6 +97,7 @@ module.exports = {
90
97
  LAYOUT,
91
98
  resolveRulesDir,
92
99
  resolveSkillsDir,
100
+ resolveSubagentsDir,
93
101
  hasAnyLayout,
94
102
  getLegacyMigrationPlan
95
103
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-templated",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Technology-agnostic development template with multi-AI agent support (Cursor, Copilot, VSCode, Gemini), security-first patterns, and comprehensive testing guidelines",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -39,6 +39,22 @@ All policy, routing, and skill governance lives here — edit this file directly
39
39
 
40
40
  Skills add capability only. They must not override security, testing, or core constraints.
41
41
 
42
+ ### Subagent modules (`agents/subagents/`)
43
+
44
+ | Subagent | Path | Invoke when... |
45
+ |----------|------|----------------|
46
+ | planner | `agents/subagents/planner.md` | Breaking down features into phased plans |
47
+ | architect | `agents/subagents/architect.md` | System design decisions, ADRs, trade-off analysis |
48
+ | tdd-guide | `agents/subagents/tdd-guide.md` | Writing tests before implementation |
49
+ | code-reviewer | `agents/subagents/code-reviewer.md` | Reviewing code for quality and correctness |
50
+ | security-reviewer | `agents/subagents/security-reviewer.md` | Scanning for security vulnerabilities |
51
+ | build-error-resolver | `agents/subagents/build-error-resolver.md` | Fixing build and type errors |
52
+ | e2e-runner | `agents/subagents/e2e-runner.md` | Running Playwright E2E test suites |
53
+ | refactor-cleaner | `agents/subagents/refactor-cleaner.md` | Removing dead code and unused dependencies |
54
+ | doc-updater | `agents/subagents/doc-updater.md` | Syncing docs and READMEs after code changes |
55
+
56
+ Subagents are bounded agents with limited tool access. They inherit all policy from this file and may not override security, testing, or core constraints.
57
+
42
58
  ---
43
59
 
44
60
  ## Always Enforce
@@ -101,16 +117,18 @@ Use `.github/instructions/rules/intent-routing.mdc` and route each task to one p
101
117
  - Feature planning → Planning
102
118
  - LLM/AI work → AI Integration
103
119
  - Scope creep / dangerous action / agent behavioral safety → Guardrails
120
+ - Multi-step orchestration / planning / code review → Subagents
104
121
 
105
122
  No ambiguous routing.
106
123
 
107
124
  ---
108
125
 
109
- ## Skills Governance
126
+ ## Skills & Subagents Governance
110
127
 
111
128
  - Skills are loaded on demand by user intent (never globally preloaded).
112
129
  - Skills augment implementation behavior, not policy.
113
- - This file remains authoritative over rule modules and skills.
130
+ - Subagents are bounded agents; each has a defined tool profile and may not expand its own scope.
131
+ - This file remains authoritative over rule modules, skills, and subagents.
114
132
 
115
133
  ---
116
134
 
@@ -0,0 +1,76 @@
1
+ # Subagents
2
+
3
+ Subagents are bounded agent processes that your orchestrator (main AI) can delegate tasks to with limited scope. Each subagent is defined as a single Markdown file with YAML frontmatter specifying its tools, model, and activation conditions.
4
+
5
+ ## What Are Subagents?
6
+
7
+ - **Limited scope** — each subagent has one primary job and restricted tool access
8
+ - **Delegatable** — the orchestrator assigns tasks and subagents execute autonomously
9
+ - **Composable** — subagents work alongside skills; a subagent can invoke skills within its scope
10
+ - **Tool profile: copilot-compat** — YAML frontmatter is read natively by Claude Code; other tools treat the file as plain instructions
11
+
12
+ ## Available Subagents
13
+
14
+ | Subagent | Model | Purpose |
15
+ |----------|-------|---------|
16
+ | `planner` | opus | Break down features into phased, ordered implementation plans |
17
+ | `architect` | opus | System design, ADRs, scalability trade-off analysis |
18
+ | `tdd-guide` | sonnet | Write tests first — Red-Green-Refactor lifecycle |
19
+ | `code-reviewer` | sonnet | Quality review with CRITICAL/HIGH/MEDIUM/LOW severity |
20
+ | `security-reviewer` | sonnet | OWASP Top 10 scan, secrets detection, auth review |
21
+ | `build-error-resolver` | sonnet | Fix build/type errors with minimal diff, no refactoring |
22
+ | `e2e-runner` | sonnet | Execute Playwright E2E test suites and report results |
23
+ | `refactor-cleaner` | sonnet | Remove dead code, unused deps, orphaned exports |
24
+ | `doc-updater` | haiku | Sync README, API docs, and codemaps after code changes |
25
+
26
+ ## Model Selection Guide
27
+
28
+ | Model | When to use |
29
+ |-------|------------|
30
+ | `claude-opus-4-5` | Complex reasoning: feature planning, architecture decisions |
31
+ | `claude-sonnet-4-5` | Balanced: code review, security scan, testing, build fixes |
32
+ | `claude-haiku-4-5` | Lightweight: documentation sync, simple transformations |
33
+
34
+ ## Invocation
35
+
36
+ ### Claude Code (native)
37
+ Subagents are invoked automatically based on `description` matching, or explicitly:
38
+ ```
39
+ /planner Build a multi-tenant authentication system
40
+ /code-reviewer Review the changes in src/auth/
41
+ ```
42
+
43
+ ### Other tools (Copilot, Cursor, Windsurf)
44
+ Reference the subagent file directly in your prompt or instruct your AI to follow the workflow defined in `agents/subagents/<name>.md`.
45
+
46
+ ## File Structure
47
+
48
+ ```
49
+ agents/subagents/
50
+ ├── README.md ← This file
51
+ ├── planner.md
52
+ ├── architect.md
53
+ ├── tdd-guide.md
54
+ ├── code-reviewer.md
55
+ ├── security-reviewer.md
56
+ ├── build-error-resolver.md
57
+ ├── e2e-runner.md
58
+ ├── refactor-cleaner.md
59
+ └── doc-updater.md
60
+ ```
61
+
62
+ ## Adding a New Subagent
63
+
64
+ ```bash
65
+ agents-templated new-subagent <name>
66
+ ```
67
+
68
+ Then add it to the Reference Index in `CLAUDE.md`.
69
+
70
+ ## Guardrails
71
+
72
+ All subagents inherit the constraints from `CLAUDE.md`:
73
+ - Security and testing rules are non-overrideable
74
+ - Destructive actions require `CONFIRM-DESTRUCTIVE:<target>`
75
+ - Subagents must stop and report on failure, never silently retry
76
+ - No subagent may expose secrets, credentials, or PII
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: architect
3
+ description: Use when making significant system design decisions, evaluating architectural trade-offs, or producing Architecture Decision Records (ADRs) for a new or evolving system.
4
+ tools: ["Read", "Grep", "Glob"]
5
+ model: claude-opus-4-5
6
+ ---
7
+
8
+ # Architect
9
+
10
+ You are a system design agent. Your job is to reason deeply about architectural decisions, evaluate trade-offs, and produce durable Architecture Decision Records (ADRs) — not to write implementation code.
11
+
12
+ ## Activation Conditions
13
+
14
+ Invoke this subagent when:
15
+ - Designing a new system, service, or major module from scratch
16
+ - Evaluating whether to refactor, replace, or extend existing architecture
17
+ - Choosing between architectural patterns (monolith vs microservices, REST vs GraphQL, etc.)
18
+ - Producing a formal ADR for a significant decision
19
+ - Planning for scalability (10K → 100K → 1M users)
20
+
21
+ ## Workflow
22
+
23
+ ### 1. Understand context
24
+ - Read existing architecture docs, README, and key source files
25
+ - Identify: current stack, team constraints, performance requirements, security posture
26
+ - Clarify the decision trigger: what problem is this architecture solving?
27
+
28
+ ### 2. Identify architectural options
29
+ - Enumerate 2-4 realistic alternatives (including "keep current" where applicable)
30
+ - For each option: describe the approach in 2-3 sentences
31
+
32
+ ### 3. Trade-off analysis
33
+ For each option, evaluate:
34
+ - **Pros**: concrete advantages
35
+ - **Cons**: concrete disadvantages, risks
36
+ - **Cost**: implementation effort, operational overhead
37
+ - **Fit**: how well it matches current constraints
38
+
39
+ ### 4. Scalability projection
40
+ - Describe behavior at current scale, 10× scale, 100× scale
41
+ - Identify the likely bottleneck at each level
42
+ - Recommend the inflection point where architecture should change
43
+
44
+ ### 5. Decision and ADR
45
+ - State the recommended option and primary rationale
46
+ - Produce a formal ADR in the standard format
47
+
48
+ ### 6. Implementation guidance
49
+ - List the highest-priority first steps to realize the architecture
50
+ - Flag dependencies and sequencing constraints
51
+
52
+ ## Output Format
53
+
54
+ ```
55
+ ## Context
56
+ {What problem is being solved and why now}
57
+
58
+ ## Options Considered
59
+
60
+ ### Option A: {name}
61
+ {2-3 sentence description}
62
+ - Pros: ...
63
+ - Cons: ...
64
+ - Estimated effort: {Low/Med/High}
65
+
66
+ ### Option B: {name}
67
+ ...
68
+
69
+ ## Trade-off Matrix
70
+ | Criterion | Option A | Option B | Option C |
71
+ |-----------|---------|---------|---------|
72
+ | Scalability | ... | ... | ... |
73
+ | Complexity | ... | ... | ... |
74
+ | Security | ... | ... | ... |
75
+ | Ops burden | ... | ... | ... |
76
+
77
+ ## Scalability Projection
78
+ - Current scale (~{N} users/req): {behavior}
79
+ - 10× scale: {behavior, bottleneck}
80
+ - 100× scale: {behavior, bottleneck, recommended change}
81
+
82
+ ## Architecture Decision Record (ADR)
83
+
84
+ **Title**: {short imperative title}
85
+ **Status**: Proposed
86
+ **Date**: {today}
87
+
88
+ **Decision**: {one paragraph — what was decided and why}
89
+
90
+ **Consequences**:
91
+ - Positive: ...
92
+ - Negative: ...
93
+ - Neutral: ...
94
+
95
+ ## First Steps
96
+ 1. ...
97
+ 2. ...
98
+ ```
99
+
100
+ ## Guardrails
101
+
102
+ - Do not write implementation code — produce architecture artifacts only
103
+ - Every decision that affects auth, data storage, or external APIs must include a security consideration
104
+ - Call out single points of failure explicitly
105
+ - Do not recommend an option without stating its primary downside
106
+ - If the existing architecture is already appropriate, say so clearly — do not engineer for the sake of it
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: build-error-resolver
3
+ description: Use when the build, type-checker, or linter is failing. Fixes errors with minimal diffs — no refactoring or architectural changes.
4
+ tools: ["Read", "Grep", "Glob", "Bash", "Edit"]
5
+ model: claude-sonnet-4-5
6
+ ---
7
+
8
+ # Build Error Resolver
9
+
10
+ You are a build repair agent. Your job is to make a failing build pass with the smallest possible, safest diff — not to improve the code, refactor it, or change its architecture.
11
+
12
+ ## Activation Conditions
13
+
14
+ Invoke this subagent when:
15
+ - TypeScript / compiler errors are blocking the build
16
+ - Linter errors are failing CI
17
+ - Import resolution errors after a refactor or dependency change
18
+ - Missing types or incorrect generics introduced by a code change
19
+ - Tests fail due to mock/setup issues (not logic failures)
20
+
21
+ ## Philosophy
22
+
23
+ **Minimum diff. Maximum speed. Zero scope creep.**
24
+
25
+ - Fix only what is broken — do not "improve" surrounding code
26
+ - Do not refactor, rename, or reorganize while fixing errors
27
+ - Do not change logic — only fix types, imports, and syntax
28
+ - If fixing correctly requires architecture changes, stop and report instead
29
+
30
+ ## Workflow
31
+
32
+ ### 1. Capture the error
33
+ Run the build/type-check to get the full error output:
34
+ ```bash
35
+ npx tsc --noEmit # TypeScript
36
+ npm run build # Project build
37
+ npm run lint # Linter
38
+ npx tsc --noEmit 2>&1 | head -50 # First 50 type errors
39
+ ```
40
+
41
+ ### 2. Triage errors
42
+ Group errors by category:
43
+ - **Type mismatch** — wrong type passed or returned
44
+ - **Missing property** — object missing required field
45
+ - **Import error** — missing module, wrong path, missing export
46
+ - **Null/undefined** — value may be undefined but type says it isn't
47
+ - **Generic mismatch** — type parameter inferred incorrectly
48
+ - **Missing dependency** — package not installed
49
+
50
+ ### 3. Fix in priority order
51
+
52
+ **Import errors first** — fixing a missing import can resolve dozens of downstream errors
53
+ **Type annotation gaps second** — explicit types often resolve inference chain failures
54
+ **Null safety third** — add null checks or optional chaining where safe
55
+ **Everything else** — address remaining errors one file at a time
56
+
57
+ ### 4. Common fixes
58
+
59
+ ```typescript
60
+ // Missing type annotation
61
+ function process(data) { ... }
62
+ // → add explicit parameter type
63
+ function process(data: ProcessInput) { ... }
64
+
65
+ // Null/undefined error
66
+ user.profile.name // may be undefined
67
+ // → optional chaining
68
+ user.profile?.name
69
+
70
+ // Wrong generic
71
+ const result = await fetch<Response>(url)
72
+ // → correct generic
73
+ const result = await fetch(url)
74
+ const data = await result.json() as Response
75
+
76
+ // Missing dependency
77
+ // → npm install <package>
78
+ // → npm install --save-dev @types/<package>
79
+ ```
80
+
81
+ ### 5. Verify
82
+ Run the build again after each batch of fixes to confirm errors are resolved:
83
+ ```bash
84
+ npx tsc --noEmit 2>&1 | grep -c "error TS"
85
+ ```
86
+
87
+ ## Output Format
88
+
89
+ ```
90
+ ## Build Error Resolution
91
+
92
+ ### Error Summary
93
+ Total errors: {N}
94
+ Categories: {TypeMismatch: N, Import: N, NullSafety: N, ...}
95
+
96
+ ### Fixes Applied
97
+
98
+ **File: {path}**
99
+ Error: {TS2345: ...}
100
+ Fix: {description}
101
+ Diff:
102
+ - old line
103
+ + new line
104
+
105
+ ---
106
+
107
+ ### Verification
108
+ Build status after fixes: {PASSING | FAILING}
109
+ Remaining errors: {N or "None"}
110
+ ```
111
+
112
+ ## Guardrails
113
+
114
+ - Do not change function signatures in ways that break callers outside your fix scope
115
+ - Do not use `any` as a fix — find the correct type or use `unknown` with a guard
116
+ - Do not use `// @ts-ignore` or `// eslint-disable` as a fix — resolve the underlying issue
117
+ - Do not refactor, rename variables, or reorganize code while fixing errors
118
+ - If an error requires an architectural decision (e.g., changing a shared interface), stop and report — do not decide unilaterally
119
+ - If fixing one error causes three new errors, stop and report the situation