hatch3r 1.0.0 → 1.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/README.md +93 -322
- package/agents/hatch3r-a11y-auditor.md +24 -6
- package/agents/hatch3r-architect.md +20 -1
- package/agents/hatch3r-ci-watcher.md +31 -8
- package/agents/hatch3r-context-rules.md +14 -2
- package/agents/hatch3r-dependency-auditor.md +21 -5
- package/agents/hatch3r-devops.md +37 -6
- package/agents/hatch3r-docs-writer.md +19 -3
- package/agents/hatch3r-fixer.md +171 -0
- package/agents/hatch3r-implementer.md +84 -11
- package/agents/hatch3r-learnings-loader.md +69 -13
- package/agents/hatch3r-lint-fixer.md +19 -14
- package/agents/hatch3r-perf-profiler.md +18 -1
- package/agents/hatch3r-researcher.md +440 -5
- package/agents/hatch3r-reviewer.md +97 -5
- package/agents/hatch3r-security-auditor.md +23 -5
- package/agents/hatch3r-test-writer.md +21 -10
- package/checks/README.md +49 -0
- package/checks/code-quality.md +49 -0
- package/checks/performance.md +58 -0
- package/checks/security.md +58 -0
- package/checks/testing.md +53 -0
- package/commands/board/pickup-azure-devops.md +81 -0
- package/commands/board/pickup-delegation-multi.md +197 -0
- package/commands/board/pickup-delegation.md +100 -0
- package/commands/board/pickup-github.md +82 -0
- package/commands/board/pickup-gitlab.md +81 -0
- package/commands/board/pickup-modes.md +143 -0
- package/commands/board/pickup-post-impl.md +120 -0
- package/commands/board/shared-azure-devops.md +149 -0
- package/commands/board/shared-board-overview.md +215 -0
- package/commands/board/shared-github.md +169 -0
- package/commands/board/shared-gitlab.md +142 -0
- package/commands/hatch3r-agent-customize.md +40 -2
- package/commands/hatch3r-api-spec.md +294 -32
- package/commands/hatch3r-benchmark.md +386 -32
- package/commands/hatch3r-board-fill.md +161 -25
- package/commands/hatch3r-board-groom.md +595 -0
- package/commands/hatch3r-board-init.md +203 -46
- package/commands/hatch3r-board-pickup.md +79 -457
- package/commands/hatch3r-board-refresh.md +98 -27
- package/commands/hatch3r-board-shared.md +87 -238
- package/commands/hatch3r-bug-plan.md +16 -3
- package/commands/hatch3r-codebase-map.md +43 -10
- package/commands/hatch3r-command-customize.md +6 -0
- package/commands/hatch3r-context-health.md +5 -0
- package/commands/hatch3r-cost-tracking.md +5 -0
- package/commands/hatch3r-debug.md +426 -0
- package/commands/hatch3r-dep-audit.md +7 -1
- package/commands/hatch3r-feature-plan.md +74 -12
- package/commands/hatch3r-healthcheck.md +17 -1
- package/commands/hatch3r-hooks.md +16 -10
- package/commands/hatch3r-learn.md +15 -9
- package/commands/hatch3r-migration-plan.md +333 -33
- package/commands/hatch3r-onboard.md +327 -38
- package/commands/hatch3r-project-spec.md +46 -10
- package/commands/hatch3r-quick-change.md +336 -0
- package/commands/hatch3r-recipe.md +6 -0
- package/commands/hatch3r-refactor-plan.md +29 -13
- package/commands/hatch3r-release.md +13 -3
- package/commands/hatch3r-revision.md +395 -0
- package/commands/hatch3r-roadmap.md +18 -3
- package/commands/hatch3r-rule-customize.md +6 -0
- package/commands/hatch3r-security-audit.md +17 -1
- package/commands/hatch3r-skill-customize.md +6 -0
- package/commands/hatch3r-test-plan.md +532 -0
- package/commands/hatch3r-workflow.md +113 -38
- package/dist/cli/index.js +5184 -2593
- package/dist/cli/index.js.map +1 -0
- package/github-agents/hatch3r-docs-agent.md +1 -0
- package/github-agents/hatch3r-lint-agent.md +1 -0
- package/github-agents/hatch3r-security-agent.md +1 -0
- package/github-agents/hatch3r-test-agent.md +1 -0
- package/hooks/hatch3r-ci-failure.md +30 -0
- package/hooks/hatch3r-file-save.md +22 -0
- package/hooks/hatch3r-post-merge.md +23 -0
- package/hooks/hatch3r-pre-commit.md +23 -0
- package/hooks/hatch3r-pre-push.md +22 -0
- package/hooks/hatch3r-session-start.md +22 -0
- package/mcp/mcp.json +22 -3
- package/package.json +4 -7
- package/prompts/hatch3r-bug-triage.md +1 -0
- package/prompts/hatch3r-code-review.md +1 -0
- package/prompts/hatch3r-pr-description.md +1 -0
- package/rules/hatch3r-accessibility-standards.md +1 -0
- package/rules/hatch3r-agent-orchestration.md +326 -53
- package/rules/hatch3r-agent-orchestration.mdc +225 -0
- package/rules/hatch3r-api-design.md +4 -1
- package/rules/hatch3r-browser-verification.md +33 -1
- package/rules/hatch3r-browser-verification.mdc +29 -0
- package/rules/hatch3r-ci-cd.md +5 -1
- package/rules/hatch3r-ci-cd.mdc +4 -1
- package/rules/hatch3r-code-standards.md +18 -0
- package/rules/hatch3r-code-standards.mdc +10 -1
- package/rules/hatch3r-component-conventions.md +4 -1
- package/rules/hatch3r-data-classification.md +1 -0
- package/rules/hatch3r-deep-context.md +94 -0
- package/rules/hatch3r-deep-context.mdc +69 -0
- package/rules/hatch3r-dependency-management.md +13 -0
- package/rules/hatch3r-feature-flags.md +4 -1
- package/rules/hatch3r-git-conventions.md +1 -0
- package/rules/hatch3r-i18n.md +4 -1
- package/rules/hatch3r-learning-consult.md +4 -2
- package/rules/hatch3r-learning-consult.mdc +3 -2
- package/rules/hatch3r-migrations.md +12 -0
- package/rules/hatch3r-observability.md +293 -1
- package/rules/hatch3r-performance-budgets.md +5 -2
- package/rules/hatch3r-performance-budgets.mdc +1 -1
- package/rules/hatch3r-secrets-management.md +11 -3
- package/rules/hatch3r-secrets-management.mdc +10 -3
- package/rules/hatch3r-security-patterns.md +23 -3
- package/rules/hatch3r-security-patterns.mdc +8 -2
- package/rules/hatch3r-testing.md +1 -0
- package/rules/hatch3r-theming.md +4 -1
- package/rules/hatch3r-tooling-hierarchy.md +42 -15
- package/rules/hatch3r-tooling-hierarchy.mdc +27 -4
- package/skills/hatch3r-a11y-audit/SKILL.md +1 -0
- package/skills/hatch3r-agent-customize/SKILL.md +3 -0
- package/skills/hatch3r-api-spec/SKILL.md +1 -0
- package/skills/hatch3r-architecture-review/SKILL.md +6 -2
- package/skills/hatch3r-bug-fix/SKILL.md +4 -1
- package/skills/hatch3r-ci-pipeline/SKILL.md +1 -0
- package/skills/hatch3r-command-customize/SKILL.md +1 -0
- package/skills/hatch3r-context-health/SKILL.md +2 -1
- package/skills/hatch3r-cost-tracking/SKILL.md +1 -0
- package/skills/hatch3r-dep-audit/SKILL.md +6 -2
- package/skills/hatch3r-feature/SKILL.md +9 -2
- package/skills/hatch3r-gh-agentic-workflows/SKILL.md +130 -21
- package/skills/hatch3r-incident-response/SKILL.md +11 -5
- package/skills/hatch3r-issue-workflow/SKILL.md +12 -7
- package/skills/hatch3r-logical-refactor/SKILL.md +1 -0
- package/skills/hatch3r-migration/SKILL.md +1 -0
- package/skills/hatch3r-perf-audit/SKILL.md +2 -1
- package/skills/hatch3r-pr-creation/SKILL.md +20 -10
- package/skills/hatch3r-qa-validation/SKILL.md +2 -1
- package/skills/hatch3r-recipe/SKILL.md +1 -0
- package/skills/hatch3r-refactor/SKILL.md +7 -1
- package/skills/hatch3r-release/SKILL.md +15 -11
- package/skills/hatch3r-rule-customize/SKILL.md +1 -0
- package/skills/hatch3r-skill-customize/SKILL.md +1 -0
- package/skills/hatch3r-visual-refactor/SKILL.md +1 -0
- package/dist/cli/hooks-ZOTFDEA3.js +0 -59
- package/rules/hatch3r-error-handling.md +0 -17
- package/rules/hatch3r-error-handling.mdc +0 -15
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Mandatory agent delegation, skill loading, and subagent usage directives for ALL tasks in ALL contexts
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
# Agent Orchestration
|
|
6
|
+
|
|
7
|
+
This rule governs when and how to delegate work to hatch3r agents, load skills, and spawn subagents. These directives are mandatory — not suggestions.
|
|
8
|
+
|
|
9
|
+
## Universal Applicability
|
|
10
|
+
|
|
11
|
+
This rule applies to EVERY context without exception:
|
|
12
|
+
|
|
13
|
+
- **Board-pickup** (epic, sub-issue, standalone, batch)
|
|
14
|
+
- **Workflow command** (full mode and quick mode)
|
|
15
|
+
- **Plain chat** (single task or multiple tasks)
|
|
16
|
+
- **Issue references** (e.g., "implement #5")
|
|
17
|
+
- **Natural language requests** (e.g., "add a dark mode toggle")
|
|
18
|
+
|
|
19
|
+
Whether the user invokes a command or simply asks for a task in conversation, the full sub-agent pipeline defined below is mandatory. There is no context where implementing code inline (without sub-agents) is acceptable.
|
|
20
|
+
|
|
21
|
+
## Universal Sub-Agent Pipeline
|
|
22
|
+
|
|
23
|
+
Every task MUST follow this four-phase pipeline:
|
|
24
|
+
|
|
25
|
+
**Phase 1 — Research:** Spawn `hatch3r-researcher` for context gathering. Skip only for trivial single-line edits (typos, comment fixes, single-value config changes). All other tasks require researcher context. **Before spawning researchers, score the task's complexity per the `hatch3r-deep-context` rule** and add the tier-appropriate researcher modes alongside the standard task-type modes (see Deep Context Integration below).
|
|
26
|
+
|
|
27
|
+
**Phase 2 — Implement:** Spawn `hatch3r-implementer` for ALL code changes. One dedicated implementer per task. Never implement inline — always delegate via the Task tool. **Include reference conventions, resolved requirements, and blast radius data** from Phase 1 in the implementer prompt when available (see Deep Context Integration below).
|
|
28
|
+
|
|
29
|
+
**Phase 3 — Review Loop:**
|
|
30
|
+
|
|
31
|
+
- 3a. Spawn `hatch3r-reviewer` to review the implementation.
|
|
32
|
+
- 3b. If Critical or Warning findings exist: spawn `hatch3r-fixer` with the reviewer output. When fixes touch shared or public interfaces, also include blast radius data and reference conventions from Phase 1 (if available).
|
|
33
|
+
- 3c. Re-review: spawn `hatch3r-reviewer` on the fixed code.
|
|
34
|
+
- 3d. Repeat 3b–3c until the reviewer reports 0 Critical + 0 Warning, or max 3 iterations reached.
|
|
35
|
+
- 3e. If max iterations reached with remaining findings: surface to user for manual resolution.
|
|
36
|
+
|
|
37
|
+
**Phase 4 — Final Quality** (runs ONLY after the review loop is clean):
|
|
38
|
+
|
|
39
|
+
Spawn all applicable specialists in parallel:
|
|
40
|
+
|
|
41
|
+
| Specialist | When | Mandatory? |
|
|
42
|
+
|-----------|------|------------|
|
|
43
|
+
| `hatch3r-test-writer` | After every code change | YES — always for code changes |
|
|
44
|
+
| `hatch3r-security-auditor` | After every code change | YES — always for code changes |
|
|
45
|
+
| `hatch3r-docs-writer` | After every implementation | EVALUATE — spawn when changes affect APIs, architecture, user-facing behavior, or when specs/ADRs need updating |
|
|
46
|
+
| `hatch3r-lint-fixer` | When lint errors present | Conditional |
|
|
47
|
+
| `hatch3r-a11y-auditor` | When UI/accessibility changes | Conditional |
|
|
48
|
+
| `hatch3r-perf-profiler` | When performance-sensitive changes | Conditional |
|
|
49
|
+
| `hatch3r-dependency-auditor` | When dependencies change | Conditional |
|
|
50
|
+
| `hatch3r-ci-watcher` | When CI fails | Conditional |
|
|
51
|
+
| `hatch3r-architect` | When architectural decisions are needed or system design review is requested | Conditional |
|
|
52
|
+
| `hatch3r-devops` | When CI/CD, deployment, or infrastructure tasks are involved | Conditional |
|
|
53
|
+
|
|
54
|
+
## Agent Roster
|
|
55
|
+
|
|
56
|
+
| Agent | Purpose | Invoke When |
|
|
57
|
+
|-------|---------|-------------|
|
|
58
|
+
| `hatch3r-researcher` | Context gathering across 15 research modes | ALWAYS before implementation. Skip only for trivial single-line edits. Select modes by task type + tier-appropriate deep context modes. |
|
|
59
|
+
| `hatch3r-implementer` | Focused single-task implementation | ALWAYS. One dedicated implementer per task — standalone issues, epic sub-issues, batched issues, and plain chat tasks all get dedicated implementers. |
|
|
60
|
+
| `hatch3r-reviewer` | Code review for quality, security, performance | ALWAYS in review loop (Phase 3). Reviews implementation, then re-reviews after fixes. |
|
|
61
|
+
| `hatch3r-fixer` | Targeted fixes for reviewer findings | When `hatch3r-reviewer` reports Critical or Warning findings during the review loop (Phase 3). |
|
|
62
|
+
| `hatch3r-test-writer` | Regression and coverage tests | ALWAYS for code changes in final quality (Phase 4). Not just bugs — every code change gets tests. |
|
|
63
|
+
| `hatch3r-security-auditor` | Security rules, data flows, access control | ALWAYS for code changes in final quality (Phase 4). Not just `area:security` — every code change gets a security review. |
|
|
64
|
+
| `hatch3r-docs-writer` | Specs, ADRs, documentation maintenance | ALWAYS evaluate in final quality (Phase 4). Spawn when changes affect APIs, architecture, or user-facing behavior. |
|
|
65
|
+
| `hatch3r-lint-fixer` | Style, formatting, type error cleanup | After implementation when lint errors are present. |
|
|
66
|
+
| `hatch3r-a11y-auditor` | WCAG AA compliance checks | When UI/accessibility changes are made. |
|
|
67
|
+
| `hatch3r-perf-profiler` | Performance profiling and optimization | When performance-sensitive changes are made. |
|
|
68
|
+
| `hatch3r-dependency-auditor` | Supply chain security, CVE scanning | When dependencies change or new packages are added. |
|
|
69
|
+
| `hatch3r-ci-watcher` | CI/CD failure diagnosis and fix suggestions | When CI fails during or after implementation. |
|
|
70
|
+
| `hatch3r-architect` | Architecture design, system design review, technical decision documentation | When architectural decisions are needed or system design review is requested. |
|
|
71
|
+
| `hatch3r-devops` | CI/CD pipeline operations, deployment configuration, infrastructure setup | When CI/CD, deployment, or infrastructure tasks are involved. |
|
|
72
|
+
|
|
73
|
+
## Deep Context Integration
|
|
74
|
+
|
|
75
|
+
Before spawning researchers in Phase 1, score the task's complexity using the `hatch3r-deep-context` rule criteria. The resulting tier determines which additional researcher modes to include alongside the standard task-type modes.
|
|
76
|
+
|
|
77
|
+
### Tier-Adjusted Research Modes
|
|
78
|
+
|
|
79
|
+
**Tier 1 (Light — score 0–2):** Use only the standard task-type modes below. No additional modes.
|
|
80
|
+
|
|
81
|
+
**Tier 2 (Standard — score 3–5):** Add these modes at `quick` depth alongside the task-type modes:
|
|
82
|
+
- `requirements-elicitation` — scan for top ambiguities, ask 3–5 clarifying questions
|
|
83
|
+
- `similar-implementation` — find 1 reference implementation, extract top-level patterns
|
|
84
|
+
|
|
85
|
+
Present the elicitation questions to the user inline. Await answers before proceeding to Phase 2.
|
|
86
|
+
|
|
87
|
+
**Tier 3 (Deep — score 6+):** Add these modes at `deep` depth alongside the task-type modes:
|
|
88
|
+
- `requirements-elicitation` — full 10-dimension ambiguity scan, dependency questions, cross-cutting concern checklist
|
|
89
|
+
- `similar-implementation` — find 2–3 references, full convention extraction, divergence analysis
|
|
90
|
+
- `codebase-impact` at `deep` depth (with transitive tracing, API consumer map, blast radius)
|
|
91
|
+
|
|
92
|
+
**Mandatory Tier 3 checkpoint:** Present a consolidated Pre-Implementation Summary to the user and ASK for confirmation. Do NOT proceed to Phase 2 until all unresolved questions are answered.
|
|
93
|
+
|
|
94
|
+
### Implementer Prompt Enrichment
|
|
95
|
+
|
|
96
|
+
When spawning `hatch3r-implementer` in Phase 2, include the following from Phase 1 results when available:
|
|
97
|
+
- **Reference Conventions**: `similar-implementation` output — the implementer uses this in its Convention Lock step (Step 1b)
|
|
98
|
+
- **Resolved Requirements**: User's answers to `requirements-elicitation` questions — explicit decisions the implementer should follow instead of guessing
|
|
99
|
+
- **Blast Radius**: Enhanced `codebase-impact` output with transitive traces and API consumer maps — informs which consumers and contracts must be preserved
|
|
100
|
+
|
|
101
|
+
## Mandatory Delegation Directives
|
|
102
|
+
|
|
103
|
+
### Context Gathering (Before Implementation)
|
|
104
|
+
|
|
105
|
+
You MUST spawn a `hatch3r-researcher` subagent before implementing any task. Skip only for trivial single-line edits (typos, comment fixes, single-value config changes). Select research modes by task type, then add tier-appropriate modes per the Deep Context Integration section above:
|
|
106
|
+
|
|
107
|
+
- **`type:bug`**: modes `symptom-trace`, `root-cause`, `codebase-impact` + tier modes
|
|
108
|
+
- **`type:feature`**: modes `codebase-impact`, `feature-design`, `architecture` + tier modes
|
|
109
|
+
- **`type:refactor`**: modes `current-state`, `refactoring-strategy`, `migration-path` + tier modes
|
|
110
|
+
- **`type:qa`**: modes `codebase-impact` + tier modes
|
|
111
|
+
|
|
112
|
+
Use depth `quick` for low-risk tasks, `standard` for medium-risk, `deep` for high-risk. The `hatch3r-deep-context` tier may override depth upward (e.g., a Tier 3 task always uses `deep` depth for the additional modes, even if the task-type modes use `standard`).
|
|
113
|
+
|
|
114
|
+
### Implementation Delegation
|
|
115
|
+
|
|
116
|
+
You MUST spawn a `hatch3r-implementer` subagent via the Task tool for ALL code changes. Never implement inline.
|
|
117
|
+
|
|
118
|
+
- **Single standalone issue**: Spawn one `hatch3r-implementer`. The orchestrator coordinates git, PR, and board operations.
|
|
119
|
+
- **Plain chat single task**: Spawn one `hatch3r-implementer`. Create synthetic issue context first (title, acceptance criteria, type).
|
|
120
|
+
- **Epics with sub-issues**: Spawn one `hatch3r-implementer` per sub-issue. Execute level-by-level respecting dependency order.
|
|
121
|
+
- **Multiple standalone issues (batch)**: Treat as a batch. Group by dependency level, spawn one `hatch3r-implementer` per issue, execute level-by-level. Shared branch, combined PR.
|
|
122
|
+
|
|
123
|
+
**Implementer prompt enrichment:** For Tier 2 and Tier 3 tasks, include the deep context outputs in the implementer prompt:
|
|
124
|
+
- `similar-implementation` findings as "Reference Conventions" (triggers the implementer's Convention Lock step)
|
|
125
|
+
- Resolved `requirements-elicitation` answers as "Resolved Requirements"
|
|
126
|
+
- Enhanced `codebase-impact` blast radius data (Tier 3 only)
|
|
127
|
+
|
|
128
|
+
### Post-Implementation Quality Pipeline
|
|
129
|
+
|
|
130
|
+
You MUST run the review loop and final quality phases after implementation completes.
|
|
131
|
+
|
|
132
|
+
**Phase 3 — Review Loop:**
|
|
133
|
+
|
|
134
|
+
1. Spawn `hatch3r-reviewer` — code review. Include the diff and acceptance criteria in the prompt.
|
|
135
|
+
2. If the reviewer reports Critical or Warning findings: spawn `hatch3r-fixer` with the full reviewer output (findings, file paths, line references, suggested fixes).
|
|
136
|
+
3. After fixes: spawn `hatch3r-reviewer` again to re-review the fixed code.
|
|
137
|
+
4. Repeat steps 2–3 until the reviewer reports 0 Critical + 0 Warning, or max 3 iterations reached.
|
|
138
|
+
5. If max iterations reached with remaining findings: surface to user for manual resolution. Do not proceed to Phase 4 until the user acknowledges.
|
|
139
|
+
|
|
140
|
+
**Phase 4 — Final Quality** (runs ONLY after the review loop is clean):
|
|
141
|
+
|
|
142
|
+
Launch as many independent subagents in parallel as the platform supports — no artificial concurrency limit.
|
|
143
|
+
|
|
144
|
+
**Always spawn (mandatory for every code change):**
|
|
145
|
+
|
|
146
|
+
1. `hatch3r-test-writer` — tests for all code changes. Unit tests for new logic, regression tests for bug fixes, integration tests for cross-module changes.
|
|
147
|
+
2. `hatch3r-security-auditor` — security review of all code changes. Audit data flows, access control, input validation, and secret management.
|
|
148
|
+
|
|
149
|
+
**Always evaluate (spawn when applicable):**
|
|
150
|
+
|
|
151
|
+
3. `hatch3r-docs-writer` — spawn when changes affect public APIs, architectural patterns, user-facing behavior, or when specs/ADRs need updating. If no documentation impact exists, skip silently.
|
|
152
|
+
|
|
153
|
+
**Conditional specialists (spawn when triggered):**
|
|
154
|
+
|
|
155
|
+
4. `hatch3r-lint-fixer` — when lint or type errors are present after implementation.
|
|
156
|
+
5. `hatch3r-a11y-auditor` — when UI or accessibility changes are made.
|
|
157
|
+
6. `hatch3r-perf-profiler` — when performance-sensitive changes are made.
|
|
158
|
+
7. `hatch3r-dependency-auditor` — when dependencies change or new packages are added.
|
|
159
|
+
8. `hatch3r-architect` — when architectural decisions are needed or system design review is requested.
|
|
160
|
+
9. `hatch3r-devops` — when CI/CD, deployment, or infrastructure tasks are involved.
|
|
161
|
+
|
|
162
|
+
## Skill Loading Directives
|
|
163
|
+
|
|
164
|
+
Before implementing any task, you MUST read and follow the matching hatch3r skill:
|
|
165
|
+
|
|
166
|
+
| Task Type | Skill |
|
|
167
|
+
|-----------|-------|
|
|
168
|
+
| `type:bug` | `hatch3r-bug-fix` |
|
|
169
|
+
| `type:feature` | `hatch3r-feature` (aka `hatch3r-feature-implementation`) |
|
|
170
|
+
| `type:refactor` + `area:ui` | `hatch3r-visual-refactor` |
|
|
171
|
+
| `type:refactor` + behavior change | `hatch3r-logical-refactor` |
|
|
172
|
+
| `type:refactor` (other) | `hatch3r-refactor` (aka `hatch3r-code-refactor`) |
|
|
173
|
+
| `type:qa` | `hatch3r-qa-validation` |
|
|
174
|
+
|
|
175
|
+
When a skill references agents under "Required Agent Delegation", those delegations are mandatory — you MUST spawn the listed agents via the Task tool.
|
|
176
|
+
|
|
177
|
+
## Subagent Spawning Protocol
|
|
178
|
+
|
|
179
|
+
When spawning any subagent via the Task tool:
|
|
180
|
+
|
|
181
|
+
1. **Use `subagent_type: "generalPurpose"`** for all hatch3r agent delegations.
|
|
182
|
+
2. **Include in every subagent prompt**:
|
|
183
|
+
- The agent protocol to follow (e.g., "Follow the hatch3r-implementer agent protocol").
|
|
184
|
+
- All `scope: always` rules from `.agents/rules/` that apply.
|
|
185
|
+
- The project's tooling hierarchy (Context7 MCP for library docs, web research for current context).
|
|
186
|
+
- Relevant learnings from `.agents/learnings/` if the directory exists.
|
|
187
|
+
3. **Launch as many independent subagents in parallel as the platform supports.** Do not impose an artificial concurrency limit. Use maximum parallelism for independent work.
|
|
188
|
+
4. **Await and review results** before proceeding. If a subagent reports BLOCKED or PARTIAL, surface to the user.
|
|
189
|
+
|
|
190
|
+
## Single-Task Plain Chat Protocol
|
|
191
|
+
|
|
192
|
+
When the user provides a single task in plain chat (no command invoked, no issue reference), the full sub-agent pipeline still applies:
|
|
193
|
+
|
|
194
|
+
1. **Classify** the task by type (bug/feature/refactor/QA/other) based on context.
|
|
195
|
+
2. **Create synthetic issue context** — title, acceptance criteria, and type — from the user's instruction.
|
|
196
|
+
3. **Run the Universal Sub-Agent Pipeline**: Phase 1 (Research) → Phase 2 (Implement) → Phase 3 (Review Loop) → Phase 4 (Final Quality).
|
|
197
|
+
4. For issue references in chat (e.g., "fix #5"), fetch issue details using the platform CLI (check `platform` in `.agents/hatch.json`) and use them as the task context instead of creating synthetic context:
|
|
198
|
+
- **GitHub:** `gh issue view`
|
|
199
|
+
- **Azure DevOps:** `az boards work-item show --id`
|
|
200
|
+
- **GitLab:** `glab issue view`
|
|
201
|
+
|
|
202
|
+
This ensures consistent quality regardless of how the task was initiated.
|
|
203
|
+
|
|
204
|
+
## Multi-Task Detection (Plain Chat)
|
|
205
|
+
|
|
206
|
+
When the user provides multiple tasks in a single message — numbered lists, comma-separated instructions, multiple issue references (e.g., "implement #1, #3, #7"), or multiple distinct requests — you MUST parallelize them:
|
|
207
|
+
|
|
208
|
+
1. **Parse** the message into individual discrete tasks. Each distinct implementation request is one task.
|
|
209
|
+
2. **Classify** each task by type (bug/feature/refactor/QA/other) based on context or explicit labels.
|
|
210
|
+
3. **Build a dependency graph** among the tasks. Independent tasks share the same level and run in parallel.
|
|
211
|
+
4. **Spawn one `hatch3r-researcher` subagent per task** (skip for trivial single-line edits only). Launch in parallel.
|
|
212
|
+
5. **Spawn one `hatch3r-implementer` subagent per task** per dependency level.
|
|
213
|
+
6. **For issue references**: fetch issue details using the platform CLI (check `platform` in `.agents/hatch.json`):
|
|
214
|
+
- **GitHub:** `gh issue view`
|
|
215
|
+
- **Azure DevOps:** `az boards work-item show --id`
|
|
216
|
+
- **GitLab:** `glab issue view`
|
|
217
|
+
7. **For natural language tasks**: create synthetic issue context (title, acceptance criteria, type) from the instruction. Pass this context to the implementer subagent.
|
|
218
|
+
8. **Run the review loop** (Phase 3) after all implementations complete: spawn reviewer, then fixer for Critical/Warning findings, re-review, repeat until clean (max 3 iterations).
|
|
219
|
+
9. **Spawn final quality subagents** (Phase 4, after review loop is clean): test-writer + security-auditor (always), plus docs-writer, auditors as applicable.
|
|
220
|
+
|
|
221
|
+
This directive applies regardless of whether board-pickup was invoked. Any context where implementation tasks are identified MUST use one subagent per task with maximum parallelism.
|
|
222
|
+
|
|
223
|
+
## Rule Application
|
|
224
|
+
|
|
225
|
+
All hatch3r rules with `scope: always` apply to every implementation task, including work delegated to subagents. When constructing subagent prompts, include the rule directives — subagents do not automatically inherit the parent's rule context.
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
+
id: hatch3r-browser-verification
|
|
3
|
+
type: rule
|
|
2
4
|
description: Browser-based verification for UI and user-facing changes
|
|
3
|
-
|
|
5
|
+
scope: conditional
|
|
6
|
+
tags: [review]
|
|
4
7
|
---
|
|
5
8
|
# Browser Verification
|
|
6
9
|
|
|
@@ -26,6 +29,35 @@ Skip browser verification for:
|
|
|
26
29
|
- CI/CD pipeline changes
|
|
27
30
|
- Code refactors that do not alter rendered output
|
|
28
31
|
|
|
32
|
+
## Session Prompt Pattern
|
|
33
|
+
|
|
34
|
+
Browser verification is opt-in per command session. The orchestrator follows a standardized prompt flow so the user is asked exactly once.
|
|
35
|
+
|
|
36
|
+
### Prompt Rules
|
|
37
|
+
|
|
38
|
+
1. **At the START of any command that supports browser verification**, the orchestrator MUST ask the user once: *"Would you like to enable browser verification for this session? This uses Playwright to test changes in the running application."*
|
|
39
|
+
2. **The user's answer applies to ALL stages of that command** — implementation, review, and verification. Do not re-ask at any subsequent stage.
|
|
40
|
+
3. **If yes:** all implementation, review, and verification stages include browser testing steps as defined in the Verification Protocol below. The orchestrator ensures a dev server is running and executes browser checks at each verification point.
|
|
41
|
+
4. **If no:** all browser verification steps are skipped silently. Do not emit warnings, reminders, or suggestions to reconsider. The command proceeds as if the Verification Protocol section does not exist.
|
|
42
|
+
|
|
43
|
+
### Command Support Matrix
|
|
44
|
+
|
|
45
|
+
| Supports Browser Verification | Does NOT Support |
|
|
46
|
+
| ------------------------------ | ---------------- |
|
|
47
|
+
| `hatch3r-workflow` | `hatch3r-board-fill` |
|
|
48
|
+
| `hatch3r-board-pickup` | `hatch3r-board-groom` |
|
|
49
|
+
| `hatch3r-quick-change` | `hatch3r-board-refresh` |
|
|
50
|
+
| `hatch3r-revision` | `hatch3r-roadmap` |
|
|
51
|
+
| `hatch3r-debug` | `hatch3r-release` |
|
|
52
|
+
| | `hatch3r-refactor-plan` |
|
|
53
|
+
| | `hatch3r-security-audit` |
|
|
54
|
+
| | `hatch3r-rule-customize` |
|
|
55
|
+
| | `hatch3r-skill-customize` |
|
|
56
|
+
|
|
57
|
+
Commands in the "Does NOT Support" column are documentation-only, planning-only, or non-implementation commands. They MUST NOT prompt for browser verification.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
29
61
|
## Verification Protocol
|
|
30
62
|
|
|
31
63
|
### 1. Ensure Dev Server is Running
|
|
@@ -26,6 +26,35 @@ Skip browser verification for:
|
|
|
26
26
|
- CI/CD pipeline changes
|
|
27
27
|
- Code refactors that do not alter rendered output
|
|
28
28
|
|
|
29
|
+
## Session Prompt Pattern
|
|
30
|
+
|
|
31
|
+
Browser verification is opt-in per command session. The orchestrator follows a standardized prompt flow so the user is asked exactly once.
|
|
32
|
+
|
|
33
|
+
### Prompt Rules
|
|
34
|
+
|
|
35
|
+
1. **At the START of any command that supports browser verification**, the orchestrator MUST ask the user once: *"Would you like to enable browser verification for this session? This uses Playwright to test changes in the running application."*
|
|
36
|
+
2. **The user's answer applies to ALL stages of that command** — implementation, review, and verification. Do not re-ask at any subsequent stage.
|
|
37
|
+
3. **If yes:** all implementation, review, and verification stages include browser testing steps as defined in the Verification Protocol below. The orchestrator ensures a dev server is running and executes browser checks at each verification point.
|
|
38
|
+
4. **If no:** all browser verification steps are skipped silently. Do not emit warnings, reminders, or suggestions to reconsider. The command proceeds as if the Verification Protocol section does not exist.
|
|
39
|
+
|
|
40
|
+
### Command Support Matrix
|
|
41
|
+
|
|
42
|
+
| Supports Browser Verification | Does NOT Support |
|
|
43
|
+
| ------------------------------ | ---------------- |
|
|
44
|
+
| `hatch3r-workflow` | `hatch3r-board-fill` |
|
|
45
|
+
| `hatch3r-board-pickup` | `hatch3r-board-groom` |
|
|
46
|
+
| `hatch3r-quick-change` | `hatch3r-board-refresh` |
|
|
47
|
+
| `hatch3r-revision` | `hatch3r-roadmap` |
|
|
48
|
+
| `hatch3r-debug` | `hatch3r-release` |
|
|
49
|
+
| | `hatch3r-refactor-plan` |
|
|
50
|
+
| | `hatch3r-security-audit` |
|
|
51
|
+
| | `hatch3r-rule-customize` |
|
|
52
|
+
| | `hatch3r-skill-customize` |
|
|
53
|
+
|
|
54
|
+
Commands in the "Does NOT Support" column are documentation-only, planning-only, or non-implementation commands. They MUST NOT prompt for browser verification.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
29
58
|
## Verification Protocol
|
|
30
59
|
|
|
31
60
|
### 1. Ensure Dev Server is Running
|
package/rules/hatch3r-ci-cd.md
CHANGED
|
@@ -3,6 +3,7 @@ id: hatch3r-ci-cd
|
|
|
3
3
|
type: rule
|
|
4
4
|
description: CI/CD pipeline standards covering stage gates, deployment strategies, and rollback procedures
|
|
5
5
|
scope: always
|
|
6
|
+
tags: [devops]
|
|
6
7
|
---
|
|
7
8
|
# CI/CD Standards
|
|
8
9
|
|
|
@@ -64,7 +65,10 @@ scope: always
|
|
|
64
65
|
## Secrets Management in CI
|
|
65
66
|
|
|
66
67
|
- Never store secrets in pipeline configuration files.
|
|
67
|
-
- Use the CI platform's secret storage
|
|
68
|
+
- Use the CI platform's secret storage:
|
|
69
|
+
- **GitHub:** GitHub Secrets (repository or organization level)
|
|
70
|
+
- **Azure DevOps:** Pipeline variables (marked secret) or Azure Key Vault linked variable groups
|
|
71
|
+
- **GitLab:** CI/CD Variables (project or group level, marked Protected and Masked)
|
|
68
72
|
- Rotate CI secrets on a regular schedule (at least quarterly).
|
|
69
73
|
- Audit secret access logs for unauthorized usage.
|
|
70
74
|
- Use OIDC-based authentication for cloud provider access instead of long-lived credentials.
|
package/rules/hatch3r-ci-cd.mdc
CHANGED
|
@@ -62,7 +62,10 @@ alwaysApply: true
|
|
|
62
62
|
## Secrets Management in CI
|
|
63
63
|
|
|
64
64
|
- Never store secrets in pipeline configuration files.
|
|
65
|
-
- Use the CI platform's secret storage
|
|
65
|
+
- Use the CI platform's secret storage:
|
|
66
|
+
- **GitHub:** GitHub Secrets (repository or organization level)
|
|
67
|
+
- **Azure DevOps:** Pipeline variables (marked secret) or Azure Key Vault linked variable groups
|
|
68
|
+
- **GitLab:** CI/CD Variables (project or group level, marked Protected and Masked)
|
|
66
69
|
- Rotate CI secrets on a regular schedule (at least quarterly).
|
|
67
70
|
- Audit secret access logs for unauthorized usage.
|
|
68
71
|
- Use OIDC-based authentication for cloud provider access instead of long-lived credentials.
|
|
@@ -3,6 +3,7 @@ id: hatch3r-code-standards
|
|
|
3
3
|
type: rule
|
|
4
4
|
description: Code quality and file naming conventions for the project
|
|
5
5
|
scope: always
|
|
6
|
+
tags: [core]
|
|
6
7
|
---
|
|
7
8
|
# Code Standards
|
|
8
9
|
|
|
@@ -81,6 +82,15 @@ scope: always
|
|
|
81
82
|
- Log the full error (including stack trace) at the boundary. Return a safe, sanitized error response to the caller — no internal details.
|
|
82
83
|
- Let errors propagate naturally within a module. Catching errors mid-flow and re-throwing obscures the stack trace. Handle at the boundary.
|
|
83
84
|
|
|
85
|
+
### General Error Discipline
|
|
86
|
+
|
|
87
|
+
- Never swallow errors silently. Always re-throw or log with context.
|
|
88
|
+
- User-facing errors are separate from internal errors. Never expose internal details to clients.
|
|
89
|
+
- API endpoints return structured error responses `{ code, message, details? }`. Never return stack traces.
|
|
90
|
+
- Retry with exponential backoff for transient failures (network, rate limits). Honor `Retry-After` on 429.
|
|
91
|
+
- Include `correlationId` in all error logs for tracing across client and server.
|
|
92
|
+
- No secrets, tokens, or PII in error messages or logs.
|
|
93
|
+
|
|
84
94
|
## Import Ordering
|
|
85
95
|
|
|
86
96
|
Enforce consistent import ordering via linter rules (e.g., `eslint-plugin-import`). The canonical order:
|
|
@@ -93,6 +103,14 @@ Enforce consistent import ordering via linter rules (e.g., `eslint-plugin-import
|
|
|
93
103
|
|
|
94
104
|
Separate each group with a blank line. Sort alphabetically within each group.
|
|
95
105
|
|
|
106
|
+
## Monorepo Conventions
|
|
107
|
+
|
|
108
|
+
When working in a monorepo (multiple packages or apps in a single repository):
|
|
109
|
+
|
|
110
|
+
- **Scope changes to a single package at a time.** A PR should touch one package unless the change requires a coordinated cross-package update (e.g., a shared type change and its consumers). Coordinated changes must be documented in the PR description.
|
|
111
|
+
- **Run tests only for affected packages.** Use the monorepo tool's filtering (e.g., `--filter`, `--scope`, `--since`) to run tests, lint, and builds only for packages affected by the current change.
|
|
112
|
+
- **Respect package boundaries — do not import across packages without explicit dependency.** If package A needs something from package B, B must be declared as a dependency in A's `package.json` (or equivalent manifest). Direct file-path imports across package boundaries are forbidden.
|
|
113
|
+
|
|
96
114
|
## Dead Code Prevention
|
|
97
115
|
|
|
98
116
|
- Remove unused imports, variables, functions, and type definitions immediately. Do not comment them out "for later."
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: Code quality and file naming conventions for the project
|
|
3
3
|
alwaysApply: true
|
|
4
4
|
---
|
|
5
5
|
# Code Standards
|
|
@@ -79,6 +79,15 @@ alwaysApply: true
|
|
|
79
79
|
- Log the full error (including stack trace) at the boundary. Return a safe, sanitized error response to the caller — no internal details.
|
|
80
80
|
- Let errors propagate naturally within a module. Catching errors mid-flow and re-throwing obscures the stack trace. Handle at the boundary.
|
|
81
81
|
|
|
82
|
+
### General Error Discipline
|
|
83
|
+
|
|
84
|
+
- Never swallow errors silently. Always re-throw or log with context.
|
|
85
|
+
- User-facing errors are separate from internal errors. Never expose internal details to clients.
|
|
86
|
+
- API endpoints return structured error responses `{ code, message, details? }`. Never return stack traces.
|
|
87
|
+
- Retry with exponential backoff for transient failures (network, rate limits). Honor `Retry-After` on 429.
|
|
88
|
+
- Include `correlationId` in all error logs for tracing across client and server.
|
|
89
|
+
- No secrets, tokens, or PII in error messages or logs.
|
|
90
|
+
|
|
82
91
|
## Import Ordering
|
|
83
92
|
|
|
84
93
|
Enforce consistent import ordering via linter rules (e.g., `eslint-plugin-import`). The canonical order:
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
---
|
|
2
|
+
id: hatch3r-component-conventions
|
|
3
|
+
type: rule
|
|
2
4
|
description: Rules for component development in web applications
|
|
5
|
+
scope: conditional
|
|
3
6
|
globs: src/**/*.vue, src/**/*.tsx, src/**/*.jsx
|
|
4
|
-
|
|
7
|
+
tags: [implementation]
|
|
5
8
|
---
|
|
6
9
|
# Component Conventions
|
|
7
10
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-deep-context
|
|
3
|
+
type: rule
|
|
4
|
+
description: Adaptive pre-implementation analysis — complexity scoring, requirements elicitation, similar implementation discovery, and transitive dependency tracing before coding
|
|
5
|
+
scope: always
|
|
6
|
+
tags: [core]
|
|
7
|
+
---
|
|
8
|
+
# Deep Context Analysis
|
|
9
|
+
|
|
10
|
+
Before implementing any non-trivial task, assess its complexity and run proportional pre-implementation analysis. This rule ensures the agent asks the right questions, discovers existing patterns to follow, and maps the full blast radius before writing code.
|
|
11
|
+
|
|
12
|
+
## Complexity Scoring
|
|
13
|
+
|
|
14
|
+
Score every task against these signals before implementation. Each signal adds weight:
|
|
15
|
+
|
|
16
|
+
| Signal | Weight | Detection |
|
|
17
|
+
|--------|--------|-----------|
|
|
18
|
+
| Multiple modules/layers touched (data + API + UI, etc.) | +3 | Count distinct architectural layers in the task description and affected files |
|
|
19
|
+
| Vague or underspecified terms ("improve", "better", "proper", "handle", "support", "clean up") | +2 | Scan task description for ambiguous language |
|
|
20
|
+
| Cross-cutting concerns triggered (auth, i18n, a11y, payments, migrations, observability) | +2 | Match task against known cross-cutting domains |
|
|
21
|
+
| Epic or multi-issue scope | +3 | Task references multiple issues, contains numbered sub-tasks, or spans multiple features |
|
|
22
|
+
| New dependency or integration introduction | +2 | Task mentions new libraries, services, or external APIs |
|
|
23
|
+
| Estimated file count > 5 | +2 | Infer from task scope and codebase exploration |
|
|
24
|
+
| Security-sensitive area (auth, payments, data access, secrets) | +2 | Match task against security-sensitive directories or keywords |
|
|
25
|
+
| Behavioral contract change (API signature, event schema, type interface) | +2 | Task implies changes to shared interfaces or public APIs |
|
|
26
|
+
|
|
27
|
+
### Tier Assignment
|
|
28
|
+
|
|
29
|
+
| Total Weight | Tier | Label |
|
|
30
|
+
|-------------|------|-------|
|
|
31
|
+
| 0–2 | 1 | Light |
|
|
32
|
+
| 3–5 | 2 | Standard |
|
|
33
|
+
| 6+ | 3 | Deep |
|
|
34
|
+
|
|
35
|
+
## Tier Actions
|
|
36
|
+
|
|
37
|
+
### Tier 1 — Light
|
|
38
|
+
|
|
39
|
+
Single-file changes, config tweaks, typo fixes, comment edits, constant value changes. No additional analysis required beyond existing researcher modes.
|
|
40
|
+
|
|
41
|
+
Skip deep context analysis entirely. Proceed with the standard pipeline.
|
|
42
|
+
|
|
43
|
+
### Tier 2 — Standard
|
|
44
|
+
|
|
45
|
+
Multi-file changes with clear scope. Run these researcher modes at `quick` depth before implementation:
|
|
46
|
+
|
|
47
|
+
1. **`requirements-elicitation`** at `quick` — scan for top ambiguities and ask 3–5 clarifying questions.
|
|
48
|
+
2. **`similar-implementation`** at `quick` — find 1 reference implementation and extract top-level patterns.
|
|
49
|
+
|
|
50
|
+
Present findings to the user inline. Proceed after answers are received — no separate confirmation checkpoint required.
|
|
51
|
+
|
|
52
|
+
### Tier 3 — Deep
|
|
53
|
+
|
|
54
|
+
Cross-module features, architectural changes, multi-layer implementations, or tasks with high ambiguity. Run these researcher modes at `deep` depth:
|
|
55
|
+
|
|
56
|
+
1. **`requirements-elicitation`** at `deep` — full 10-dimension ambiguity scan, dependency-derived questions, cross-cutting concern checklist.
|
|
57
|
+
2. **`similar-implementation`** at `deep` — find 2–3 reference implementations, full convention extraction, divergence analysis.
|
|
58
|
+
3. **`codebase-impact`** at `deep` — full transitive dependency tracing, API consumer map, blast radius summary.
|
|
59
|
+
|
|
60
|
+
**Mandatory checkpoint:** Present a consolidated "Pre-Implementation Summary" to the user and ASK for confirmation before proceeding to implementation:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Pre-Implementation Summary:
|
|
64
|
+
Complexity: Tier 3 (Deep) — score {N}
|
|
65
|
+
Resolved requirements: {N}/{M} dimensions addressed
|
|
66
|
+
Unresolved questions: {list — these MUST be answered before proceeding}
|
|
67
|
+
Reference implementation: {name} — conventions locked
|
|
68
|
+
Blast radius: {N} files directly affected, {M} transitively at risk
|
|
69
|
+
Cross-cutting concerns: {list with status}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Do NOT proceed to implementation until all unresolved questions are answered by the user.
|
|
73
|
+
|
|
74
|
+
## Passing Context to Implementer
|
|
75
|
+
|
|
76
|
+
When the `similar-implementation` mode produces reference implementations, include them in the implementer sub-agent prompt as **"Reference Conventions"**. The implementer's Convention Lock step (Step 1b) uses these to align its architectural decisions with established codebase patterns.
|
|
77
|
+
|
|
78
|
+
When the `requirements-elicitation` mode produces resolved requirements, include the user's answers in the implementer sub-agent prompt as **"Resolved Requirements"** so the implementer has explicit answers to all ambiguities rather than guessing.
|
|
79
|
+
|
|
80
|
+
When the enhanced `codebase-impact` mode produces a blast radius summary, include it in the implementer sub-agent prompt so the implementer knows which consumers and contracts must be preserved.
|
|
81
|
+
|
|
82
|
+
## Integration with Existing Pipeline
|
|
83
|
+
|
|
84
|
+
This rule augments — not replaces — the existing Universal Sub-Agent Pipeline from `hatch3r-agent-orchestration`. The complexity scoring happens at the start of Phase 1 (Research), and the additional researcher modes run alongside the existing task-type modes:
|
|
85
|
+
|
|
86
|
+
- **`type:feature`**: existing modes `codebase-impact`, `feature-design`, `architecture` + new modes per tier
|
|
87
|
+
- **`type:bug`**: existing modes `symptom-trace`, `root-cause`, `codebase-impact` + `requirements-elicitation` per tier (bugs often have underspecified reproduction steps)
|
|
88
|
+
- **`type:refactor`**: existing modes `current-state`, `refactoring-strategy`, `migration-path` + `similar-implementation` per tier (refactors benefit most from convention alignment)
|
|
89
|
+
|
|
90
|
+
## Exceptions
|
|
91
|
+
|
|
92
|
+
- **`hatch3r-quick-change` command**: Tier 1 items proceed without research. Tier 2 items get lightweight `similar-implementation` at `quick` depth. Tier 3 items must be routed to `hatch3r-workflow` (hard block).
|
|
93
|
+
- **Trivial single-line edits**: Always Tier 1 regardless of scoring signals. This is the only valid basis for skipping research — label-based shortcuts (e.g., `risk:low AND priority:p3`) are not sufficient alone.
|
|
94
|
+
- **`hatch3r-revision` command**: Operates on already-implemented code. Deep context analysis applies to the original implementation, not the revision pass.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Adaptive pre-implementation analysis — complexity scoring, requirements elicitation, similar implementation discovery, and transitive dependency tracing before coding
|
|
3
|
+
alwaysApply: true
|
|
4
|
+
---
|
|
5
|
+
# Deep Context Analysis
|
|
6
|
+
|
|
7
|
+
Before implementing any non-trivial task, assess its complexity and run proportional pre-implementation analysis. This rule ensures the agent asks the right questions, discovers existing patterns to follow, and maps the full blast radius before writing code.
|
|
8
|
+
|
|
9
|
+
## Complexity Scoring
|
|
10
|
+
|
|
11
|
+
Score every task against these signals before implementation. Each signal adds weight:
|
|
12
|
+
|
|
13
|
+
| Signal | Weight | Detection |
|
|
14
|
+
|--------|--------|-----------|
|
|
15
|
+
| Multiple modules/layers touched (data + API + UI, etc.) | +3 | Count distinct architectural layers in the task description and affected files |
|
|
16
|
+
| Vague or underspecified terms ("improve", "better", "proper", "handle", "support", "clean up") | +2 | Scan task description for ambiguous language |
|
|
17
|
+
| Cross-cutting concerns triggered (auth, i18n, a11y, payments, migrations, observability) | +2 | Match task against known cross-cutting domains |
|
|
18
|
+
| Epic or multi-issue scope | +3 | Task references multiple issues, contains numbered sub-tasks, or spans multiple features |
|
|
19
|
+
| New dependency or integration introduction | +2 | Task mentions new libraries, services, or external APIs |
|
|
20
|
+
| Estimated file count > 5 | +2 | Infer from task scope and codebase exploration |
|
|
21
|
+
| Security-sensitive area (auth, payments, data access, secrets) | +2 | Match task against security-sensitive directories or keywords |
|
|
22
|
+
| Behavioral contract change (API signature, event schema, type interface) | +2 | Task implies changes to shared interfaces or public APIs |
|
|
23
|
+
|
|
24
|
+
### Tier Assignment
|
|
25
|
+
|
|
26
|
+
| Total Weight | Tier | Label |
|
|
27
|
+
|-------------|------|-------|
|
|
28
|
+
| 0–2 | 1 | Light |
|
|
29
|
+
| 3–5 | 2 | Standard |
|
|
30
|
+
| 6+ | 3 | Deep |
|
|
31
|
+
|
|
32
|
+
## Tier Actions
|
|
33
|
+
|
|
34
|
+
### Tier 1 — Light
|
|
35
|
+
|
|
36
|
+
Single-file changes, config tweaks, typo fixes, comment edits, constant value changes. No additional analysis required beyond existing researcher modes. Skip deep context analysis entirely.
|
|
37
|
+
|
|
38
|
+
### Tier 2 — Standard
|
|
39
|
+
|
|
40
|
+
Multi-file changes with clear scope. Run these researcher modes at `quick` depth before implementation:
|
|
41
|
+
|
|
42
|
+
1. **`requirements-elicitation`** at `quick` — scan for top ambiguities and ask 3–5 clarifying questions.
|
|
43
|
+
2. **`similar-implementation`** at `quick` — find 1 reference implementation and extract top-level patterns.
|
|
44
|
+
|
|
45
|
+
Present findings to the user inline. Proceed after answers are received.
|
|
46
|
+
|
|
47
|
+
### Tier 3 — Deep
|
|
48
|
+
|
|
49
|
+
Cross-module features, architectural changes, multi-layer implementations, or tasks with high ambiguity. Run these researcher modes at `deep` depth:
|
|
50
|
+
|
|
51
|
+
1. **`requirements-elicitation`** at `deep` — full 10-dimension ambiguity scan, dependency-derived questions, cross-cutting concern checklist.
|
|
52
|
+
2. **`similar-implementation`** at `deep` — find 2–3 reference implementations, full convention extraction, divergence analysis.
|
|
53
|
+
3. **`codebase-impact`** at `deep` — full transitive dependency tracing, API consumer map, blast radius summary.
|
|
54
|
+
|
|
55
|
+
**Mandatory checkpoint:** Present a consolidated "Pre-Implementation Summary" to the user and ASK for confirmation before proceeding. Do NOT proceed until all unresolved questions are answered.
|
|
56
|
+
|
|
57
|
+
## Passing Context to Implementer
|
|
58
|
+
|
|
59
|
+
When the `similar-implementation` mode produces reference implementations, include them in the implementer sub-agent prompt as **"Reference Conventions"**. When the `requirements-elicitation` mode produces resolved requirements, include the user's answers as **"Resolved Requirements"**. When `codebase-impact` produces a blast radius summary, include it so the implementer knows which consumers and contracts must be preserved.
|
|
60
|
+
|
|
61
|
+
## Integration with Existing Pipeline
|
|
62
|
+
|
|
63
|
+
This rule augments the existing Universal Sub-Agent Pipeline from `hatch3r-agent-orchestration`. The complexity scoring happens at the start of Phase 1 (Research), and the additional researcher modes run alongside the existing task-type modes.
|
|
64
|
+
|
|
65
|
+
## Exceptions
|
|
66
|
+
|
|
67
|
+
- **`hatch3r-quick-change`**: Tier 1 items proceed without research. Tier 2 items get lightweight `similar-implementation` at `quick` depth. Tier 3 items must be routed to `hatch3r-workflow` (hard block).
|
|
68
|
+
- **Trivial single-line edits**: Always Tier 1 regardless of scoring. This is the only valid basis for skipping research — label-based shortcuts (e.g., `risk:low AND priority:p3`) are not sufficient alone.
|
|
69
|
+
- **`hatch3r-revision`**: Operates on already-implemented code; deep context analysis applies to the original implementation.
|
|
@@ -3,6 +3,7 @@ id: hatch3r-dependency-management
|
|
|
3
3
|
type: rule
|
|
4
4
|
description: Rules for managing project dependencies
|
|
5
5
|
scope: always
|
|
6
|
+
tags: [maintenance]
|
|
6
7
|
---
|
|
7
8
|
# Dependency Management
|
|
8
9
|
|
|
@@ -15,3 +16,15 @@ scope: always
|
|
|
15
16
|
- Remove unused dependencies on every cleanup pass.
|
|
16
17
|
- Security patches (CVEs) are P0/P1 priority. Patch within 48h for critical.
|
|
17
18
|
- Check bundle size impact against budget. Reject deps that exceed.
|
|
19
|
+
|
|
20
|
+
## Transitive Dependency Hygiene
|
|
21
|
+
|
|
22
|
+
- Audit transitive dependencies, not just direct ones. A direct dependency with a compromised transitive dep is still a vulnerability. Use `npm ls`, `pip show`, or `cargo tree` to inspect the full dependency graph.
|
|
23
|
+
- When a transitive dependency has a known CVE, determine whether the vulnerable code path is reachable from your project. If reachable, override or patch the transitive dep. If unreachable, document the finding with justification for deferral.
|
|
24
|
+
- Avoid dependencies that pull in excessively large transitive trees for minimal functionality. If a package adds 50+ transitive deps for a single utility function, write the utility inline or find a lighter alternative.
|
|
25
|
+
|
|
26
|
+
## Version Upgrade Strategy
|
|
27
|
+
|
|
28
|
+
- Review changelogs and migration guides before upgrading major versions. Never blindly bump major versions and assume backward compatibility.
|
|
29
|
+
- Run the full test suite after any dependency upgrade, including integration tests. A passing unit test suite does not guarantee compatibility with upgraded peer dependencies.
|
|
30
|
+
- When upgrading a shared dependency used across multiple modules, upgrade all consumers in the same PR to avoid version skew within the monorepo or project.
|