hatch3r 1.0.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/LICENSE +21 -0
- package/README.md +437 -0
- package/agents/hatch3r-a11y-auditor.md +126 -0
- package/agents/hatch3r-architect.md +160 -0
- package/agents/hatch3r-ci-watcher.md +123 -0
- package/agents/hatch3r-context-rules.md +97 -0
- package/agents/hatch3r-dependency-auditor.md +164 -0
- package/agents/hatch3r-devops.md +138 -0
- package/agents/hatch3r-docs-writer.md +97 -0
- package/agents/hatch3r-implementer.md +162 -0
- package/agents/hatch3r-learnings-loader.md +108 -0
- package/agents/hatch3r-lint-fixer.md +104 -0
- package/agents/hatch3r-perf-profiler.md +123 -0
- package/agents/hatch3r-researcher.md +642 -0
- package/agents/hatch3r-reviewer.md +81 -0
- package/agents/hatch3r-security-auditor.md +119 -0
- package/agents/hatch3r-test-writer.md +134 -0
- package/commands/hatch3r-agent-customize.md +146 -0
- package/commands/hatch3r-api-spec.md +49 -0
- package/commands/hatch3r-benchmark.md +50 -0
- package/commands/hatch3r-board-fill.md +504 -0
- package/commands/hatch3r-board-init.md +315 -0
- package/commands/hatch3r-board-pickup.md +672 -0
- package/commands/hatch3r-board-refresh.md +198 -0
- package/commands/hatch3r-board-shared.md +369 -0
- package/commands/hatch3r-bug-plan.md +410 -0
- package/commands/hatch3r-codebase-map.md +1182 -0
- package/commands/hatch3r-command-customize.md +94 -0
- package/commands/hatch3r-context-health.md +112 -0
- package/commands/hatch3r-cost-tracking.md +139 -0
- package/commands/hatch3r-dep-audit.md +171 -0
- package/commands/hatch3r-feature-plan.md +379 -0
- package/commands/hatch3r-healthcheck.md +307 -0
- package/commands/hatch3r-hooks.md +282 -0
- package/commands/hatch3r-learn.md +217 -0
- package/commands/hatch3r-migration-plan.md +51 -0
- package/commands/hatch3r-onboard.md +56 -0
- package/commands/hatch3r-project-spec.md +1153 -0
- package/commands/hatch3r-recipe.md +179 -0
- package/commands/hatch3r-refactor-plan.md +426 -0
- package/commands/hatch3r-release.md +328 -0
- package/commands/hatch3r-roadmap.md +556 -0
- package/commands/hatch3r-rule-customize.md +114 -0
- package/commands/hatch3r-security-audit.md +370 -0
- package/commands/hatch3r-skill-customize.md +93 -0
- package/commands/hatch3r-workflow.md +377 -0
- package/dist/cli/hooks-ZOTFDEA3.js +59 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +3584 -0
- package/github-agents/hatch3r-docs-agent.md +46 -0
- package/github-agents/hatch3r-lint-agent.md +41 -0
- package/github-agents/hatch3r-security-agent.md +54 -0
- package/github-agents/hatch3r-test-agent.md +66 -0
- package/hooks/hatch3r-ci-failure.md +10 -0
- package/hooks/hatch3r-file-save.md +11 -0
- package/hooks/hatch3r-post-merge.md +10 -0
- package/hooks/hatch3r-pre-commit.md +11 -0
- package/hooks/hatch3r-pre-push.md +10 -0
- package/hooks/hatch3r-session-start.md +10 -0
- package/mcp/mcp.json +62 -0
- package/package.json +84 -0
- package/prompts/hatch3r-bug-triage.md +155 -0
- package/prompts/hatch3r-code-review.md +131 -0
- package/prompts/hatch3r-pr-description.md +173 -0
- package/rules/hatch3r-accessibility-standards.md +77 -0
- package/rules/hatch3r-accessibility-standards.mdc +75 -0
- package/rules/hatch3r-agent-orchestration.md +160 -0
- package/rules/hatch3r-api-design.md +176 -0
- package/rules/hatch3r-api-design.mdc +176 -0
- package/rules/hatch3r-browser-verification.md +73 -0
- package/rules/hatch3r-browser-verification.mdc +73 -0
- package/rules/hatch3r-ci-cd.md +70 -0
- package/rules/hatch3r-ci-cd.mdc +68 -0
- package/rules/hatch3r-code-standards.md +102 -0
- package/rules/hatch3r-code-standards.mdc +100 -0
- package/rules/hatch3r-component-conventions.md +102 -0
- package/rules/hatch3r-component-conventions.mdc +102 -0
- package/rules/hatch3r-data-classification.md +85 -0
- package/rules/hatch3r-data-classification.mdc +83 -0
- package/rules/hatch3r-dependency-management.md +17 -0
- package/rules/hatch3r-dependency-management.mdc +15 -0
- package/rules/hatch3r-error-handling.md +17 -0
- package/rules/hatch3r-error-handling.mdc +15 -0
- package/rules/hatch3r-feature-flags.md +112 -0
- package/rules/hatch3r-feature-flags.mdc +112 -0
- package/rules/hatch3r-git-conventions.md +47 -0
- package/rules/hatch3r-git-conventions.mdc +45 -0
- package/rules/hatch3r-i18n.md +90 -0
- package/rules/hatch3r-i18n.mdc +90 -0
- package/rules/hatch3r-learning-consult.md +29 -0
- package/rules/hatch3r-learning-consult.mdc +27 -0
- package/rules/hatch3r-migrations.md +17 -0
- package/rules/hatch3r-migrations.mdc +15 -0
- package/rules/hatch3r-observability.md +165 -0
- package/rules/hatch3r-observability.mdc +165 -0
- package/rules/hatch3r-performance-budgets.md +109 -0
- package/rules/hatch3r-performance-budgets.mdc +109 -0
- package/rules/hatch3r-secrets-management.md +76 -0
- package/rules/hatch3r-secrets-management.mdc +74 -0
- package/rules/hatch3r-security-patterns.md +211 -0
- package/rules/hatch3r-security-patterns.mdc +211 -0
- package/rules/hatch3r-testing.md +89 -0
- package/rules/hatch3r-testing.mdc +87 -0
- package/rules/hatch3r-theming.md +51 -0
- package/rules/hatch3r-theming.mdc +51 -0
- package/rules/hatch3r-tooling-hierarchy.md +92 -0
- package/rules/hatch3r-tooling-hierarchy.mdc +79 -0
- package/skills/hatch3r-a11y-audit/SKILL.md +131 -0
- package/skills/hatch3r-agent-customize/SKILL.md +75 -0
- package/skills/hatch3r-api-spec/SKILL.md +66 -0
- package/skills/hatch3r-architecture-review/SKILL.md +96 -0
- package/skills/hatch3r-bug-fix/SKILL.md +129 -0
- package/skills/hatch3r-ci-pipeline/SKILL.md +76 -0
- package/skills/hatch3r-command-customize/SKILL.md +67 -0
- package/skills/hatch3r-context-health/SKILL.md +76 -0
- package/skills/hatch3r-cost-tracking/SKILL.md +65 -0
- package/skills/hatch3r-dep-audit/SKILL.md +82 -0
- package/skills/hatch3r-feature/SKILL.md +129 -0
- package/skills/hatch3r-gh-agentic-workflows/SKILL.md +150 -0
- package/skills/hatch3r-incident-response/SKILL.md +86 -0
- package/skills/hatch3r-issue-workflow/SKILL.md +139 -0
- package/skills/hatch3r-logical-refactor/SKILL.md +73 -0
- package/skills/hatch3r-migration/SKILL.md +76 -0
- package/skills/hatch3r-perf-audit/SKILL.md +114 -0
- package/skills/hatch3r-pr-creation/SKILL.md +85 -0
- package/skills/hatch3r-qa-validation/SKILL.md +86 -0
- package/skills/hatch3r-recipe/SKILL.md +67 -0
- package/skills/hatch3r-refactor/SKILL.md +86 -0
- package/skills/hatch3r-release/SKILL.md +93 -0
- package/skills/hatch3r-rule-customize/SKILL.md +70 -0
- package/skills/hatch3r-skill-customize/SKILL.md +67 -0
- package/skills/hatch3r-visual-refactor/SKILL.md +89 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-recipe
|
|
3
|
+
type: command
|
|
4
|
+
description: Execute shareable workflow recipes that compose agents, skills, and commands into guided sequences for common development scenarios
|
|
5
|
+
---
|
|
6
|
+
# Recipe System — Composable Workflow Orchestration
|
|
7
|
+
|
|
8
|
+
Execute predefined or custom workflow recipes that chain hatch3r's agents, skills, and commands into repeatable guided sequences for common development scenarios.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Recipe Format
|
|
13
|
+
|
|
14
|
+
Recipes are YAML files stored in `.hatch3r/recipes/` (project-level) or `~/.hatch3r/recipes/` (user-level).
|
|
15
|
+
|
|
16
|
+
### Recipe Schema
|
|
17
|
+
|
|
18
|
+
```yaml
|
|
19
|
+
name: greenfield-setup
|
|
20
|
+
version: 1.0.0
|
|
21
|
+
description: Full greenfield project setup from spec to first PR
|
|
22
|
+
author: hatch3r
|
|
23
|
+
tags: [setup, greenfield, planning]
|
|
24
|
+
|
|
25
|
+
prerequisites:
|
|
26
|
+
- GitHub repository initialized
|
|
27
|
+
- hatch3r initialized (hatch3r init)
|
|
28
|
+
|
|
29
|
+
variables:
|
|
30
|
+
project_name:
|
|
31
|
+
description: Project name
|
|
32
|
+
required: true
|
|
33
|
+
tech_stack:
|
|
34
|
+
description: Primary tech stack
|
|
35
|
+
required: true
|
|
36
|
+
options: [react, vue, next, express, fastify]
|
|
37
|
+
|
|
38
|
+
steps:
|
|
39
|
+
- id: generate-spec
|
|
40
|
+
name: Generate Project Specification
|
|
41
|
+
command: hatch3r-project-spec
|
|
42
|
+
inputs:
|
|
43
|
+
project_name: "{{ project_name }}"
|
|
44
|
+
checkpoint: true
|
|
45
|
+
|
|
46
|
+
- id: init-board
|
|
47
|
+
name: Initialize Project Board
|
|
48
|
+
command: hatch3r-board-init
|
|
49
|
+
depends_on: [generate-spec]
|
|
50
|
+
checkpoint: true
|
|
51
|
+
|
|
52
|
+
- id: fill-board
|
|
53
|
+
name: Fill Board from Specification
|
|
54
|
+
command: hatch3r-board-fill
|
|
55
|
+
depends_on: [init-board]
|
|
56
|
+
|
|
57
|
+
- id: security-baseline
|
|
58
|
+
name: Security Baseline Audit
|
|
59
|
+
command: hatch3r-security-audit
|
|
60
|
+
depends_on: [fill-board]
|
|
61
|
+
parallel_with: [a11y-baseline]
|
|
62
|
+
|
|
63
|
+
- id: a11y-baseline
|
|
64
|
+
name: Accessibility Baseline
|
|
65
|
+
skill: hatch3r-a11y-audit
|
|
66
|
+
depends_on: [fill-board]
|
|
67
|
+
parallel_with: [security-baseline]
|
|
68
|
+
|
|
69
|
+
- id: first-pickup
|
|
70
|
+
name: Pick Up First Issue
|
|
71
|
+
command: hatch3r-board-pickup
|
|
72
|
+
depends_on: [security-baseline, a11y-baseline]
|
|
73
|
+
checkpoint: true
|
|
74
|
+
|
|
75
|
+
completion:
|
|
76
|
+
message: "Project {{ project_name }} is set up with board, security audit, and first issue in progress."
|
|
77
|
+
next_steps:
|
|
78
|
+
- Continue with `board-pickup` to implement remaining issues
|
|
79
|
+
- Run `hatch3r-dep-audit` for dependency security baseline
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Built-in Recipes
|
|
83
|
+
|
|
84
|
+
### 1. Greenfield Setup
|
|
85
|
+
Full project initialization: spec -> board -> audit -> first issue.
|
|
86
|
+
|
|
87
|
+
### 2. Legacy Onboarding
|
|
88
|
+
Codebase analysis -> codebase map -> board setup -> healthcheck -> first improvements.
|
|
89
|
+
|
|
90
|
+
### 3. Security Hardening
|
|
91
|
+
Security audit -> dependency audit -> findings triage -> hardening implementation.
|
|
92
|
+
|
|
93
|
+
### 4. Performance Sprint
|
|
94
|
+
Performance audit -> budget review -> optimization planning -> implementation -> verification.
|
|
95
|
+
|
|
96
|
+
### 5. Release Preparation
|
|
97
|
+
Healthcheck -> test validation -> security scan -> changelog -> release.
|
|
98
|
+
|
|
99
|
+
### 6. Quality Gate
|
|
100
|
+
Lint fix -> test coverage review -> a11y audit -> perf audit -> security scan.
|
|
101
|
+
|
|
102
|
+
## Recipe Execution
|
|
103
|
+
|
|
104
|
+
### Workflow
|
|
105
|
+
|
|
106
|
+
1. **Parse recipe**: Load and validate YAML schema, resolve variable references.
|
|
107
|
+
2. **Check prerequisites**: Verify all prerequisites are met before starting.
|
|
108
|
+
3. **Collect variables**: Prompt user for required variables (or accept via CLI args).
|
|
109
|
+
4. **Build execution graph**: Resolve `depends_on` and `parallel_with` into a dependency DAG.
|
|
110
|
+
5. **Execute steps**: Run steps in dependency order, parallelizing where possible.
|
|
111
|
+
6. **Handle checkpoints**: At `checkpoint: true` steps, pause and present progress to user.
|
|
112
|
+
7. **Report completion**: Show completion message and next steps.
|
|
113
|
+
|
|
114
|
+
### Execution Modes
|
|
115
|
+
|
|
116
|
+
| Mode | Behavior |
|
|
117
|
+
|------|----------|
|
|
118
|
+
| Interactive (default) | Pause at checkpoints, show progress |
|
|
119
|
+
| Auto (`--auto`) | Skip checkpoints, run all steps autonomously |
|
|
120
|
+
| Dry-run (`--dry-run`) | Show execution plan without running |
|
|
121
|
+
| Resume (`--resume`) | Continue from last checkpoint |
|
|
122
|
+
|
|
123
|
+
### Error Handling
|
|
124
|
+
|
|
125
|
+
- **Step failure**: Stop execution, show error, offer retry or skip.
|
|
126
|
+
- **Dependency failure**: Skip dependent steps, mark as blocked.
|
|
127
|
+
- **Partial completion**: Save progress, allow resume from last successful step.
|
|
128
|
+
|
|
129
|
+
## Custom Recipes
|
|
130
|
+
|
|
131
|
+
### Creating a Recipe
|
|
132
|
+
|
|
133
|
+
1. Create a YAML file in `.hatch3r/recipes/your-recipe.yaml`
|
|
134
|
+
2. Follow the recipe schema above
|
|
135
|
+
3. Test with `--dry-run` mode
|
|
136
|
+
4. Share by including in the project repository
|
|
137
|
+
|
|
138
|
+
### Recipe Composition
|
|
139
|
+
|
|
140
|
+
Recipes can reference other recipes as steps:
|
|
141
|
+
```yaml
|
|
142
|
+
steps:
|
|
143
|
+
- id: security
|
|
144
|
+
recipe: security-hardening
|
|
145
|
+
inputs:
|
|
146
|
+
scope: full
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Output Format
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
## Recipe Execution: {recipe_name}
|
|
153
|
+
|
|
154
|
+
**Status:** COMPLETE | PARTIAL | FAILED
|
|
155
|
+
|
|
156
|
+
**Steps:**
|
|
157
|
+
|
|
158
|
+
| # | Step | Status | Duration | Notes |
|
|
159
|
+
|---|------|--------|----------|-------|
|
|
160
|
+
| 1 | Generate Spec | DONE | 5m | Spec created at docs/spec.md |
|
|
161
|
+
| 2 | Init Board | DONE | 2m | Board created with 8 columns |
|
|
162
|
+
| 3 | Fill Board | DONE | 8m | 24 issues created |
|
|
163
|
+
| 4 | Security Audit | DONE | 3m | Audit epic #45 created |
|
|
164
|
+
| 5 | First Pickup | IN PROGRESS | - | Working on #46 |
|
|
165
|
+
|
|
166
|
+
**Variables Used:**
|
|
167
|
+
- project_name: {value}
|
|
168
|
+
- tech_stack: {value}
|
|
169
|
+
|
|
170
|
+
**Next Steps:**
|
|
171
|
+
- {recommendations}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Guardrails
|
|
175
|
+
|
|
176
|
+
- Recipes must not bypass safety checkpoints for destructive operations
|
|
177
|
+
- Recipe files are validated against the schema before execution
|
|
178
|
+
- Circular dependencies in the execution graph are detected and rejected
|
|
179
|
+
- Variable injection is sanitized to prevent command injection
|
|
@@ -0,0 +1,426 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-refactor-plan
|
|
3
|
+
type: command
|
|
4
|
+
description: Plan a refactoring or migration effort -- spawn parallel researchers, produce refactoring spec, ADR(s), and phased todo.md entries for board-fill.
|
|
5
|
+
---
|
|
6
|
+
# Refactor Plan — Refactoring & Migration Specification from Problem to Phased Execution
|
|
7
|
+
|
|
8
|
+
Take a refactoring goal or migration need and produce a complete refactoring specification (`docs/specs/`), architectural decision records (`docs/adr/`) when the approach involves significant design choices, and structured `todo.md` entries (phased work items) ready for `hatch3r-board-fill`. Spawns parallel researcher sub-agents (current state analysis, refactoring strategy, impact & risk assessment, migration path planning) to design the refactoring from multiple angles before generating artifacts. AI proposes all outputs; user confirms before any files are written. Optionally chains into `hatch3r-board-fill` to create GitHub issues immediately.
|
|
9
|
+
|
|
10
|
+
**Handles all refactoring types by detection:**
|
|
11
|
+
|
|
12
|
+
- **Structural / code refactoring** — module restructuring, extraction, dependency decoupling, dead code removal
|
|
13
|
+
- **Logical refactoring** — behavior flow changes, data model migrations, API contract evolution
|
|
14
|
+
- **Visual refactoring** — design system overhauls, component hierarchy restructuring, accessibility compliance
|
|
15
|
+
- **Mixed** — the command detects which dimensions are relevant and adjusts researcher prompts
|
|
16
|
+
|
|
17
|
+
The command produces phased todo.md entries that map to the appropriate execution skill (`hatch3r-refactor`, `hatch3r-logical-refactor`, or `hatch3r-visual-refactor`) during `hatch3r-board-pickup`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Shared Context
|
|
22
|
+
|
|
23
|
+
**Read the `hatch3r-board-shared` command at the start of the run** if it exists. While this command does not perform board operations directly, it establishes patterns and context (GitHub owner/repo, tooling directives) that downstream commands like `hatch3r-board-fill` rely on. Cache any values found.
|
|
24
|
+
|
|
25
|
+
## Token-Saving Directives
|
|
26
|
+
|
|
27
|
+
1. **Do not re-read files already cached.** Once researcher outputs are collected, reference them in memory — do not re-invoke sub-agents.
|
|
28
|
+
2. **Limit documentation reads.** When reading existing project files for context, read TOC/headers first (~30 lines), expand only relevant sections.
|
|
29
|
+
3. **Structured output only.** All sub-agent prompts require structured markdown output — no prose dumps.
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Workflow
|
|
34
|
+
|
|
35
|
+
Execute these steps in order. **Do not skip any step.** Ask the user at every checkpoint marked with ASK.
|
|
36
|
+
|
|
37
|
+
### Step 1: Gather Refactoring Goal
|
|
38
|
+
|
|
39
|
+
1. **ASK:** "Tell me about the refactoring or migration you want to plan. I need:
|
|
40
|
+
- **Title** (short descriptive name for the effort)
|
|
41
|
+
- **Motivation** (what problem does this solve? what pain are you experiencing?)
|
|
42
|
+
- **Target area** (which modules, files, components, or patterns are involved?)
|
|
43
|
+
- **Desired end state** (what does "done" look like? what improves?)
|
|
44
|
+
- **Constraints** (backward compatibility, feature freeze, timeline, external consumers, etc.)
|
|
45
|
+
- **Refactoring type** (structural / logical / visual / migration / mixed / not sure)
|
|
46
|
+
|
|
47
|
+
You can also point me to a tech debt finding, `hatch3r-codebase-map` output, existing spec section, or GitHub issue and I'll extract these from it."
|
|
48
|
+
|
|
49
|
+
2. If the user provides a document reference or issue, read it and extract the six fields above.
|
|
50
|
+
3. Detect the **refactoring dimension(s)** from the goal:
|
|
51
|
+
|
|
52
|
+
| Signal | Dimension |
|
|
53
|
+
|--------|-----------|
|
|
54
|
+
| Module restructuring, file reorganization, extracting/inlining, decoupling, dead code | Structural |
|
|
55
|
+
| Behavior changes, data model changes, API evolution, business logic rewrite | Logical |
|
|
56
|
+
| Design system changes, component overhaul, accessibility fixes, responsive layout | Visual |
|
|
57
|
+
| Framework/library swap, database migration, architecture shift | Migration |
|
|
58
|
+
|
|
59
|
+
4. Present a structured summary:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
Refactoring Brief:
|
|
63
|
+
Title: {title}
|
|
64
|
+
Motivation: {why this refactoring is needed}
|
|
65
|
+
Target area: {modules, files, patterns involved}
|
|
66
|
+
Desired state: {what "done" looks like}
|
|
67
|
+
Constraints: {list}
|
|
68
|
+
Dimension(s): {Structural / Logical / Visual / Migration — one or more}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**ASK:** "Does this capture the refactoring goal correctly? Adjust anything before I send this to the research phase."
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
### Step 2: Load Project Context
|
|
76
|
+
|
|
77
|
+
1. Check for existing documentation:
|
|
78
|
+
- `docs/specs/` — project specifications (read TOC/headers first, expand relevant sections only)
|
|
79
|
+
- `docs/adr/` — architectural decision records (scan for decisions relevant to the target area)
|
|
80
|
+
- `README.md` — project overview
|
|
81
|
+
- `/.agents/hatch.json` — board configuration
|
|
82
|
+
- Existing `todo.md` — current backlog (check for overlap or related items)
|
|
83
|
+
2. Scan GitHub issues via `search_issues` for existing work related to the refactoring area. Note in-progress work, dependencies, or prior refactoring attempts.
|
|
84
|
+
3. If `/.agents/learnings/` exists, scan for learnings relevant to the target area. Match by area and tags against the refactoring brief.
|
|
85
|
+
4. Scan test coverage in the target area — identify which parts have strong test coverage (safe to refactor) vs. weak coverage (need tests first).
|
|
86
|
+
5. Present a context summary:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Context Loaded:
|
|
90
|
+
Specs: {N} files in docs/specs/ ({relevant ones listed})
|
|
91
|
+
ADRs: {N} files in docs/adr/ ({relevant ones listed})
|
|
92
|
+
Existing todo.md: {found with N items / not found}
|
|
93
|
+
Related issues: {N} open issues with overlap ({list issue numbers})
|
|
94
|
+
Learnings: {N} relevant learnings ({areas})
|
|
95
|
+
Test coverage: {strong / partial / weak in target area — details}
|
|
96
|
+
Gaps: {list any missing context}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**ASK:** "Here is the context I loaded. Provide additional context — prior refactoring attempts, external consumers, deployment constraints? (or confirm to proceed)"
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### Step 3: Spawn Parallel Researcher Sub-Agents
|
|
104
|
+
|
|
105
|
+
Spawn one sub-agent per research domain below concurrently, each following the **hatch3r-researcher agent protocol**. Each receives the confirmed refactoring brief from Step 1 (including detected dimension(s)) and the context summary from Step 2.
|
|
106
|
+
|
|
107
|
+
**Each sub-agent prompt must include:**
|
|
108
|
+
- The full confirmed refactoring brief including detected dimension(s)
|
|
109
|
+
- The project context summary from Step 2 (including test coverage assessment)
|
|
110
|
+
- Instruction to follow the **hatch3r-researcher agent protocol**
|
|
111
|
+
- The assigned mode (one per sub-agent) and depth level `deep`
|
|
112
|
+
- The detected dimension(s) as the `dimension` parameter — the researcher agent applies dimension-specific focus automatically
|
|
113
|
+
|
|
114
|
+
| Sub-Agent | Researcher Mode | Focus |
|
|
115
|
+
|-----------|----------------|-------|
|
|
116
|
+
| 1 | `current-state` | Map complexity, coupling, cohesion, test coverage, code smells, patterns |
|
|
117
|
+
| 2 | `refactoring-strategy` | Design transformations, behavioral invariants, interface contracts, effort |
|
|
118
|
+
| 3 | `risk-assessment` | Breaking changes, downstream consumers, regression hotspots, rollback strategy |
|
|
119
|
+
| 4 | `migration-path` | Phased execution plan, parallel lanes, rollback points, skill mapping |
|
|
120
|
+
|
|
121
|
+
Each sub-agent produces the structured output defined by its mode in the hatch3r-researcher agent specification. Modes `current-state` and `refactoring-strategy` apply dimension-specific focus (structural/logical/visual/migration) based on the dimension(s) passed in the brief.
|
|
122
|
+
|
|
123
|
+
Wait for all sub-agents to complete before proceeding.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### Step 4: Synthesize & Review Research
|
|
128
|
+
|
|
129
|
+
1. Present a **merged summary** combining key findings from all researchers:
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
Refactoring Summary:
|
|
133
|
+
|
|
134
|
+
Title: {title}
|
|
135
|
+
Dimension(s): {Structural / Logical / Visual / Migration}
|
|
136
|
+
Affected files: {N} files across {M} modules
|
|
137
|
+
Phases: {N} phases ({X} parallelizable)
|
|
138
|
+
Total effort: {estimate}
|
|
139
|
+
ADRs needed: {N} architectural decisions
|
|
140
|
+
Risks: {N} risks ({X} high, {Y} med, {Z} low)
|
|
141
|
+
Breaking changes: {N} ({list if any})
|
|
142
|
+
Test gaps: {N} areas need tests before refactoring
|
|
143
|
+
Prerequisites: {list — tests to add, docs to update, etc.}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
2. **Highlight conflicts** between researchers. Common conflict types:
|
|
147
|
+
- Strategy designer proposes a transformation that the risk assessor flags as too dangerous given test coverage
|
|
148
|
+
- Current state analyzer identifies coupling that the migration path planner's phase ordering doesn't account for
|
|
149
|
+
- Effort estimates from strategy designer conflict with the scope of changes identified by current state analyzer
|
|
150
|
+
- Migration path planner's skill mapping doesn't match the dimension detected in Step 1
|
|
151
|
+
|
|
152
|
+
3. For each conflict, present both sides and a recommended resolution.
|
|
153
|
+
|
|
154
|
+
**ASK:** "Here is the merged refactoring summary. Conflicts (if any) are highlighted above. Options:
|
|
155
|
+
- **Confirm** to proceed with spec and todo generation
|
|
156
|
+
- **Adjust** specific findings (tell me what to change)
|
|
157
|
+
- **Re-run** a specific researcher with updated parameters
|
|
158
|
+
- **Descope** to reduce the refactoring scope
|
|
159
|
+
- **Add prerequisite phase** (e.g., add tests before refactoring)"
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
### Step 5: Generate Refactoring Spec
|
|
164
|
+
|
|
165
|
+
From the merged researcher outputs, generate a refactoring specification document. Present all content for review before writing any files.
|
|
166
|
+
|
|
167
|
+
#### Refactoring Spec — `docs/specs/{NN}_{refactor-slug}.md`
|
|
168
|
+
|
|
169
|
+
Determine the next sequential number by scanning existing files in `docs/specs/`. Use slugified refactoring title (lowercase, hyphens).
|
|
170
|
+
|
|
171
|
+
```markdown
|
|
172
|
+
# Refactoring: {Title}
|
|
173
|
+
|
|
174
|
+
## Overview
|
|
175
|
+
|
|
176
|
+
{2-3 sentence summary of the refactoring, its motivation, and target end state}
|
|
177
|
+
|
|
178
|
+
## Scope
|
|
179
|
+
|
|
180
|
+
### In Scope
|
|
181
|
+
- {area or transformation included}
|
|
182
|
+
|
|
183
|
+
### Out of Scope
|
|
184
|
+
- {explicitly excluded to prevent scope creep}
|
|
185
|
+
|
|
186
|
+
## Current State
|
|
187
|
+
|
|
188
|
+
{From current state analyzer — summary of problems, complexity, coupling}
|
|
189
|
+
|
|
190
|
+
### Key Metrics
|
|
191
|
+
| Metric | Current | Target |
|
|
192
|
+
|--------|---------|--------|
|
|
193
|
+
| {metric — e.g., module count, coupling, complexity} | {current value} | {target value} |
|
|
194
|
+
|
|
195
|
+
## Target State
|
|
196
|
+
|
|
197
|
+
{From strategy designer — description of the desired architecture after refactoring}
|
|
198
|
+
|
|
199
|
+
## Behavioral Invariants
|
|
200
|
+
|
|
201
|
+
| # | Invariant | Verification |
|
|
202
|
+
|---|-----------|-------------|
|
|
203
|
+
| 1 | {behavior that must be preserved} | {how to verify} |
|
|
204
|
+
|
|
205
|
+
## Transformation Plan
|
|
206
|
+
|
|
207
|
+
| # | Transformation | Type | From | To |
|
|
208
|
+
|---|---------------|------|------|-----|
|
|
209
|
+
| 1 | {change} | {Extract/Inline/Restructure/Migrate} | {current} | {target} |
|
|
210
|
+
|
|
211
|
+
## Phased Execution
|
|
212
|
+
|
|
213
|
+
| Phase | Title | Scope | Skill | Effort | Dependencies |
|
|
214
|
+
|-------|-------|-------|-------|--------|-------------|
|
|
215
|
+
| 0 | {prereq} | {scope} | {skill} | {effort} | — |
|
|
216
|
+
| 1 | {phase} | {scope} | {skill} | {effort} | Phase 0 |
|
|
217
|
+
|
|
218
|
+
### Phase Details
|
|
219
|
+
{Expanded details from migration path planner — per-phase goals, files, verification}
|
|
220
|
+
|
|
221
|
+
### Parallel Lanes
|
|
222
|
+
{Which phases can execute concurrently}
|
|
223
|
+
|
|
224
|
+
### Critical Path
|
|
225
|
+
{Sequential dependency chain with total effort}
|
|
226
|
+
|
|
227
|
+
## Breaking Changes
|
|
228
|
+
|
|
229
|
+
| What Breaks | Who Is Affected | Migration Path |
|
|
230
|
+
|------------|----------------|----------------|
|
|
231
|
+
| {change} | {consumers} | {strategy} |
|
|
232
|
+
|
|
233
|
+
## Risks & Mitigations
|
|
234
|
+
|
|
235
|
+
| Risk | Likelihood | Impact | Mitigation |
|
|
236
|
+
|------|-----------|--------|------------|
|
|
237
|
+
| {risk} | {level} | {level} | {strategy} |
|
|
238
|
+
|
|
239
|
+
## Prerequisites
|
|
240
|
+
|
|
241
|
+
- [ ] {test to add before refactoring}
|
|
242
|
+
- [ ] {documentation to update}
|
|
243
|
+
- [ ] {approval to obtain}
|
|
244
|
+
|
|
245
|
+
## Completion Criteria
|
|
246
|
+
|
|
247
|
+
- [ ] All phases completed and verified
|
|
248
|
+
- [ ] All behavioral invariants confirmed via tests
|
|
249
|
+
- [ ] No regression in existing test suite
|
|
250
|
+
- [ ] Dead code removed
|
|
251
|
+
- [ ] Documentation updated
|
|
252
|
+
|
|
253
|
+
---
|
|
254
|
+
|
|
255
|
+
**Owner / Reviewers / Last updated**
|
|
256
|
+
Owner: {tbd}
|
|
257
|
+
Reviewers: {tbd}
|
|
258
|
+
Last updated: {today's date}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
If a glossary exists (`docs/specs/00_glossary.md`), reference its stable IDs where applicable. If the refactoring introduces new entities or patterns, note them for glossary update.
|
|
262
|
+
|
|
263
|
+
**ASK:** "Here is the generated refactoring spec. Review the content before I write the file:
|
|
264
|
+
- `{NN}_{refactor-slug}.md` — {phase count} phases, {transformation count} transformations, {risk count} risks
|
|
265
|
+
|
|
266
|
+
Confirm, or tell me what to adjust."
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### Step 6: Generate ADR(s) (If Applicable)
|
|
271
|
+
|
|
272
|
+
Only proceed if the refactoring involves significant architectural decisions — for example, replacing a framework, introducing a new pattern across the codebase, changing data models, or evolving API contracts. If no ADRs are needed, skip to Step 7.
|
|
273
|
+
|
|
274
|
+
From the strategy designer's output and any conflicts resolved in Step 4, create one ADR per decision.
|
|
275
|
+
|
|
276
|
+
#### ADR Format — `docs/adr/{NNNN}_{decision-slug}.md`
|
|
277
|
+
|
|
278
|
+
Determine the next sequential number by scanning existing files in `docs/adr/`. Use slugified decision titles.
|
|
279
|
+
|
|
280
|
+
```markdown
|
|
281
|
+
# ADR-{NNNN}: {Decision Title}
|
|
282
|
+
|
|
283
|
+
## Status
|
|
284
|
+
|
|
285
|
+
Proposed
|
|
286
|
+
|
|
287
|
+
## Date
|
|
288
|
+
|
|
289
|
+
{today's date}
|
|
290
|
+
|
|
291
|
+
## Context
|
|
292
|
+
|
|
293
|
+
{Why this decision is needed — the refactoring goal, the current state problem, and why a design choice must be made}
|
|
294
|
+
|
|
295
|
+
## Decision
|
|
296
|
+
|
|
297
|
+
{What was decided and why — which approach, pattern, or technology was chosen}
|
|
298
|
+
|
|
299
|
+
## Alternatives Considered
|
|
300
|
+
|
|
301
|
+
| Alternative | Pros | Cons | Why Not |
|
|
302
|
+
|-------------|------|------|---------|
|
|
303
|
+
| {option} | {pros} | {cons} | {reason} |
|
|
304
|
+
|
|
305
|
+
## Consequences
|
|
306
|
+
|
|
307
|
+
### Positive
|
|
308
|
+
- {consequence}
|
|
309
|
+
|
|
310
|
+
### Negative
|
|
311
|
+
- {consequence}
|
|
312
|
+
|
|
313
|
+
### Risks
|
|
314
|
+
- {risk}: {mitigation}
|
|
315
|
+
|
|
316
|
+
## Related
|
|
317
|
+
|
|
318
|
+
- Refactoring spec: `docs/specs/{NN}_{refactor-slug}.md`
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
**ASK:** "Here are {N} ADR(s) generated from refactoring decisions. Review before I write the files:
|
|
322
|
+
{list with titles}
|
|
323
|
+
|
|
324
|
+
Confirm, or tell me what to adjust."
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
### Step 7: Generate todo.md Entries
|
|
329
|
+
|
|
330
|
+
From the migration path planner's phased execution plan and the synthesized research, generate structured `todo.md` entries in the format that `hatch3r-board-fill` expects.
|
|
331
|
+
|
|
332
|
+
#### Entry Structure
|
|
333
|
+
|
|
334
|
+
One **epic-level entry** for the refactoring effort, followed by **individual phase entries** ordered for safe execution:
|
|
335
|
+
|
|
336
|
+
```markdown
|
|
337
|
+
- [ ] **{Refactoring title} epic**: {Motivation, target state, phase count, key transformations}. Ref: docs/specs/{NN}_{refactor-slug}.md.
|
|
338
|
+
- [ ] **Phase 0 — {Test scaffolding title}**: {What tests to add, where, acceptance criteria}. Ref: docs/specs/{NN}_{refactor-slug}.md.
|
|
339
|
+
- [ ] **Phase 1 — {Transformation title}**: {What to transform, behavioral invariants, verification criteria}. Ref: docs/specs/{NN}_{refactor-slug}.md.
|
|
340
|
+
- [ ] **Phase 2 — {Transformation title}**: {What to transform, dependencies on Phase 1, verification criteria}. Ref: docs/specs/{NN}_{refactor-slug}.md.
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
For small refactoring efforts (single phase, effort S or M), produce a single standalone entry instead of an epic.
|
|
344
|
+
|
|
345
|
+
#### Placement
|
|
346
|
+
|
|
347
|
+
Determine the appropriate priority header. Refactoring is typically P2 (important but not urgent) unless motivated by a production issue (P1) or purely aspirational improvement (P3). Place entries under the matching `## P{N} — {Label}` header.
|
|
348
|
+
|
|
349
|
+
#### If `todo.md` Already Exists
|
|
350
|
+
|
|
351
|
+
**ASK:** "todo.md already exists with {N} items. How should I add the new entries?
|
|
352
|
+
- **(a) Append** under the appropriate priority header
|
|
353
|
+
- **(b) Merge** — deduplicate against existing items and reorganize
|
|
354
|
+
- **(c) Show me the entries** and I'll place them manually"
|
|
355
|
+
|
|
356
|
+
#### If `todo.md` Does Not Exist
|
|
357
|
+
|
|
358
|
+
Create a new `todo.md` with the appropriate priority header and the new entries.
|
|
359
|
+
|
|
360
|
+
Present the drafted entries for review.
|
|
361
|
+
|
|
362
|
+
**ASK:** "Here are the todo.md entries for this refactoring ({N} items — 1 epic + {M} phases). Review before I write:
|
|
363
|
+
|
|
364
|
+
{entries}
|
|
365
|
+
|
|
366
|
+
Confirm, or tell me what to adjust."
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
### Step 8: Write All Files
|
|
371
|
+
|
|
372
|
+
After all content is confirmed:
|
|
373
|
+
|
|
374
|
+
1. Write the refactoring spec to `docs/specs/{NN}_{refactor-slug}.md`. Create the `docs/specs/` directory if it does not exist.
|
|
375
|
+
2. Write ADR(s) to `docs/adr/{NNNN}_{decision-slug}.md` (if any). Create the `docs/adr/` directory if it does not exist.
|
|
376
|
+
3. Write or update `todo.md` at the project root.
|
|
377
|
+
4. If a glossary exists and the refactoring introduces new entities or patterns, note glossary updates needed (do not modify the glossary automatically — flag for manual update or a follow-up `project-spec` run).
|
|
378
|
+
5. Present a summary of all files created or modified:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
Files Created/Updated:
|
|
382
|
+
docs/specs/
|
|
383
|
+
{NN}_{refactor-slug}.md — {phase count} phases, {transformation count} transformations
|
|
384
|
+
docs/adr/
|
|
385
|
+
{NNNN}_{decision}.md — {decision title} (if applicable)
|
|
386
|
+
...
|
|
387
|
+
todo.md — {N} entries added ({1} epic + {M} phases)
|
|
388
|
+
Glossary update needed: {yes/no — list new patterns/entities if yes}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
### Step 9 (Optional): Chain into Board-Fill
|
|
394
|
+
|
|
395
|
+
**ASK:** "All files written. Run `hatch3r-board-fill` to create GitHub issues from the new todo.md entries? (yes / not now)"
|
|
396
|
+
|
|
397
|
+
If yes, instruct the user to invoke the `hatch3r-board-fill` command. Note that board-fill will perform its own deduplication, grouping, dependency analysis, and readiness assessment on the entries.
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Error Handling
|
|
402
|
+
|
|
403
|
+
- **Sub-agent failure:** Retry the failed sub-agent once. If it fails again, present partial results from the remaining sub-agents and ask the user how to proceed (continue without that researcher's input / provide the missing information manually / abort).
|
|
404
|
+
- **Conflicting researcher outputs:** Present both options side by side with trade-offs. Ask the user to decide. Do not silently pick one.
|
|
405
|
+
- **File write failure:** Report the error and provide the full file content so the user can create the file manually.
|
|
406
|
+
- **Missing project context:** If no `hatch3r-board-shared` or `/.agents/hatch.json` exists, proceed without board context — this command does not require board configuration.
|
|
407
|
+
- **No existing specs or docs:** Proceed without spec references. Warn that the refactoring spec will be less contextualized without existing project documentation. Recommend running `hatch3r-project-spec` or `hatch3r-codebase-map` first for best results.
|
|
408
|
+
- **Duplicate detection:** If the refactoring overlaps significantly with existing todo.md items or GitHub issues found in Step 2, present the overlap and ASK whether to proceed (augment existing / replace / abort).
|
|
409
|
+
- **Weak test coverage:** If the current state analyzer finds weak test coverage in the target area, the migration path planner MUST include a Phase 0 for test scaffolding. Do not proceed with refactoring phases without adequate coverage.
|
|
410
|
+
|
|
411
|
+
## Guardrails
|
|
412
|
+
|
|
413
|
+
- **Never skip ASK checkpoints.** Every step with an ASK must pause for user confirmation.
|
|
414
|
+
- **Never write files without user review and confirmation.** All generated content is presented first.
|
|
415
|
+
- **Always delegate research to the hatch3r-researcher agent protocol.** Researcher sub-agents handle Context7 MCP, web research, and the tooling hierarchy internally.
|
|
416
|
+
- **Stay within the refactoring scope** defined by the user in Step 1. Do not expand into unrelated areas. Flag scope expansion opportunities but do not act on them without explicit approval.
|
|
417
|
+
- **todo.md must be compatible with board-fill format** — markdown checklist with bold titles, grouped by priority, referencing source specs.
|
|
418
|
+
- **ADRs use the same format as `hatch3r-project-spec`** — Status, Date, Context, Decision, Alternatives, Consequences.
|
|
419
|
+
- **Every phase must leave the codebase in a working state.** No phase may break the build, fail tests, or leave the code in an intermediate non-functional state. If a transformation cannot be split into safe phases, flag this to the user.
|
|
420
|
+
- **Behavioral invariants are non-negotiable.** Every invariant listed in the spec must have a verification strategy. If an invariant cannot be verified (no test, no assertion), add a prerequisite to create the verification first.
|
|
421
|
+
- **Phase ordering must respect dependencies.** The migration path planner's output is the source of truth for execution order. Do not reorder phases without updating dependency analysis.
|
|
422
|
+
- **Do not over-specify.** Keep the spec at the right level of detail for board-fill to create actionable issues. Avoid implementation details that belong in code.
|
|
423
|
+
- **All 4 researchers must complete before proceeding to Step 4.** Do not generate specs from partial research.
|
|
424
|
+
- **Respect the project's tooling hierarchy** for knowledge augmentation: project docs first, then codebase exploration, then Context7 MCP, then web research.
|
|
425
|
+
- **Preserve existing todo.md content.** Never overwrite or reorganize existing items without explicit user approval.
|
|
426
|
+
- **Distinguish refactoring from new features.** If the "refactoring" introduces new external behavior or capabilities, flag this to the user and recommend using `hatch3r-feature-plan` for the new behavior, with the refactoring as a prerequisite.
|