hatch3r 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +38 -1
  2. package/agents/hatch3r-a11y-auditor.md +7 -14
  3. package/agents/hatch3r-architect.md +7 -14
  4. package/agents/hatch3r-ci-watcher.md +7 -13
  5. package/agents/hatch3r-context-rules.md +5 -10
  6. package/agents/hatch3r-dependency-auditor.md +10 -19
  7. package/agents/hatch3r-devops.md +7 -16
  8. package/agents/hatch3r-docs-writer.md +7 -14
  9. package/agents/hatch3r-fixer.md +2 -8
  10. package/agents/hatch3r-implementer.md +2 -8
  11. package/agents/hatch3r-learnings-loader.md +150 -21
  12. package/agents/hatch3r-lint-fixer.md +7 -12
  13. package/agents/hatch3r-perf-profiler.md +7 -14
  14. package/agents/hatch3r-researcher.md +7 -14
  15. package/agents/hatch3r-reviewer.md +7 -13
  16. package/agents/hatch3r-security-auditor.md +7 -15
  17. package/agents/hatch3r-test-writer.md +7 -14
  18. package/agents/modes/architecture.md +44 -0
  19. package/agents/modes/boundary-analysis.md +45 -0
  20. package/agents/modes/codebase-impact.md +81 -0
  21. package/agents/modes/complexity-risk.md +40 -0
  22. package/agents/modes/coverage-analysis.md +44 -0
  23. package/agents/modes/current-state.md +52 -0
  24. package/agents/modes/feature-design.md +39 -0
  25. package/agents/modes/impact-analysis.md +45 -0
  26. package/agents/modes/library-docs.md +31 -0
  27. package/agents/modes/migration-path.md +55 -0
  28. package/agents/modes/prior-art.md +31 -0
  29. package/agents/modes/refactoring-strategy.md +55 -0
  30. package/agents/modes/regression.md +45 -0
  31. package/agents/modes/requirements-elicitation.md +68 -0
  32. package/agents/modes/risk-assessment.md +41 -0
  33. package/agents/modes/risk-prioritization.md +43 -0
  34. package/agents/modes/root-cause.md +39 -0
  35. package/agents/modes/similar-implementation.md +70 -0
  36. package/agents/modes/symptom-trace.md +39 -0
  37. package/agents/modes/test-pattern.md +61 -0
  38. package/agents/shared/external-knowledge.md +32 -0
  39. package/agents/shared/quality-charter.md +78 -0
  40. package/commands/board/pickup-azure-devops.md +4 -0
  41. package/commands/board/pickup-delegation-multi.md +3 -0
  42. package/commands/board/pickup-delegation.md +3 -0
  43. package/commands/board/pickup-github.md +4 -0
  44. package/commands/board/pickup-gitlab.md +4 -0
  45. package/commands/board/pickup-post-impl.md +8 -1
  46. package/commands/board/shared-azure-devops.md +13 -3
  47. package/commands/board/shared-github.md +1 -0
  48. package/commands/board/shared-gitlab.md +9 -2
  49. package/commands/hatch3r-agent-customize.md +5 -1
  50. package/commands/hatch3r-board-groom.md +55 -2
  51. package/commands/hatch3r-board-init.md +5 -2
  52. package/commands/hatch3r-board-shared.md +62 -2
  53. package/commands/hatch3r-command-customize.md +4 -0
  54. package/commands/hatch3r-context-health.md +22 -2
  55. package/commands/hatch3r-cost-tracking.md +14 -0
  56. package/commands/hatch3r-hooks.md +1 -1
  57. package/commands/hatch3r-learn.md +68 -2
  58. package/commands/hatch3r-quick-change.md +29 -3
  59. package/commands/hatch3r-revision.md +136 -16
  60. package/commands/hatch3r-rule-customize.md +4 -0
  61. package/commands/hatch3r-skill-customize.md +4 -0
  62. package/commands/hatch3r-workflow.md +10 -1
  63. package/dist/cli/index.js +2528 -640
  64. package/dist/cli/index.js.map +1 -1
  65. package/package.json +12 -9
  66. package/rules/hatch3r-agent-orchestration-detail.md +159 -0
  67. package/rules/hatch3r-agent-orchestration-detail.mdc +156 -0
  68. package/rules/hatch3r-agent-orchestration.md +91 -318
  69. package/rules/hatch3r-agent-orchestration.mdc +127 -149
  70. package/rules/hatch3r-code-standards.mdc +10 -2
  71. package/rules/hatch3r-component-conventions.mdc +0 -1
  72. package/rules/hatch3r-deep-context.mdc +30 -8
  73. package/rules/hatch3r-dependency-management.mdc +17 -5
  74. package/rules/hatch3r-i18n.mdc +0 -1
  75. package/rules/hatch3r-migrations.mdc +12 -1
  76. package/rules/hatch3r-observability.mdc +289 -0
  77. package/rules/hatch3r-security-patterns.mdc +11 -0
  78. package/rules/hatch3r-testing.mdc +1 -1
  79. package/rules/hatch3r-theming.mdc +0 -1
  80. package/rules/hatch3r-tooling-hierarchy.mdc +18 -4
  81. package/skills/hatch3r-agent-customize/SKILL.md +4 -72
  82. package/skills/hatch3r-command-customize/SKILL.md +4 -62
  83. package/skills/hatch3r-customize/SKILL.md +117 -0
  84. package/skills/hatch3r-dep-audit/SKILL.md +1 -1
  85. package/skills/hatch3r-rule-customize/SKILL.md +4 -65
  86. package/skills/hatch3r-skill-customize/SKILL.md +4 -62
@@ -0,0 +1,78 @@
1
+ ---
2
+ id: shared-quality-charter
3
+ type: reference
4
+ description: Shared quality charter for all agents — behavioral standards for senior-engineer-quality output.
5
+ ---
6
+
7
+ ## Agent Quality Charter
8
+
9
+ All agents operating under hatch3r should embody these behavioral standards. This charter is the single source of truth for agent conduct — referenced by content artifacts and verified by the weekly audit cycle.
10
+
11
+ ### 1. Express Confidence Levels
12
+
13
+ Rate every recommendation and decision as **high**, **medium**, or **low** confidence:
14
+
15
+ - **High:** Verified against current code and documentation. You read the specific file, traced the logic, and confirmed the behavior.
16
+ - **Medium:** Based on established patterns and conventions but not fully verified against the specific code path. Likely correct but could have edge cases.
17
+ - **Low:** Best professional judgment based on general principles. Recommend human review before acting on this.
18
+
19
+ When confidence is low, say so explicitly. "I believe this is correct but recommend verifying because..." is more valuable than false certainty.
20
+
21
+ ### 2. Use Current Information First
22
+
23
+ Follow the tooling hierarchy without exception:
24
+
25
+ 1. **Project specs and documentation** (`docs/specs/`, `docs/adr/`, `docs/process/`)
26
+ 2. **Codebase search** (grep, file reading, understanding existing code)
27
+ 3. **Library documentation** (Context7 MCP for up-to-date library docs)
28
+ 4. **Web research** (Brave Search MCP or equivalent for broader context)
29
+
30
+ Never rely solely on training data for technical decisions. Libraries change APIs, frameworks deprecate features, best practices evolve. Always verify against current sources before recommending.
31
+
32
+ ### 3. Question Unclear Requirements
33
+
34
+ Before building anything, verify that the requirements are clear and well-founded:
35
+
36
+ - If a requirement is ambiguous, ask for clarification rather than guessing.
37
+ - If a requirement seems misguided (solving the wrong problem, using an inappropriate pattern), raise the concern before implementing. Building the wrong thing well is worse than asking a clarifying question.
38
+ - Frame challenges constructively: "Before I implement this, I want to confirm the approach because [specific concern]."
39
+
40
+ ### 4. Report Root Causes
41
+
42
+ When identifying issues or debugging problems, trace to the root cause:
43
+
44
+ - "Missing error handling in function X" is a **symptom**.
45
+ - "No error strategy defined at the architecture level, causing inconsistent handling across 12 functions" is the **root cause**.
46
+
47
+ Report both the symptom (what you observed) and the root cause (why it exists). If you can only identify the symptom, state that explicitly and rate confidence as medium.
48
+
49
+ ### 5. Consider Multiple Stakeholders
50
+
51
+ Every recommendation should account for its impact on:
52
+
53
+ - **End user** — How does this affect the person using the product?
54
+ - **Maintaining developer** — Will the next developer understand this code in 6 months?
55
+ - **Team lead** — Does this align with project conventions and governance?
56
+ - **Ops team** — Is this deployable, monitorable, and debuggable in production?
57
+
58
+ When stakeholder interests conflict, note the tradeoff explicitly and recommend based on the project's stated priorities.
59
+
60
+ ### 6. Fail Gracefully
61
+
62
+ When prerequisites are missing, inputs are invalid, or unexpected conditions arise:
63
+
64
+ - Produce clear, actionable error messages explaining what is needed and how to provide it.
65
+ - Never fail silently — silent failures are the hardest bugs to diagnose.
66
+ - Provide recovery guidance: "To fix this, run X" or "This requires Y to be configured first."
67
+ - If partial results are possible and useful, provide them with a clear note about what is missing.
68
+
69
+ ### 7. Include Measurable Criteria
70
+
71
+ Where possible, state acceptance criteria in measurable, verifiable terms:
72
+
73
+ - **Measurable:** "All API endpoints return structured error responses with status code, message, and request ID."
74
+ - **Not measurable:** "Improve error handling."
75
+ - **Measurable:** "Page load time under 2 seconds on 3G connection for the 5 most visited pages."
76
+ - **Not measurable:** "Make the app faster."
77
+
78
+ When a recommendation cannot be quantified (e.g., "improve code readability"), provide a concrete before/after example instead.
@@ -31,6 +31,10 @@ Platform-specific procedures for Azure DevOps. Referenced from `hatch3r-board-pi
31
31
  **Open PRs:**
32
32
  - `az repos pr list --org https://dev.azure.com/{namespace} --project {project} --status active`.
33
33
 
34
+ **Abandoned PRs for selected work item (abandoned work detection):**
35
+ - `az repos pr list --org https://dev.azure.com/{namespace} --project {project} --status abandoned` — check if any abandoned PRs are linked to this work item.
36
+ - If found: Surface to the user: "Note: PR #{M} was abandoned for work item #{N}. The previous work may be partially relevant. Options: (a) review the abandoned PR branch, (b) start fresh, (c) pick a different work item."
37
+
34
38
  ---
35
39
 
36
40
  ## Step 4: Update Issue Status — Azure DevOps
@@ -80,6 +80,7 @@ For each dependency level, starting at Level 1:
80
80
  - Relevant learnings from `.agents/learnings/` (from Step 6.pre).
81
81
  - Instruction to use GitHub MCP for issue reads, and follow the project's tooling hierarchy for external knowledge augmentation.
82
82
  - Explicit instruction: do NOT create branches, commits, or PRs.
83
+ - Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
83
84
 
84
85
  3. **Await all sub-agents in the current level.** Collect their structured results (files changed, tests written, issues encountered).
85
86
 
@@ -147,6 +148,7 @@ For each dependency level, starting at Level 1:
147
148
  - All `scope: always` rule directives from `.agents/rules/` — subagents do not inherit rules automatically.
148
149
  - Relevant learnings from `.agents/learnings/` (from Step 6.pre).
149
150
  - Explicit instruction: do NOT create branches, commits, or PRs.
151
+ - Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
150
152
 
151
153
  3. **Await all sub-agents in the current level.** Collect their structured results (files changed, tests written, issues encountered).
152
154
 
@@ -176,6 +178,7 @@ After all implementations complete, run the two-stage quality pipeline across th
176
178
  - **Reference conventions** from Step 6c.2 (if available) — so the fixer maintains established patterns when applying fixes.
177
179
  3. Re-spawn **`hatch3r-reviewer`** to verify fixes.
178
180
  4. Repeat steps 2-3 for a maximum of **3 iterations** until the reviewer reports 0 Critical + 0 Warning findings.
181
+ After each reviewer iteration, assess the reviewer's findings confidence: if the reviewer rates any finding as low-confidence, flag it separately in the ASK prompt so the user can prioritize human review of uncertain findings.
179
182
  5. If still not clean after 3 iterations, **ASK** the user how to proceed.
180
183
 
181
184
  **Stage 2 — Final Quality (parallel, after review loop is clean):**
@@ -58,6 +58,7 @@ The implementer sub-agent prompt MUST include:
58
58
  - All `scope: always` rule directives from `.agents/rules/` — subagents do not inherit rules automatically.
59
59
  - Relevant learnings from `.agents/learnings/` (from Step 6.pre).
60
60
  - Explicit instruction: do NOT create branches, commits, or PRs.
61
+ - Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
61
62
 
62
63
  Await the implementer sub-agent. Collect its structured result (files changed, tests written, issues encountered).
63
64
 
@@ -73,6 +74,7 @@ After implementation completes, run the two-stage quality pipeline. Use the Task
73
74
  - **Reference conventions** from Step 6a.1 (if available) — so the fixer maintains established patterns when applying fixes.
74
75
  3. Re-spawn **`hatch3r-reviewer`** to verify fixes.
75
76
  4. Repeat steps 2-3 for a maximum of **3 iterations** until the reviewer reports 0 Critical + 0 Warning findings.
77
+ After each reviewer iteration, assess the reviewer's findings confidence: if the reviewer rates any finding as low-confidence, flag it separately in the ASK prompt so the user can prioritize human review of uncertain findings.
76
78
  5. If still not clean after 3 iterations, **ASK** the user how to proceed.
77
79
 
78
80
  **Stage 2 — Final Quality (parallel, after review loop is clean):**
@@ -96,5 +98,6 @@ Each specialist sub-agent prompt MUST include:
96
98
  - All `scope: always` rule directives from `.agents/rules/` (subagents do not inherit rules automatically).
97
99
  - The diff or file changes to review.
98
100
  - The issue's acceptance criteria.
101
+ - Confidence expression requirement: rate every recommendation and finding as high/medium/low confidence per the quality charter (`agents/shared/quality-charter.md`). High = verified against current code. Medium = pattern-based, not fully verified. Low = best judgment, recommend human review.
99
102
 
100
103
  Await all specialist sub-agents. Apply their feedback (fixes, additional tests, documentation updates) before proceeding to Step 7.
@@ -31,6 +31,10 @@ Platform-specific procedures for GitHub. Referenced from `hatch3r-board-pickup`.
31
31
  **Open PRs:**
32
32
  - `gh pr list -R {owner}/{repo} --state open` (fall back to `search_pull_requests` MCP).
33
33
 
34
+ **Closed PRs for selected issue (abandoned work detection):**
35
+ - `gh pr list -R {owner}/{repo} --state closed --search "closes #{N}"` — check if any recently closed (not merged) PRs reference this issue.
36
+ - If found: Surface to the user: "Note: PR #{M} was closed without merge for issue #{N}. The previous work may be partially relevant. Options: (a) review the closed PR branch, (b) start fresh, (c) pick a different issue."
37
+
34
38
  ---
35
39
 
36
40
  ## Step 4: Update Issue Status — GitHub
@@ -31,6 +31,10 @@ Platform-specific procedures for GitLab. Referenced from `hatch3r-board-pickup`.
31
31
  **Open MRs:**
32
32
  - `glab mr list -R {namespace}/{project} --state opened`.
33
33
 
34
+ **Closed MRs for selected issue (abandoned work detection):**
35
+ - `glab mr list -R {namespace}/{project} --state closed` — check if any recently closed (not merged) MRs reference `Closes #{N}`.
36
+ - If found: Surface to the user: "Note: MR !{M} was closed without merge for issue #{N}. The previous work may be partially relevant. Options: (a) review the closed MR branch, (b) start fresh, (c) pick a different issue."
37
+
34
38
  ---
35
39
 
36
40
  ## Step 4: Update Issue Status — GitLab
@@ -16,6 +16,8 @@ Run the project's quality checks (linting, type checking, tests). Refer to the p
16
16
 
17
17
  Verify: all AC met, tests passing, no lint errors, dead code removed, project-specific invariants respected.
18
18
 
19
+ Rate confidence in quality verification: high (all checks pass with comprehensive coverage), medium (checks pass but coverage gaps exist), low (checks pass minimally, recommend additional human review).
20
+
19
21
  ---
20
22
 
21
23
  ## Step 7a: Commit & Push
@@ -83,7 +85,12 @@ Follow the project's PR/MR creation skill or conventions:
83
85
 
84
86
  1. If all sub-issues addressed, confirm the PR body uses `Closes #<epic-number>` so the epic will auto-close on merge and transition to Done.
85
87
  2. Remind user `Closes #N` auto-closes on merge.
86
- 3. If partial:
88
+ 3. **Post-merge board state advisory:** After merge, `Closes #N` will auto-close the issue, but label and board status updates to `status:done` / "Done" depend on platform automation:
89
+ - **GitHub:** Automatic IF the Projects V2 "Item closed" workflow is enabled (verify in Project > Workflows). Labels are NOT auto-updated — `status:in-review` remains on the closed issue.
90
+ - **Azure DevOps:** Ensure the "Complete linked work items after merging" checkbox is checked during PR completion. State transitions to "Closed" only when this option is selected.
91
+ - **GitLab:** Labels are NOT updated on auto-close. `status::in-review` remains. Consider setting up a CI pipeline trigger on issue close events for automated cleanup.
92
+ - If automation is not configured, `board-groom` with the `health-fix` action will detect and fix the drift during the next grooming session.
93
+ 4. If partial:
87
94
 
88
95
  **ASK:** "PR created. N remaining sub-issues on epic #X. Continue with next sub-issue or stop?"
89
96
 
@@ -86,7 +86,11 @@ Azure Boards syncs via Work Item State changes. There is no separate "add to boa
86
86
  | `status:in-progress` | `Active` |
87
87
  | `status:in-review` | `Resolved` |
88
88
  | `status:blocked` | `New` |
89
- | (done) | `Closed` |
89
+ | `status:done` | `Closed` |
90
+
91
+ **Known limitation — Ready vs. In Progress granularity:** Both `status:ready` and `status:in-progress` map to the `Active` Work Item State because Azure DevOps built-in process templates (Agile, Scrum, CMMI) do not include a "Ready" state. The distinction is preserved in Work Item Tags (e.g., tag `status:ready` vs. `status:in-progress`), which hatch3r board commands always set alongside the State update. For projects that need board-level distinction:
92
+ - **Custom process template:** Add a "Ready" state to the work item type in your Azure DevOps process template. Update the mapping above accordingly.
93
+ - **Board column mapping:** Configure Azure Boards to use tag-based swim lanes or column splits to distinguish "Ready" from "In Progress" within the "Active" column.
90
94
 
91
95
  **Steps for each work item to sync:**
92
96
 
@@ -110,8 +114,14 @@ Azure Boards syncs via Work Item State changes. There is no separate "add to boa
110
114
  `az boards work-item relation add --id {child_id} --relation-type "System.LinkTypes.Hierarchy-Reverse" --target-id {parent_id}`.
111
115
  Record link status as `native`.
112
116
 
113
- 2. **Fallback 1 — Comment trace:**
114
- If relation add fails:
117
+ 2. **Fallback 1 — Advisory body-reference:**
118
+ If relation add fails, establish an advisory link via work item descriptions:
119
+ - Read the parent work item description. Append a sub-issue checklist entry: `- [ ] #{child} {title}` to the parent's description via `az boards work-item update --id {epic} --description "..."`.
120
+ - Read the child work item description. Prepend `> Parent: #{epic}` to the child's description via `az boards work-item update --id {child} --description "..."`.
121
+ - Record link status as `advisory`.
122
+
123
+ 3. **Fallback 2 — Comment trace:**
124
+ If both primary and Fallback 1 fail:
115
125
  `az boards work-item update --id {epic} --discussion "Sub-issue: #{child} — {title} (linking failed)"`.
116
126
  Record link status as `comment-only`.
117
127
 
@@ -95,6 +95,7 @@ Read the mapping from `board.statusOptions` in `.agents/hatch.json`:
95
95
  | `status:ready` | `board.statusOptions.ready` |
96
96
  | `status:in-progress` | `board.statusOptions.inProgress` |
97
97
  | `status:in-review` | `board.statusOptions.inReview` |
98
+ | `status:done` | `board.statusOptions.done` |
98
99
  | `status:blocked` | `board.statusOptions.backlog` |
99
100
 
100
101
  **Steps for each issue to sync (gh CLI primary):**
@@ -83,6 +83,7 @@ GitLab board lists are label-based. Each status corresponds to a scoped label:
83
83
  | `status:ready` | `status::ready` |
84
84
  | `status:in-progress` | `status::in-progress` |
85
85
  | `status:in-review` | `status::in-review` |
86
+ | `status:done` | `status::done` |
86
87
  | `status:blocked` | `status::blocked` |
87
88
 
88
89
  **Steps for each issue to sync:**
@@ -104,8 +105,14 @@ GitLab board lists are label-based. Each status corresponds to a scoped label:
104
105
  `glab api projects/{project_id}/issues/{parent_iid}/links --method POST --field target_project_id={project_id} --field target_issue_iid={child_iid}`.
105
106
  Record link status as `native`.
106
107
 
107
- 2. **Fallback 1 — Comment trace:**
108
- If API linking fails:
108
+ 2. **Fallback 1 — Advisory body-reference:**
109
+ If API linking fails, establish an advisory link via issue descriptions:
110
+ - Read the parent epic body. Add a sub-issue checklist entry: `- [ ] #{child} {title}` to the epic's body via `glab issue update {epic} -R {namespace}/{project} --description "..."`.
111
+ - Read the child issue body. Prepend `> Parent: #{epic}` to the child's body via `glab issue update {child} -R {namespace}/{project} --description "..."`.
112
+ - Record link status as `advisory`.
113
+
114
+ 3. **Fallback 2 — Comment trace:**
115
+ If both primary and Fallback 1 fail:
109
116
  `glab issue note {epic} -R {namespace}/{project} --message "Sub-issue: #{child} — {title} (linking failed)"`.
110
117
  Record link status as `comment-only`.
111
118
 
@@ -153,7 +153,7 @@ Some agents have `protected: true` in their canonical frontmatter. This field ma
153
153
 
154
154
  ```yaml
155
155
  ---
156
- id: hatch3r-reviewer
156
+ id: hatch3r-example-agent
157
157
  description: Expert code reviewer for the project...
158
158
  protected: true
159
159
  model: standard
@@ -175,6 +175,10 @@ The `protected` field is set in the canonical agent definition and cannot be ove
175
175
  - Invalid YAML produces warnings but does not prevent agent execution (graceful degradation)
176
176
  - Customization files should be committed to the repository
177
177
 
178
+ ## Unified Skill
179
+
180
+ This command's workflow is handled by the `hatch3r-customize` skill with `type: agent`. The skill provides root-cause analysis, multi-stakeholder review, and quality gate steps that extend the workflow above. Invoke the skill directly or use this command for the agent-specific reference documentation (model resolution, protected agents, per-agent examples).
181
+
178
182
  ## Related
179
183
 
180
184
  - Skill customization: `hatch3r-skill-customize` command
@@ -173,7 +173,23 @@ For each epic, compare the sub-issue references in the epic body (checklist item
173
173
 
174
174
  If `board.projectNumber` is configured, compare label-based status (`status:*` labels) against board column status via `gh project item-list {board.projectNumber} --owner {board.owner} --format json` (GitHub) or equivalent platform call. Flag issues where the label status and board column status diverge.
175
175
 
176
- #### 3l. Present Refinement Summary
176
+ #### 3l. Orphaned In-Review Detection
177
+
178
+ For each open issue with `status:in-review`:
179
+
180
+ 1. **GitHub:** Check if any open PR body references `Closes #N` for this issue: `gh pr list -R {owner}/{repo} --state open --json number,body` — parse for `Closes #{N}`.
181
+ 2. **Azure DevOps:** Check if any active PR is linked to this work item: `az repos pr list --org https://dev.azure.com/{namespace} --project {project} --status active` — check work item relations.
182
+ 3. **GitLab:** Check if any open MR description references `Closes #N` for this issue: `glab mr list -R {namespace}/{project} --state opened` — parse descriptions for `Closes #{N}`.
183
+
184
+ Also check for closed issues with `status:in-review` (or any non-`status:done` status label) — these are issues that were auto-closed on PR merge but whose labels and board status were not updated to "Done" (see Post-Merge Terminal State in `hatch3r-board-shared`).
185
+
186
+ Flag two categories:
187
+ - **Orphaned in-review (open):** Open issues with `status:in-review` but no associated open PR/MR — likely caused by PR closure without merge.
188
+ - **Stale in-review (closed):** Closed issues still labeled `status:in-review` — should be `status:done` with board status "Done".
189
+
190
+ ---
191
+
192
+ #### 3m. Present Refinement Summary
177
193
 
178
194
  Present findings grouped by category:
179
195
 
@@ -189,6 +205,7 @@ Board Health:
189
205
  Epic ordering discrepancies: E epics
190
206
  Unlinked sub-issues: U issues (non-native links)
191
207
  Board sync drift: V issues (label/board status mismatch)
208
+ Orphaned in-review: O issues (open with no PR/MR), S issues (closed but not status:done)
192
209
 
193
210
  Grooming Opportunities:
194
211
  Re-prioritize candidates: R issues (priority/risk misalignment, priority inflation)
@@ -448,7 +465,7 @@ Link Fix Candidates:
448
465
 
449
466
  #### 4i. Health Fix (Board Health Remediation)
450
467
 
451
- Fix structural gaps detected in Step 3b (missing metadata).
468
+ Fix structural gaps detected in Step 3b (missing metadata), board sync drift detected in Step 3k, and orphaned in-review issues detected in Step 3l.
452
469
 
453
470
  1. For each issue with missing required labels, infer the missing labels from issue content using the same classification tables as `board-fill` Step 3:
454
471
  - Missing `type:*` → infer from title/body keywords.
@@ -475,6 +492,42 @@ Health Fix — Missing Metadata:
475
492
  - **Azure DevOps:** `az boards work-item update --id N --fields "System.Tags=..."`.
476
493
  - **GitLab:** `glab issue update N --label "..."`.
477
494
 
495
+ 4. **Board sync drift remediation:** For each issue flagged in Step 3k where label status and board column status diverge:
496
+
497
+ - **Labels are source of truth.** Update the board to match the label.
498
+ - Use the platform-specific Board Sync Procedure to set the board status to the value corresponding to the issue's current status label.
499
+ - **Special case — closed issue with `status:in-review`:** If the issue is closed (state = closed) but the label is `status:in-review` and the board shows "In Review":
500
+ 1. Replace `status:in-review` with `status:done` on the issue.
501
+ 2. Sync board status to "Done" using `board.statusOptions.done`.
502
+ - Present drift fixes in the batch:
503
+
504
+ ```
505
+ Board Sync Drift Remediation:
506
+
507
+ | # | Title | Label Status | Board Status | Action |
508
+ |---|-------|-------------|--------------|--------|
509
+ | #N | {title} | status:ready | In Progress | Sync board -> Ready |
510
+ | #M | {title} | status:in-review (closed) | In Review | Label -> status:done, board -> Done |
511
+ ```
512
+
513
+ No separate ASK — drift fixes are presented alongside the metadata fixes in the same Health Fix confirmation prompt.
514
+
515
+ 5. **Orphaned in-review remediation:** For each issue flagged in Step 3l:
516
+
517
+ a. **Closed issue with `status:in-review`** (stale in-review): Suggest replacing `status:in-review` with `status:done` and syncing board to "Done". This is the post-merge terminal state that was not reached (see Post-Merge Terminal State in `hatch3r-board-shared`).
518
+ b. **Open issue with `status:in-review` but no open PR/MR** (orphaned in-review): Present the issue with context (last PR if any, time since last update). Suggest `status:ready` (if work appears abandoned) or `status:in-progress` (if rework is likely).
519
+
520
+ ```
521
+ Orphaned In-Review Remediation:
522
+
523
+ | # | Title | State | Last PR | Suggested Status | Reason |
524
+ |---|-------|-------|---------|------------------|--------|
525
+ | #N | {title} | closed | PR #M (merged) | status:done | Closed issue still labeled in-review |
526
+ | #K | {title} | open | PR #J (closed, not merged) | status:ready | PR closed 14 days ago, no replacement |
527
+ ```
528
+
529
+ **ASK:** "Confirm or adjust status changes for in-review issues. Enter per-issue decisions (e.g., '#N -> done, #K -> in-progress'), or 'confirm all' / 'skip'."
530
+
478
531
  ---
479
532
 
480
533
  ### Step 5: Readiness Re-evaluation
@@ -252,6 +252,7 @@ Execute all planned mutations in sequence. No further questions unless a mutatio
252
252
  4. Ensure these status options exist on the field: **Backlog**, **Ready**, **In Progress**, **In Review**, **Done**.
253
253
  - For missing options, use the `updateProjectV2Field` mutation (or the appropriate mutation for adding options to a single-select field) to add them.
254
254
  5. Capture the field ID and each option's ID.
255
+ 6. **Verify built-in "Done on close" automation:** After board creation, check the Projects V2 built-in workflows. Navigate to Project settings > Workflows > "Item closed" and verify it is enabled with Status mapped to "Done". Also verify "Pull request merged" maps Status to "Done". These workflows are on by default for UI-created projects but may not be enabled for API-created projects. Without these workflows, the board status will remain "In Review" after PR merge until `board-groom` detects the drift.
255
256
 
256
257
  **If platform is `azure-devops`:**
257
258
 
@@ -262,6 +263,7 @@ Execute all planned mutations in sequence. No further questions unless a mutatio
262
263
  2. Map hatch3r statuses to Work Item States: **Backlog** → `New`, **Ready** → `Active`, **In Progress** → `Active`, **In Review** → `Resolved`, **Done** → `Closed`.
263
264
  3. If using a custom process, verify these states exist. Azure DevOps built-in processes (Agile, Scrum, CMMI) include these states by default.
264
265
  4. Store the state mapping in `board.statusOptions` for use by other board commands.
266
+ 5. **Note — Ready vs. In Progress:** Azure DevOps built-in processes map both "Ready" and "In Progress" to the `Active` state. The distinction is maintained via hatch3r tags on work items. For board-level visibility, consider configuring Azure Boards column splits: in the Board Settings, split the "Active" column into "Active - Ready" and "Active - In Progress" using tag-based rules. Projects with custom Azure DevOps process templates can alternatively add a "Ready" state to the work item type.
265
267
 
266
268
  **If platform is `gitlab`:**
267
269
 
@@ -270,8 +272,9 @@ Execute all planned mutations in sequence. No further questions unless a mutatio
270
272
  glab api projects/{project_id}/boards/{board_id}/lists --method POST --field label_id={label_id}
271
273
  ```
272
274
  2. Create scoped labels for each status first (see Step 2.3), then create board lists referencing those labels.
273
- 3. Required board lists: **Backlog** (`status::triage`), **Ready** (`status::ready`), **In Progress** (`status::in-progress`), **In Review** (`status::in-review`).
275
+ 3. Required board lists: **Backlog** (`status::triage`), **Ready** (`status::ready`), **In Progress** (`status::in-progress`), **In Review** (`status::in-review`), **Done** (`status::done`).
274
276
  4. Store the board list IDs in `board.statusOptions`.
277
+ 5. **Note — Labels not auto-updated on close:** GitLab does not update labels when an issue is auto-closed via `Closes #N`. The `status::in-review` scoped label will remain on closed issues. This drift is detected and fixed by `board-groom` during the `health-fix` action. For automated cleanup, consider setting up a GitLab CI pipeline trigger on issue close events to apply `status::done`. Note: scoped labels require GitLab **Premium or Ultimate** tier.
275
278
 
276
279
  #### 2.3: Create Label Taxonomy
277
280
 
@@ -282,7 +285,7 @@ Execute all planned mutations in sequence. No further questions unless a mutatio
282
285
  |-----------|--------|
283
286
  | Type | `type:bug`, `type:feature`, `type:refactor`, `type:qa`, `type:docs`, `type:infra` |
284
287
  | Executor | `executor:agent`, `executor:human`, `executor:hybrid` |
285
- | Status | `status:triage`, `status:ready`, `status:in-progress`, `status:in-review`, `status:blocked` |
288
+ | Status | `status:triage`, `status:ready`, `status:in-progress`, `status:in-review`, `status:done`, `status:blocked` |
286
289
  | Priority | `priority:p0`, `priority:p1`, `priority:p2`, `priority:p3` |
287
290
  | Risk | `risk:low`, `risk:med`, `risk:high` |
288
291
  | Meta | `meta:board-overview`, `has-dependencies` |
@@ -14,6 +14,31 @@ This command provides shared context and procedures for board commands. It does
14
14
 
15
15
  ---
16
16
 
17
+ ## Prerequisite Check (run at the start of every board command)
18
+
19
+ Before reading configuration, validate that prerequisites are met. If any check fails, stop immediately with an actionable error message.
20
+
21
+ 1. **hatch.json exists:** If `.agents/hatch.json` is missing or unreadable, stop with:
22
+ > "Board commands require a hatch3r project. Run `npx hatch3r init` to set up your project first."
23
+
24
+ 2. **owner/repo configured:** If both top-level `owner`/`repo` and `board.owner`/`board.repo` are empty, stop with:
25
+ > "Board commands require owner and repo. Run `npx hatch3r config` to set your repository identity, or provide them in `.agents/hatch.json` under the top-level `owner` and `repo` fields."
26
+
27
+ 3. **Platform authentication:** Verify CLI authentication for the configured platform:
28
+ - **GitHub:** Run `gh auth status`. If it fails, stop with: "GitHub CLI not authenticated. Run `gh auth login` and ensure your PAT has the `project` scope for Projects V2 access. See: https://docs.github.com/en/issues/planning-and-tracking-with-projects"
29
+ - **Azure DevOps:** Run `az account show`. If it fails, stop with: "Azure CLI not authenticated. Run `az login` or set AZURE_DEVOPS_PAT. Ensure access to organization `{namespace}`."
30
+ - **GitLab:** Run `glab auth status`. If it fails, stop with: "GitLab CLI not authenticated. Run `glab auth login` or set GITLAB_TOKEN. Ensure access to project `{namespace}/{project}`."
31
+
32
+ 4. **projectNumber set (for commands other than board-init):** For `board-fill`, `board-groom`, `board-pickup`, and `board-refresh`, if `board.projectNumber` is null, stop with:
33
+ > "No project board configured. Run the `board-init` command first to create or connect a project board. This sets up the board.projectNumber in `.agents/hatch.json`."
34
+
35
+ 5. **GitHub PAT project scope (GitHub only, for board-init/fill/groom/pickup):** If GitHub mutations fail with permission errors, surface:
36
+ > "GitHub Projects V2 requires the `project` scope on your PAT. Run `gh auth refresh -s project` to add it. Classic PATs need `admin:org` for org-owned projects."
37
+
38
+ Report each failed prerequisite with the specific fix command. Do not proceed past the first failure.
39
+
40
+ ---
41
+
17
42
  ## Board Configuration
18
43
 
19
44
  All board commands read project-specific configuration from `.agents/hatch.json`. The GitHub owner and repo are defined at the top level (`owner`, `repo`). Board-specific configuration (Projects v2 IDs, label taxonomy, branch conventions, area labels) lives under the `board` key. **Read `.agents/hatch.json` at the start of every run and cache both top-level and `board` config for the duration.**
@@ -40,7 +65,7 @@ All board commands read project-specific configuration from `.agents/hatch.json`
40
65
  "labels": {
41
66
  "types": ["type:bug", "type:feature", "type:refactor", "type:qa", "type:docs", "type:infra"],
42
67
  "executors": ["executor:agent", "executor:human", "executor:hybrid"],
43
- "statuses": ["status:triage", "status:ready", "status:in-progress", "status:in-review", "status:blocked"],
68
+ "statuses": ["status:triage", "status:ready", "status:in-progress", "status:in-review", "status:done", "status:blocked"],
44
69
  "meta": ["meta:board-overview"]
45
70
  },
46
71
  "branchConvention": "{type}/{short-description}",
@@ -104,7 +129,7 @@ Cache link status per child (`native` / `advisory` / `comment-only`) in the run
104
129
  Board sync is **MANDATORY**, not optional. The following rules override any "skip if null" or "skip silently" language elsewhere when the board is configured (GitHub: `board.projectNumber` set; Azure DevOps: project configured; GitLab: board configured).
105
130
 
106
131
  1. **Every issue/work item created or updated by a board command MUST be synced to the board — no exceptions.** This includes newly created issues, status changes, label updates, and any mutation that affects board state. Skipping sync for any item is a violation of this policy.
107
- 2. **Status MUST be updated after every status-changing operation.** The four canonical statuses — Ready, In Progress, In Review, Done — must be reflected on the board immediately after the corresponding label change. Do not batch status updates to "later" or defer them. See the platform sub-files for platform-specific status update commands.
132
+ 2. **Status MUST be updated after every status-changing operation.** The five canonical statuses — Ready, In Progress, In Review, Done, Blocked — must be reflected on the board immediately after the corresponding label change. Do not batch status updates to "later" or defer them. See the platform sub-files for platform-specific status update commands.
108
133
  3. **All available board fields (priority, sprint, area, iteration) MUST be populated when the data is available.** Never leave a board field empty if the information exists in the issue's labels, body, or metadata.
109
134
  4. **Board overview dashboard MUST be regenerated after any batch of issue operations.** This is in addition to the per-run regeneration rule — if a board command performs multiple batches of mutations, the dashboard must reflect the final state.
110
135
  5. **Fallback: never silently skip sync.** See platform sub-files for escalation paths. Silent skipping is prohibited.
@@ -113,6 +138,35 @@ Board sync is **MANDATORY**, not optional. The following rules override any "ski
113
138
 
114
139
  ---
115
140
 
141
+ ## Post-Merge Terminal State
142
+
143
+ When a PR/MR merges and `Closes #N` auto-closes the referenced issues, the board item lifecycle must reach its terminal state. The `status:in-review` label should be replaced with `status:done`, and the board status should be set to "Done" using `board.statusOptions.done`.
144
+
145
+ **Platform-specific behavior and recommendations:**
146
+
147
+ - **GitHub:** The built-in Projects V2 "Item closed" workflow sets the Status field to "Done" when an issue is closed. This workflow is enabled by default for projects created via the GitHub UI, but projects created via API (as `board-init` does) may not have it enabled. **Verify** the workflow is active: Project settings > Workflows > "Item closed" > confirm Status maps to "Done". If disabled, enable it. Without this workflow, the board status will remain "In Review" until `board-groom` detects and fixes the drift. GitHub does NOT auto-update labels on close — the `status:in-review` label remains on the closed issue.
148
+ - **Azure DevOps:** Work item auto-transition to "Closed" requires the **"Complete linked work items after merging"** checkbox during PR completion. This is opt-in per PR (not automatic by default). ADO also supports `Fixes #N` / `Resolves #N` syntax in PR descriptions for state transitions. **Recommend** checking this option consistently, or configuring it as the user's default.
149
+ - **GitLab:** Labels are NOT updated on auto-close. The `status::in-review` scoped label remains on the closed issue. GitLab does not have a built-in "set label on close" automation. The `status::done` label must be applied manually, via a CI pipeline trigger on issue close events, or will be caught and fixed during `board-groom` drift remediation. Note: scoped labels (`status::done`) require GitLab **Premium or Ultimate** tier.
150
+
151
+ Board commands that detect closed issues with `status:in-review` (or any non-`status:done` status label) should treat this as drift and remediate per the platform-specific sync procedure.
152
+
153
+ ---
154
+
155
+ ## PR Closed Without Merge
156
+
157
+ When a PR/MR is closed without merging, the referenced issues remain open with `status:in-review`. This is drift that must be resolved:
158
+
159
+ 1. **Expected behavior:** Issues should revert to:
160
+ - `status:in-progress` — if the developer intends to continue work on a different branch or rework the changes.
161
+ - `status:ready` — if the work is abandoned and the issue should return to the backlog for future pickup.
162
+ 2. **Board sync:** The board status should be updated to match the new label ("In Progress" or "Ready").
163
+ 3. **Detection:** `board-groom` Step 3l detects orphaned `status:in-review` issues (those with no open PR/MR referencing them). The user decides the target state during grooming.
164
+ 4. **Collision detection:** During `board-pickup` Step 3, if collision detection finds a closed-without-merge PR for the selected issue, surface this context to the user so they can decide whether to reuse the branch, start fresh, or pick a different issue.
165
+
166
+ This situation is NOT automatically remediated because the correct target state depends on developer intent. Board commands surface it as a diagnostic for user decision.
167
+
168
+ ---
169
+
116
170
  ## End-of-Run Reconciliation Procedure
117
171
 
118
172
  Every mutating board command (`board-fill`, `board-groom`, `board-pickup`) runs this procedure as its final step before the summary output. It catches silent failures and drift accumulated during the run.
@@ -121,6 +175,11 @@ Every mutating board command (`board-fill`, `board-groom`, `board-pickup`) runs
121
175
  2. **Sub-issue link verification:** Review `link_results` in the run cache. For links recorded as `advisory`, retry the platform-specific primary link method once to upgrade to `native`. Report all non-native links (`advisory` / `comment-only`) in the reconciliation output.
122
176
  3. **Label consistency:** Verify all created/updated issues have required labels (`type:*`, `priority:*`, `executor:*`) and correct `has-dependencies` state per rule 7 of Board Sync Enforcement. Fix any gaps.
123
177
  4. **PR linkage:** For issues transitioned to `status:in-progress` or `status:in-review`, verify any associated open PR body contains `Closes #N` for the addressed issues. Auto-fix if missing by updating the PR body.
178
+ 5. **Orphaned in-review detection:** For all cached issues with `status:in-review` (not just those transitioned during this run), verify an open PR/MR exists that references `Closes #N`:
179
+ - **GitHub:** `gh pr list -R {owner}/{repo} --state open --json number,body` — parse for `Closes #{N}`.
180
+ - **Azure DevOps:** `az repos pr list --status active` — check work item links.
181
+ - **GitLab:** `glab mr list -R {namespace}/{project} --state opened` — parse descriptions for `Closes #{N}`.
182
+ Flag orphaned in-review issues (those with no associated open PR/MR) in the reconciliation report. This catches issues that drifted to `status:in-review` in previous runs but lost their PR (closed without merge, PR deleted, etc.). Also flag closed issues still labeled `status:in-review` that should be `status:done`.
124
183
 
125
184
  ### Reconciliation Report
126
185
 
@@ -132,6 +191,7 @@ Reconciliation:
132
191
  Sub-issue links: {N} native, {M} advisory, {K} comment-only
133
192
  Label gaps: {N} fixed, {M} remaining (list)
134
193
  PR linkage: {N} verified, {M} missing `Closes` (list)
194
+ Orphaned in-review: {N} open issues with no PR/MR, {M} closed issues not status:done (list)
135
195
  Errors: {list or "None"}
136
196
  ```
137
197
 
@@ -93,6 +93,10 @@ enabled: false
93
93
  - Invalid YAML produces warnings but does not prevent command execution (graceful degradation)
94
94
  - Customization files should be committed to the repository
95
95
 
96
+ ## Unified Skill
97
+
98
+ This command's workflow is handled by the `hatch3r-customize` skill with `type: command`. The skill provides root-cause analysis, multi-stakeholder review, and quality gate steps that extend the workflow above.
99
+
96
100
  ## Related
97
101
 
98
102
  - Agent customization: `hatch3r-agent-customize` command
@@ -18,8 +18,8 @@ Monitor and maintain healthy conversation context during long-running agent sess
18
18
 
19
19
  ### Degradation Signals
20
20
 
21
- | Signal | Detection Method | Threshold |
22
- |--------|-----------------|-----------|
21
+ | Signal | Detection Method | Default Threshold |
22
+ |--------|-----------------|-------------------|
23
23
  | Conversation depth | Count user/assistant turns | > 30 turns |
24
24
  | Token accumulation | Estimate total context tokens | > 80% of model context window |
25
25
  | Topic drift | Compare current task to original issue scope | Cosine similarity < 0.6 |
@@ -27,6 +27,26 @@ Monitor and maintain healthy conversation context during long-running agent sess
27
27
  | File staleness | Track time since last file re-read | > 20 turns since last read |
28
28
  | Tool failure rate | Track tool call success/failure ratio | > 30% failure rate |
29
29
 
30
+ ### Model-Aware Threshold Profiles
31
+
32
+ Different models have different context window sizes and degradation characteristics. The default thresholds above assume a large-context model. When the active model is known, apply the matching profile to adjust thresholds dynamically.
33
+
34
+ | Model Tier | Context Window | Token Warning | Turn Limit | File Staleness |
35
+ |-----------|---------------|---------------|------------|----------------|
36
+ | Small (< 32K) | ~32K tokens | > 60% of window | > 15 turns | > 10 turns |
37
+ | Medium (32K--128K) | ~128K tokens | > 70% of window | > 25 turns | > 15 turns |
38
+ | Large (128K--200K) | ~200K tokens | > 80% of window | > 30 turns | > 20 turns |
39
+ | Extended (> 200K) | 200K+ tokens | > 85% of window | > 40 turns | > 25 turns |
40
+
41
+ **Profile resolution:**
42
+
43
+ 1. Check `models` in `hatch.json` for the configured model. If a model name or tier is specified, use the matching profile.
44
+ 2. If no model is configured, default to the **Large** profile (backward-compatible with existing thresholds).
45
+ 3. When the runtime reports the model name (e.g., via API response headers or tool metadata), map it to the appropriate tier using known model context sizes.
46
+ 4. Log the active profile at the start of each health check: `"Context health using <tier> profile (<window_size> tokens)"`.
47
+
48
+ **Custom thresholds:** If `hatch.json` includes a `contextHealth` section with explicit thresholds, those values override the model-aware profile. This allows teams to tune thresholds for their specific workflow patterns.
49
+
30
50
  ### Health Levels
31
51
 
32
52
  | Level | Status | Action |
@@ -77,6 +77,20 @@ Configure in `hatch.json`:
77
77
  }
78
78
  ```
79
79
 
80
+ ### Default Budgets
81
+
82
+ When `hatch.json` has no `costTracking` section, the following defaults are applied automatically. These defaults provide baseline guardrails without requiring explicit configuration.
83
+
84
+ | Budget Type | Default Value | Rationale |
85
+ |------------|--------------|-----------|
86
+ | `sessionBudget` | $10.00 | Covers a typical multi-issue development session (~3-4 issues at ~$3 each, with headroom) |
87
+ | `issueBudget` | $5.00 | Accommodates the full 4-phase pipeline (Research + Implement + Review + Quality) for a standard task |
88
+ | `epicBudget` | $25.00 | Covers ~5 sub-issues with shared overhead for batch coherence assessment |
89
+ | `warningThresholds` | [0.5, 0.75, 0.9] | Progressive alerts at 50%, 75%, and 90% of budget |
90
+ | `hardStop` | false | Defaults to soft warnings (log + alert) rather than blocking. Teams can opt into hard stops explicitly. |
91
+
92
+ These defaults activate reporting mode: budget warnings are surfaced to the user at each threshold, but work is not halted unless `hardStop` is explicitly set to `true`. To override any default, add the corresponding key to `costTracking` in `hatch.json`.
93
+
80
94
  ### Enforcement
81
95
 
82
96
  | Threshold | Action |
@@ -251,7 +251,7 @@ Add `priority` and `timeout` to hook frontmatter:
251
251
 
252
252
  ```markdown
253
253
  ---
254
- id: pre-commit-lint-fixer
254
+ id: my-pre-commit-lint-fixer
255
255
  type: hook
256
256
  event: pre-commit
257
257
  agent: lint-fixer