hatch3r 1.9.0 → 2.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/README.md +52 -143
- package/dist/cli/index.js +28453 -15831
- package/dist/content/agents/hatch3r-architect.md +39 -9
- package/dist/content/agents/hatch3r-brownfield-spec.md +254 -0
- package/dist/content/agents/hatch3r-ci-watcher.md +8 -1
- package/dist/content/agents/hatch3r-context-rules.md +19 -1
- package/dist/content/agents/hatch3r-creator.md +65 -26
- package/dist/content/agents/hatch3r-dependency-drafter.md +162 -0
- package/dist/content/agents/hatch3r-devops.md +11 -1
- package/dist/content/agents/hatch3r-docs-writer.md +11 -1
- package/dist/content/agents/hatch3r-edge-case-analyst.md +134 -0
- package/dist/content/agents/hatch3r-enhancability.md +192 -0
- package/dist/content/agents/hatch3r-fixer.md +59 -8
- package/dist/content/agents/hatch3r-greenfield-spec.md +256 -0
- package/dist/content/agents/hatch3r-handoff-loader.md +29 -3
- package/dist/content/agents/hatch3r-handoff-preparer.md +10 -1
- package/dist/content/agents/hatch3r-implementer.md +139 -8
- package/dist/content/agents/hatch3r-incident-responder.md +96 -0
- package/dist/content/agents/hatch3r-learnings-loader.md +122 -88
- package/dist/content/agents/hatch3r-lint-fixer.md +15 -3
- package/dist/content/agents/hatch3r-maintainability.md +183 -0
- package/dist/content/agents/hatch3r-pack-installer.md +113 -0
- package/dist/content/agents/hatch3r-performance.md +179 -0
- package/dist/content/agents/hatch3r-reliability.md +193 -0
- package/dist/content/agents/hatch3r-researcher.md +27 -4
- package/dist/content/agents/hatch3r-reviewer.md +153 -103
- package/dist/content/agents/hatch3r-scalability.md +162 -0
- package/dist/content/agents/hatch3r-security.md +197 -0
- package/dist/content/agents/hatch3r-testability.md +204 -0
- package/dist/content/agents/hatch3r-ui.md +175 -0
- package/dist/content/agents/hatch3r-ux.md +160 -0
- package/dist/content/agents/modes/requirements-elicitation.md +1 -1
- package/dist/content/agents/modes/user-flows.md +2 -2
- package/dist/content/agents/shared/clarification-default-block.md +44 -0
- package/dist/content/agents/shared/confidence-gate.md +42 -0
- package/dist/content/agents/shared/cq-specialist-roster.md +26 -0
- package/dist/content/agents/shared/efficiency-patterns.md +32 -1
- package/dist/content/agents/shared/injection-patterns.md +18 -7
- package/dist/content/agents/shared/principles.md +60 -0
- package/dist/content/agents/shared/prompt-structure.md +7 -1
- package/dist/content/agents/shared/quality-charter.md +48 -12
- package/dist/content/agents/shared/quality-specialist-frame.md +141 -0
- package/dist/content/agents/shared/rigor-contract.md +151 -0
- package/dist/content/agents/shared/severity-mapping.md +92 -0
- package/dist/content/agents/shared/triage-vocabulary.md +46 -0
- package/dist/content/agents/shared/user-content-templates.md +34 -8
- package/dist/content/agents/shared/user-question-protocol.md +45 -3
- package/dist/content/checks/README.md +5 -0
- package/dist/content/checks/accessibility.md +14 -7
- package/dist/content/checks/code-quality.md +1 -1
- package/dist/content/checks/performance.md +7 -4
- package/dist/content/checks/security.md +6 -6
- package/dist/content/checks/testing.md +1 -1
- package/dist/content/commands/board/pickup-delegation-multi.md +37 -10
- package/dist/content/commands/board/pickup-delegation.md +7 -5
- package/dist/content/commands/board/pickup-modes.md +1 -0
- package/dist/content/commands/board/pickup-post-impl.md +1 -1
- package/dist/content/commands/hatch3r-api-spec.md +79 -2
- package/dist/content/commands/hatch3r-auth-scaffold.md +250 -0
- package/dist/content/commands/hatch3r-benchmark.md +90 -7
- package/dist/content/commands/hatch3r-board-fill.md +97 -11
- package/dist/content/commands/hatch3r-board-pickup.md +93 -9
- package/dist/content/commands/hatch3r-bug-pipeline.md +240 -0
- package/dist/content/commands/hatch3r-bug-plan.md +79 -3
- package/dist/content/commands/hatch3r-codebase-map.md +80 -4
- package/dist/content/commands/hatch3r-create.md +105 -7
- package/dist/content/commands/hatch3r-debug.md +102 -14
- package/dist/content/commands/hatch3r-diagnose.md +238 -0
- package/dist/content/commands/hatch3r-feature-plan.md +125 -5
- package/dist/content/commands/hatch3r-handoff.md +83 -3
- package/dist/content/commands/hatch3r-healthcheck.md +105 -5
- package/dist/content/commands/hatch3r-incident-response.md +228 -0
- package/dist/content/commands/hatch3r-migration-plan.md +79 -3
- package/dist/content/commands/hatch3r-onboard.md +94 -3
- package/dist/content/commands/hatch3r-pack-install.md +243 -0
- package/dist/content/commands/hatch3r-pr-resolve.md +106 -23
- package/dist/content/commands/hatch3r-project-spec.md +82 -6
- package/dist/content/commands/hatch3r-quick-change.md +108 -13
- package/dist/content/commands/hatch3r-refactor-plan.md +78 -2
- package/dist/content/commands/hatch3r-release.md +401 -0
- package/dist/content/commands/hatch3r-revision.md +98 -12
- package/dist/content/commands/hatch3r-roadmap.md +92 -10
- package/dist/content/commands/hatch3r-security-audit.md +105 -5
- package/dist/content/commands/hatch3r-slo-scaffold.md +246 -0
- package/dist/content/commands/hatch3r-spec.md +216 -0
- package/dist/content/commands/hatch3r-test-plan.md +85 -9
- package/dist/content/commands/hatch3r-workflow.md +165 -41
- package/dist/content/commands/revision/revision-delegation.md +6 -5
- package/dist/content/commands/revision/revision-modes.md +49 -4
- package/dist/content/commands/revision/revision-quality.md +10 -7
- package/dist/content/commands/shared/orchestration-frame.md +119 -0
- package/dist/content/github-agents/hatch3r-docs-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-lint-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-security-agent.md +21 -1
- package/dist/content/github-agents/hatch3r-test-agent.md +21 -1
- package/dist/content/hooks/hatch3r-file-save.md +1 -1
- package/dist/content/hooks/hatch3r-pre-push.md +4 -4
- package/dist/content/hooks/hatch3r-review-loop-cap.md +52 -0
- package/dist/content/mcp/mcp.json +7 -5
- package/dist/content/rules/hatch3r-accessibility-standards.md +14 -2
- package/dist/content/rules/hatch3r-accessibility-standards.mdc +12 -1
- package/dist/content/rules/hatch3r-agent-orchestration-detail.md +58 -19
- package/dist/content/rules/hatch3r-agent-orchestration-detail.mdc +58 -19
- package/dist/content/rules/hatch3r-agent-orchestration.md +87 -213
- package/dist/content/rules/hatch3r-agent-orchestration.mdc +87 -213
- package/dist/content/rules/hatch3r-ai-evals.md +5 -4
- package/dist/content/rules/hatch3r-ai-evals.mdc +3 -3
- package/dist/content/rules/hatch3r-ai-ux-patterns.md +6 -2
- package/dist/content/rules/hatch3r-ai-ux-patterns.mdc +4 -1
- package/dist/content/rules/hatch3r-android-patterns.md +107 -0
- package/dist/content/rules/hatch3r-android-patterns.mdc +102 -0
- package/dist/content/rules/hatch3r-anti-duplication.md +115 -0
- package/dist/content/rules/hatch3r-anti-duplication.mdc +115 -0
- package/dist/content/rules/hatch3r-api-design.md +5 -1
- package/dist/content/rules/hatch3r-api-design.mdc +3 -0
- package/dist/content/rules/hatch3r-api-versioning.md +2 -1
- package/dist/content/rules/hatch3r-auth-patterns.md +3 -1
- package/dist/content/rules/hatch3r-auth-patterns.mdc +1 -0
- package/dist/content/rules/hatch3r-browser-verification.md +2 -0
- package/dist/content/rules/hatch3r-browser-verification.mdc +2 -0
- package/dist/content/rules/hatch3r-capability-matrix.md +108 -0
- package/dist/content/rules/hatch3r-capability-matrix.mdc +108 -0
- package/dist/content/rules/hatch3r-ci-cd.md +8 -1
- package/dist/content/rules/hatch3r-ci-cd.mdc +6 -0
- package/dist/content/rules/hatch3r-clarification-default.md +73 -0
- package/dist/content/rules/hatch3r-clarification-default.mdc +73 -0
- package/dist/content/rules/hatch3r-code-standards.md +23 -47
- package/dist/content/rules/hatch3r-code-standards.mdc +22 -46
- package/dist/content/rules/hatch3r-component-conventions.md +3 -0
- package/dist/content/rules/hatch3r-component-conventions.mdc +3 -0
- package/dist/content/rules/hatch3r-container-hardening.md +11 -2
- package/dist/content/rules/hatch3r-container-hardening.mdc +9 -1
- package/dist/content/rules/hatch3r-contract-testing.md +2 -1
- package/dist/content/rules/hatch3r-cost-visibility.md +135 -0
- package/dist/content/rules/hatch3r-cost-visibility.mdc +135 -0
- package/dist/content/rules/hatch3r-cq-rule-frame.md +54 -0
- package/dist/content/rules/hatch3r-cq-rule-frame.mdc +49 -0
- package/dist/content/rules/hatch3r-data-classification.md +3 -1
- package/dist/content/rules/hatch3r-data-classification.mdc +2 -1
- package/dist/content/rules/hatch3r-deep-context.md +13 -13
- package/dist/content/rules/hatch3r-deep-context.mdc +13 -13
- package/dist/content/rules/hatch3r-dependency-management.md +16 -3
- package/dist/content/rules/hatch3r-dependency-management.mdc +15 -3
- package/dist/content/rules/hatch3r-design-system-detection.md +2 -1
- package/dist/content/rules/hatch3r-dotnet-patterns.md +104 -0
- package/dist/content/rules/hatch3r-dotnet-patterns.mdc +99 -0
- package/dist/content/rules/hatch3r-edge-case-discipline.md +65 -0
- package/dist/content/rules/hatch3r-edge-case-discipline.mdc +65 -0
- package/dist/content/rules/hatch3r-enhancability.md +147 -0
- package/dist/content/rules/hatch3r-enhancability.mdc +142 -0
- package/dist/content/rules/hatch3r-event-schema-evolution.md +2 -1
- package/dist/content/rules/hatch3r-fan-out-discipline.md +91 -0
- package/dist/content/rules/hatch3r-fan-out-discipline.mdc +91 -0
- package/dist/content/rules/hatch3r-feature-flags.md +2 -0
- package/dist/content/rules/hatch3r-feature-flags.mdc +2 -0
- package/dist/content/rules/hatch3r-flutter-patterns.md +88 -0
- package/dist/content/rules/hatch3r-flutter-patterns.mdc +83 -0
- package/dist/content/rules/hatch3r-git-conventions.md +4 -1
- package/dist/content/rules/hatch3r-git-conventions.mdc +2 -0
- package/dist/content/rules/hatch3r-go-patterns.md +98 -0
- package/dist/content/rules/hatch3r-go-patterns.mdc +93 -0
- package/dist/content/rules/hatch3r-handoff-readiness.md +10 -0
- package/dist/content/rules/hatch3r-handoff-readiness.mdc +10 -0
- package/dist/content/rules/hatch3r-i18n.md +2 -0
- package/dist/content/rules/hatch3r-i18n.mdc +2 -0
- package/dist/content/rules/hatch3r-iteration-summary.md +75 -57
- package/dist/content/rules/hatch3r-iteration-summary.mdc +77 -54
- package/dist/content/rules/hatch3r-learning-system.md +202 -0
- package/dist/content/rules/hatch3r-learning-system.mdc +202 -0
- package/dist/content/rules/hatch3r-maintainability.md +157 -0
- package/dist/content/rules/hatch3r-maintainability.mdc +152 -0
- package/dist/content/rules/hatch3r-migrations.md +2 -1
- package/dist/content/rules/hatch3r-observability-logging.md +1 -1
- package/dist/content/rules/hatch3r-observability-metrics.md +1 -1
- package/dist/content/rules/hatch3r-observability-tracing.md +45 -36
- package/dist/content/rules/hatch3r-observability-tracing.mdc +44 -35
- package/dist/content/rules/hatch3r-operability.md +2 -1
- package/dist/content/rules/hatch3r-passkey-server.md +2 -1
- package/dist/content/rules/hatch3r-performance-budgets.md +2 -0
- package/dist/content/rules/hatch3r-performance-budgets.mdc +2 -0
- package/dist/content/rules/hatch3r-php-laravel-patterns.md +109 -0
- package/dist/content/rules/hatch3r-php-laravel-patterns.mdc +104 -0
- package/dist/content/rules/hatch3r-progressive-delivery.md +5 -1
- package/dist/content/rules/hatch3r-progressive-delivery.mdc +3 -0
- package/dist/content/rules/hatch3r-proof-model.md +131 -0
- package/dist/content/rules/hatch3r-proof-model.mdc +131 -0
- package/dist/content/rules/hatch3r-python-patterns.md +70 -0
- package/dist/content/rules/hatch3r-python-patterns.mdc +65 -0
- package/dist/content/rules/hatch3r-react-native-patterns.md +83 -0
- package/dist/content/rules/hatch3r-react-native-patterns.mdc +78 -0
- package/dist/content/rules/hatch3r-resilience-patterns.md +2 -1
- package/dist/content/rules/hatch3r-reviewer-calibration.md +84 -0
- package/dist/content/rules/hatch3r-reviewer-calibration.mdc +84 -0
- package/dist/content/rules/hatch3r-right-sizing.md +68 -0
- package/dist/content/rules/hatch3r-right-sizing.mdc +66 -0
- package/dist/content/rules/hatch3r-ruby-rails-patterns.md +111 -0
- package/dist/content/rules/hatch3r-ruby-rails-patterns.mdc +106 -0
- package/dist/content/rules/hatch3r-rust-patterns.md +107 -0
- package/dist/content/rules/hatch3r-rust-patterns.mdc +102 -0
- package/dist/content/rules/hatch3r-scalability.md +137 -0
- package/dist/content/rules/hatch3r-scalability.mdc +132 -0
- package/dist/content/rules/hatch3r-secrets-management.md +10 -1
- package/dist/content/rules/hatch3r-secrets-management.mdc +8 -0
- package/dist/content/rules/hatch3r-security-patterns.md +36 -34
- package/dist/content/rules/hatch3r-security-patterns.mdc +35 -34
- package/dist/content/rules/hatch3r-security.md +97 -0
- package/dist/content/rules/hatch3r-security.mdc +92 -0
- package/dist/content/rules/hatch3r-swiftui-patterns.md +98 -0
- package/dist/content/rules/hatch3r-swiftui-patterns.mdc +93 -0
- package/dist/content/rules/hatch3r-testability.md +115 -0
- package/dist/content/rules/hatch3r-testability.mdc +110 -0
- package/dist/content/rules/hatch3r-testing.md +4 -1
- package/dist/content/rules/hatch3r-testing.mdc +2 -0
- package/dist/content/rules/hatch3r-theming.md +2 -0
- package/dist/content/rules/hatch3r-theming.mdc +2 -0
- package/dist/content/rules/hatch3r-tool-currency.md +91 -0
- package/dist/content/rules/hatch3r-tool-currency.mdc +86 -0
- package/dist/content/rules/hatch3r-tooling-hierarchy.md +29 -31
- package/dist/content/rules/hatch3r-tooling-hierarchy.mdc +27 -30
- package/dist/content/rules/hatch3r-typescript-patterns.md +58 -0
- package/dist/content/rules/hatch3r-typescript-patterns.mdc +53 -0
- package/dist/content/rules/hatch3r-ux-states-and-flows.md +11 -4
- package/dist/content/rules/hatch3r-ux-states-and-flows.mdc +9 -3
- package/dist/content/skills/hatch3r-a11y-audit/SKILL.md +10 -8
- package/dist/content/skills/hatch3r-a11y-audit/references/manual-audit-checklist.md +7 -5
- package/dist/content/skills/hatch3r-adhoc-orchestrate/SKILL.md +131 -0
- package/dist/content/skills/hatch3r-ai-feature/SKILL.md +4 -6
- package/dist/content/skills/hatch3r-api-spec/SKILL.md +27 -2
- package/dist/content/skills/hatch3r-architecture-review/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-board-groom/SKILL.md +11 -0
- package/dist/content/skills/hatch3r-board-init/SKILL.md +17 -1
- package/dist/content/skills/hatch3r-board-refresh/SKILL.md +12 -1
- package/dist/content/skills/hatch3r-board-shared/SKILL.md +38 -1
- package/dist/content/skills/hatch3r-browser-verify/SKILL.md +307 -0
- package/dist/content/skills/hatch3r-bug-fix/SKILL.md +15 -2
- package/dist/content/skills/hatch3r-ci-pipeline/SKILL.md +17 -7
- package/dist/content/skills/hatch3r-cli-fd/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-fzf/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-gh/SKILL.md +50 -1
- package/dist/content/skills/hatch3r-cli-jq/SKILL.md +40 -6
- package/dist/content/skills/hatch3r-cli-ripgrep/SKILL.md +33 -1
- package/dist/content/skills/hatch3r-cli-toolbox/SKILL.md +130 -23
- package/dist/content/skills/hatch3r-containerize/SKILL.md +157 -0
- package/dist/content/skills/hatch3r-context-health/SKILL.md +9 -7
- package/dist/content/skills/hatch3r-cost-tracking/SKILL.md +37 -17
- package/dist/content/skills/hatch3r-customize/SKILL.md +5 -8
- package/dist/content/skills/hatch3r-dep-audit/SKILL.md +23 -7
- package/dist/content/skills/hatch3r-design-system-detect/SKILL.md +3 -7
- package/dist/content/skills/hatch3r-docs-writing/SKILL.md +159 -0
- package/dist/content/skills/hatch3r-enhancability-verify/SKILL.md +152 -0
- package/dist/content/skills/hatch3r-feature/SKILL.md +53 -3
- package/dist/content/skills/hatch3r-feedback/SKILL.md +103 -0
- package/dist/content/skills/hatch3r-gh-agentic-workflows/SKILL.md +10 -8
- package/dist/content/skills/hatch3r-handoff-prepare/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-handoff-resume/SKILL.md +4 -7
- package/dist/content/{commands/hatch3r-hooks.md → skills/hatch3r-hooks/SKILL.md} +48 -137
- package/dist/content/skills/hatch3r-incident-response/SKILL.md +66 -7
- package/dist/content/skills/hatch3r-issue-workflow/SKILL.md +11 -0
- package/dist/content/skills/hatch3r-learn/SKILL.md +317 -0
- package/dist/content/skills/hatch3r-logical-refactor/SKILL.md +6 -7
- package/dist/content/skills/hatch3r-maintainability-verify/SKILL.md +146 -0
- package/dist/content/skills/hatch3r-migration/SKILL.md +8 -7
- package/dist/content/skills/hatch3r-observability-verify/SKILL.md +17 -12
- package/dist/content/skills/hatch3r-perf-audit/SKILL.md +13 -9
- package/dist/content/skills/hatch3r-pr-creation/SKILL.md +4 -7
- package/dist/content/skills/hatch3r-qa-validation/SKILL.md +6 -5
- package/dist/content/skills/hatch3r-recipe/SKILL.md +63 -60
- package/dist/content/skills/hatch3r-refactor/SKILL.md +6 -7
- package/dist/content/skills/hatch3r-release/SKILL.md +123 -11
- package/dist/content/skills/hatch3r-reliability-verify/SKILL.md +9 -5
- package/dist/content/{commands/hatch3r-report.md → skills/hatch3r-report/SKILL.md} +20 -17
- package/dist/content/skills/hatch3r-scalability-verify/SKILL.md +145 -0
- package/dist/content/skills/hatch3r-security-verify/SKILL.md +144 -0
- package/dist/content/skills/hatch3r-team-convention-author/SKILL.md +126 -0
- package/dist/content/skills/hatch3r-testability-verify/SKILL.md +147 -0
- package/dist/content/skills/hatch3r-ui-ux-verify/SKILL.md +19 -11
- package/dist/content/skills/hatch3r-visual-refactor/SKILL.md +11 -7
- package/package.json +50 -31
- package/dist/cli/index.d.ts +0 -2
- package/dist/cli/index.js.map +0 -1
- package/dist/content/agents/hatch3r-a11y-auditor.md +0 -159
- package/dist/content/agents/hatch3r-dependency-auditor.md +0 -219
- package/dist/content/agents/hatch3r-perf-profiler.md +0 -166
- package/dist/content/agents/hatch3r-security-auditor.md +0 -180
- package/dist/content/agents/hatch3r-test-writer.md +0 -171
- package/dist/content/commands/hatch3r-learn.md +0 -312
- package/dist/content/rules/hatch3r-learning-consult.md +0 -42
- package/dist/content/rules/hatch3r-learning-consult.mdc +0 -38
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
id: hatch3r-ai-ux-patterns
|
|
3
3
|
type: rule
|
|
4
4
|
description: 2026 AI/agentic UX patterns for end-user projects shipping AI features — streaming, tool-call UI, human-approval gates, cancel/abort/undo, citations
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/*.vue,**/*.jsx,**/*.tsx,**/*.svelte,**/ai/**,**/chat/**,**/assistant/**,**/agents/**,**/llm/**,**/copilot/**"
|
|
6
7
|
tags: [implementation, floor:ui-ux, ux, ai, frontend]
|
|
8
|
+
precedence: high
|
|
7
9
|
quality_charter: agents/shared/quality-charter.md
|
|
8
10
|
cache_friendly: true
|
|
9
11
|
---
|
|
10
12
|
# AI/Agentic UX Patterns (2026)
|
|
11
13
|
|
|
14
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ2 (UX Quality)
|
|
15
|
+
|
|
12
16
|
## Scope
|
|
13
17
|
|
|
14
18
|
This rule applies when the end-user project ships LLM-driven UI — chat, assistant, copilot, agent dashboards, generative UI surfaces. It does NOT govern the LLM backend itself (model selection, prompt engineering, retrieval pipeline). For non-AI UX rules (loading, empty, error, partial states; form patterns; microcopy), cross-reference `rules/hatch3r-ux-states-and-flows.md`. When both rules apply to the same surface, the non-AI rule sets the baseline and this rule layers AI-specific behavior on top.
|
|
@@ -110,7 +114,7 @@ Three distinct affordances — do not collapse them into a single control:
|
|
|
110
114
|
|
|
111
115
|
## Verification Gate
|
|
112
116
|
|
|
113
|
-
Before declaring an AI surface "done":
|
|
117
|
+
These 7 checks are operationalized as Gate 8 of `skills/hatch3r-ui-ux-verify` — the skill executes all 7, not just the streaming/tool-call subset. Before declaring an AI surface "done":
|
|
114
118
|
|
|
115
119
|
- Streaming verified end-to-end: scripted Playwright test that asserts progressive token render (first token <1s after request, last token marked complete).
|
|
116
120
|
- Tool-call card snapshot per state (`pending`, `in-progress`, `complete`, `failed`) — missing any state is a blocker.
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
description: 2026 AI/agentic UX patterns for end-user projects shipping AI features — streaming, tool-call UI, human-approval gates, cancel/abort/undo, citations
|
|
3
3
|
globs: ["**/*.vue", "**/*.jsx", "**/*.tsx", "**/*.svelte", "**/ai/**", "**/chat/**", "**/assistant/**", "**/agents/**", "**/llm/**", "**/copilot/**"]
|
|
4
4
|
alwaysApply: false
|
|
5
|
+
precedence: high
|
|
5
6
|
---
|
|
6
7
|
# AI/Agentic UX Patterns (2026)
|
|
7
8
|
|
|
9
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ2 (UX Quality)
|
|
10
|
+
|
|
8
11
|
## Scope
|
|
9
12
|
|
|
10
13
|
This rule applies when the end-user project ships LLM-driven UI — chat, assistant, copilot, agent dashboards, generative UI surfaces. It does NOT govern the LLM backend itself (model selection, prompt engineering, retrieval pipeline). For non-AI UX rules (loading, empty, error, partial states; form patterns; microcopy), cross-reference `rules/hatch3r-ux-states-and-flows.md`. When both rules apply to the same surface, the non-AI rule sets the baseline and this rule layers AI-specific behavior on top.
|
|
@@ -106,7 +109,7 @@ Three distinct affordances — do not collapse them into a single control:
|
|
|
106
109
|
|
|
107
110
|
## Verification Gate
|
|
108
111
|
|
|
109
|
-
Before declaring an AI surface "done":
|
|
112
|
+
These 7 checks are operationalized as Gate 8 of `skills/hatch3r-ui-ux-verify` — the skill executes all 7, not just the streaming/tool-call subset. Before declaring an AI surface "done":
|
|
110
113
|
|
|
111
114
|
- Streaming verified end-to-end: scripted Playwright test that asserts progressive token render (first token <1s after request, last token marked complete).
|
|
112
115
|
- Tool-call card snapshot per state (`pending`, `in-progress`, `complete`, `failed`) — missing any state is a blocker.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-android-patterns
|
|
3
|
+
type: rule
|
|
4
|
+
description: Android Kotlin conventions covering Jetpack Compose, coroutines + Flow, Hilt DI, Room, modular Gradle, AGP 8.x, target SDK 35, and Compose testing
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/*.kt,**/*.kts,**/build.gradle,**/build.gradle.kts,**/settings.gradle,**/settings.gradle.kts,**/gradle.properties,**/AndroidManifest.xml,**/proguard-rules.pro,**/app/src/**,**/android/app/**,**/libs.versions.toml"
|
|
7
|
+
tags: [implementation, lang:java]
|
|
8
|
+
quality_charter: agents/shared/quality-charter.md
|
|
9
|
+
cache_friendly: true
|
|
10
|
+
---
|
|
11
|
+
# Android Patterns
|
|
12
|
+
|
|
13
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
14
|
+
|
|
15
|
+
> Applies when the project ships an Android app or Kotlin library. Detection signals: `build.gradle` / `build.gradle.kts`, `AndroidManifest.xml`, `app/` module, or any `*.kt` file paired with Gradle wrapper. Native Android takes precedence over Flutter/React-Native cross-platform shells.
|
|
16
|
+
|
|
17
|
+
## Kotlin Language Floor
|
|
18
|
+
|
|
19
|
+
- Target Kotlin 2.0+ with K2 compiler (`kotlin.experimental.tryK2=true`). Treat warnings as errors in CI.
|
|
20
|
+
- Use `data class` for value-equality types, `sealed class` / `sealed interface` for closed-set hierarchies (UI state, events, errors). Exhaust `when` over sealed types — the compiler enforces it.
|
|
21
|
+
- Coroutines + Flow for concurrency. Never use `Thread` directly. Wrap legacy callback APIs with `suspendCancellableCoroutine` at the boundary.
|
|
22
|
+
- Nullability: explicit `?` for nullable types; avoid `!!` (force-unwrap) outside test fixtures. Platform types from Java interop annotated with `@Nullable` / `@NonNull` where possible.
|
|
23
|
+
|
|
24
|
+
## Build Tooling
|
|
25
|
+
|
|
26
|
+
- Android Gradle Plugin (AGP) 8.7+ with Gradle 8.10+. Use the version catalog (`gradle/libs.versions.toml`) for every dependency — no hard-coded versions in `build.gradle.kts`.
|
|
27
|
+
- Kotlin DSL (`build.gradle.kts`) for new modules. Migrate Groovy scripts during regular refactors; do not mix dialects in a single module's chain.
|
|
28
|
+
- Target SDK 35 (Android 15) — Google Play requires `targetSdk = 35` for new apps and updates in 2025. Set `compileSdk = 35` alongside.
|
|
29
|
+
- Min SDK: 24 (Android 7.0) covers >97% of active devices per Android Distribution Dashboard. Going below 24 means losing modern Kotlin stdlib calls that require API 24.
|
|
30
|
+
|
|
31
|
+
## Architecture
|
|
32
|
+
|
|
33
|
+
- Pick ONE app-architecture pattern per app and document it in `docs/architecture.md`:
|
|
34
|
+
- **MVI / Unidirectional Data Flow with Compose + ViewModel + StateFlow** — recommended default.
|
|
35
|
+
- **MVVM with LiveData** — only for legacy apps that haven't migrated to Compose.
|
|
36
|
+
- Modular Gradle structure: `app/` (entry point), `feature:<name>/` (feature modules), `core:<network|database|design-system>/` (shared modules). Cross-feature imports go through `core:` interfaces.
|
|
37
|
+
- Composition root in `app/` wires Hilt graphs. Feature modules expose `@Module @InstallIn(SingletonComponent::class)` providers; they never instantiate dependencies directly.
|
|
38
|
+
|
|
39
|
+
## Dependency Injection
|
|
40
|
+
|
|
41
|
+
- Use Hilt for runtime DI (annotation-processor based, sits on top of Dagger). Configure `@HiltAndroidApp` on the `Application` class and `@AndroidEntryPoint` on Activities, Fragments, Services.
|
|
42
|
+
- Constructor injection for ViewModels via `@HiltViewModel` + `@Inject constructor`. Do not use `ViewModelProvider.Factory` manually unless integrating with a non-Hilt host.
|
|
43
|
+
- Scoped bindings: `@SingletonComponent` for app-wide singletons, `@ViewModelScoped` for per-ViewModel instances. Never share `@SingletonComponent` state with UI lifecycle.
|
|
44
|
+
|
|
45
|
+
## Jetpack Compose
|
|
46
|
+
|
|
47
|
+
- Compose is the UI floor for new screens. Migrate XML views during regular refactors; do not mix `ConstraintLayout` XML with Compose for a single screen.
|
|
48
|
+
- State hoisting: `@Composable` functions are stateless by default. Hoist `MutableState` to the ViewModel; pass values + lambdas down.
|
|
49
|
+
- Use `collectAsStateWithLifecycle()` on Flow → State conversions inside composables. Plain `collectAsState()` ignores lifecycle and leaks during backgrounded screens.
|
|
50
|
+
- Recompose discipline: stable types only as composable parameters. Use `@Stable` / `@Immutable` annotations or `kotlinx-collections-immutable` for lists. `MutableList<T>` parameters force every consumer to recompose on any mutation.
|
|
51
|
+
- Material 3 (`androidx.compose.material3`) is the design system floor for Compose. Material 2 is legacy.
|
|
52
|
+
|
|
53
|
+
## Coroutines & Flow
|
|
54
|
+
|
|
55
|
+
- Structured concurrency: every coroutine launched in a `CoroutineScope` tied to a lifecycle. Use `viewModelScope` (auto-cancels on `onCleared()`), `lifecycleScope` (auto-cancels on lifecycle destroy), and `WorkManager` for background tasks.
|
|
56
|
+
- Never launch from `GlobalScope`. Never call `runBlocking` on the main thread.
|
|
57
|
+
- Cold flows (`flow { }`, `flowOf`) for one-shot streams; hot flows (`MutableStateFlow`, `MutableSharedFlow`) for UI state and event buses. `LiveData` is legacy — use `StateFlow` for new code.
|
|
58
|
+
- Use `Dispatchers.IO` for blocking I/O, `Dispatchers.Default` for CPU-bound work. The main dispatcher is for UI updates only; no blocking work there.
|
|
59
|
+
|
|
60
|
+
## Persistence
|
|
61
|
+
|
|
62
|
+
- Room is the SQL persistence floor. Define `@Entity`, `@Dao`, and a `@Database` class with a versioned schema. Migration paths via `Migration` objects committed to VCS.
|
|
63
|
+
- DataStore (Preferences or Proto) for key-value and structured preferences. SharedPreferences is legacy — do not adopt for new code.
|
|
64
|
+
- For network sync: WorkManager with `Constraints` (network, charging, battery) + exponential backoff. Never use `JobScheduler` directly — WorkManager wraps it and handles edge cases.
|
|
65
|
+
- Bind Room DAOs and DataStore to coroutines / Flow — suspend functions for one-shot queries, `Flow<T>` for observed reads.
|
|
66
|
+
|
|
67
|
+
## Networking
|
|
68
|
+
|
|
69
|
+
- Use Retrofit 2.11+ with kotlinx-serialization-converter or Moshi (Gson is in maintenance — prefer one of the modern serializers). Configure OkHttp logging interceptor only in debug builds.
|
|
70
|
+
- Ktor Client is the alternative when the app shares a multi-platform stack with Kotlin Multiplatform.
|
|
71
|
+
- Configure timeouts on every OkHttp client: connect (10s), read (30s), write (15s). Default timeouts are unbounded — production apps must override.
|
|
72
|
+
- Certificate pinning (`CertificatePinner`) for high-security endpoints. Always include a backup pin and a rotation schedule.
|
|
73
|
+
|
|
74
|
+
## Testing
|
|
75
|
+
|
|
76
|
+
- Unit tests with JUnit 5 (`org.junit.jupiter:junit-jupiter`) + MockK for mocking. JUnit 4 + Mockito is legacy — do not add for new modules.
|
|
77
|
+
- Coroutine tests with `kotlinx-coroutines-test` (`runTest`, `TestDispatcher`). Never use `Thread.sleep` to wait for async work.
|
|
78
|
+
- Compose UI tests with `androidx.compose.ui:ui-test-junit4`. Use semantics-based matchers (`hasContentDescription`, `hasTestTag`) — avoid text matchers for resilience.
|
|
79
|
+
- Instrumented tests via `androidTest/` source set on emulators or Firebase Test Lab matrices. Configure `testCoverage` in the AGP block; floor 80% line coverage in `feature:` modules.
|
|
80
|
+
- Screenshot tests via Paparazzi (host-side, no emulator needed) or Roborazzi. Update goldens through PR review.
|
|
81
|
+
|
|
82
|
+
## Accessibility
|
|
83
|
+
|
|
84
|
+
- Every interactive composable has `Modifier.semantics { contentDescription = "..." }` or uses Material 3 widgets that provide semantics by default.
|
|
85
|
+
- TalkBack tested on every PR touching UI. The TalkBack-on screenshot test in Paparazzi catches regressions automatically.
|
|
86
|
+
- Dynamic font scaling: respect `MaterialTheme.typography` and avoid hard-coded `.sp` values in layouts. Test with the largest accessibility font size in the system settings.
|
|
87
|
+
- Touch targets: minimum 48dp × 48dp per Material 3 guidelines. `Modifier.minimumInteractiveComponentSize()` enforces this when composables are below 48dp.
|
|
88
|
+
|
|
89
|
+
## Distribution
|
|
90
|
+
|
|
91
|
+
- Sign release builds with Play App Signing — Google holds the upload key, you hold the signing key in escrow. Configure via Play Console.
|
|
92
|
+
- App Bundle (`*.aab`) for Play Store, APK only for sideload / direct distribution. Enable `bundle { language { enableSplit = true } }`.
|
|
93
|
+
- ProGuard / R8 on release builds (`isMinifyEnabled = true`, `isShrinkResources = true`). Maintain `proguard-rules.pro` per module; verify post-shrink builds in CI before publishing.
|
|
94
|
+
- Use Crashlytics or Sentry for crash reporting. Symbolicate native crashes via NDK symbol upload in CI.
|
|
95
|
+
|
|
96
|
+
## References
|
|
97
|
+
|
|
98
|
+
- AGP 8.x release notes: https://developer.android.com/build/releases/gradle-plugin (accessed 2026-05-27, official-docs)
|
|
99
|
+
- Jetpack Compose: https://developer.android.com/jetpack/compose (accessed 2026-05-27, official-docs)
|
|
100
|
+
- Coroutines + Flow: https://kotlinlang.org/docs/coroutines-overview.html (accessed 2026-05-27, official-docs)
|
|
101
|
+
- Google Play target SDK 35 requirement: https://developer.android.com/google/play/requirements/target-sdk (accessed 2026-05-27, official-docs)
|
|
102
|
+
|
|
103
|
+
## Cross-References
|
|
104
|
+
|
|
105
|
+
- `rules/hatch3r-component-conventions.md` — four-state surface contract maps to Compose `StateFlow<UiState>` patterns.
|
|
106
|
+
- `rules/hatch3r-testing.md` — coverage thresholds and determinism rules apply to JUnit / Compose tests.
|
|
107
|
+
- `rules/hatch3r-accessibility-standards.md` — WCAG mapping for Compose `semantics { ... }` modifiers.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Android Kotlin conventions covering Jetpack Compose, coroutines + Flow, Hilt DI, Room, modular Gradle, AGP 8.x, target SDK 35, and Compose testing
|
|
3
|
+
globs: ["**/*.kt", "**/*.kts", "**/build.gradle", "**/build.gradle.kts", "**/settings.gradle", "**/settings.gradle.kts", "**/gradle.properties", "**/AndroidManifest.xml", "**/proguard-rules.pro", "**/app/src/**", "**/android/app/**", "**/libs.versions.toml"]
|
|
4
|
+
alwaysApply: false
|
|
5
|
+
---
|
|
6
|
+
# Android Patterns
|
|
7
|
+
|
|
8
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ8 (Maintainability Quality)
|
|
9
|
+
|
|
10
|
+
> Applies when the project ships an Android app or Kotlin library. Detection signals: `build.gradle` / `build.gradle.kts`, `AndroidManifest.xml`, `app/` module, or any `*.kt` file paired with Gradle wrapper. Native Android takes precedence over Flutter/React-Native cross-platform shells.
|
|
11
|
+
|
|
12
|
+
## Kotlin Language Floor
|
|
13
|
+
|
|
14
|
+
- Target Kotlin 2.0+ with K2 compiler (`kotlin.experimental.tryK2=true`). Treat warnings as errors in CI.
|
|
15
|
+
- Use `data class` for value-equality types, `sealed class` / `sealed interface` for closed-set hierarchies (UI state, events, errors). Exhaust `when` over sealed types — the compiler enforces it.
|
|
16
|
+
- Coroutines + Flow for concurrency. Never use `Thread` directly. Wrap legacy callback APIs with `suspendCancellableCoroutine` at the boundary.
|
|
17
|
+
- Nullability: explicit `?` for nullable types; avoid `!!` (force-unwrap) outside test fixtures. Platform types from Java interop annotated with `@Nullable` / `@NonNull` where possible.
|
|
18
|
+
|
|
19
|
+
## Build Tooling
|
|
20
|
+
|
|
21
|
+
- Android Gradle Plugin (AGP) 8.7+ with Gradle 8.10+. Use the version catalog (`gradle/libs.versions.toml`) for every dependency — no hard-coded versions in `build.gradle.kts`.
|
|
22
|
+
- Kotlin DSL (`build.gradle.kts`) for new modules. Migrate Groovy scripts during regular refactors; do not mix dialects in a single module's chain.
|
|
23
|
+
- Target SDK 35 (Android 15) — Google Play requires `targetSdk = 35` for new apps and updates in 2025. Set `compileSdk = 35` alongside.
|
|
24
|
+
- Min SDK: 24 (Android 7.0) covers >97% of active devices per Android Distribution Dashboard. Going below 24 means losing modern Kotlin stdlib calls that require API 24.
|
|
25
|
+
|
|
26
|
+
## Architecture
|
|
27
|
+
|
|
28
|
+
- Pick ONE app-architecture pattern per app and document it in `docs/architecture.md`:
|
|
29
|
+
- **MVI / Unidirectional Data Flow with Compose + ViewModel + StateFlow** — recommended default.
|
|
30
|
+
- **MVVM with LiveData** — only for legacy apps that haven't migrated to Compose.
|
|
31
|
+
- Modular Gradle structure: `app/` (entry point), `feature:<name>/` (feature modules), `core:<network|database|design-system>/` (shared modules). Cross-feature imports go through `core:` interfaces.
|
|
32
|
+
- Composition root in `app/` wires Hilt graphs. Feature modules expose `@Module @InstallIn(SingletonComponent::class)` providers; they never instantiate dependencies directly.
|
|
33
|
+
|
|
34
|
+
## Dependency Injection
|
|
35
|
+
|
|
36
|
+
- Use Hilt for runtime DI (annotation-processor based, sits on top of Dagger). Configure `@HiltAndroidApp` on the `Application` class and `@AndroidEntryPoint` on Activities, Fragments, Services.
|
|
37
|
+
- Constructor injection for ViewModels via `@HiltViewModel` + `@Inject constructor`. Do not use `ViewModelProvider.Factory` manually unless integrating with a non-Hilt host.
|
|
38
|
+
- Scoped bindings: `@SingletonComponent` for app-wide singletons, `@ViewModelScoped` for per-ViewModel instances. Never share `@SingletonComponent` state with UI lifecycle.
|
|
39
|
+
|
|
40
|
+
## Jetpack Compose
|
|
41
|
+
|
|
42
|
+
- Compose is the UI floor for new screens. Migrate XML views during regular refactors; do not mix `ConstraintLayout` XML with Compose for a single screen.
|
|
43
|
+
- State hoisting: `@Composable` functions are stateless by default. Hoist `MutableState` to the ViewModel; pass values + lambdas down.
|
|
44
|
+
- Use `collectAsStateWithLifecycle()` on Flow → State conversions inside composables. Plain `collectAsState()` ignores lifecycle and leaks during backgrounded screens.
|
|
45
|
+
- Recompose discipline: stable types only as composable parameters. Use `@Stable` / `@Immutable` annotations or `kotlinx-collections-immutable` for lists. `MutableList<T>` parameters force every consumer to recompose on any mutation.
|
|
46
|
+
- Material 3 (`androidx.compose.material3`) is the design system floor for Compose. Material 2 is legacy.
|
|
47
|
+
|
|
48
|
+
## Coroutines & Flow
|
|
49
|
+
|
|
50
|
+
- Structured concurrency: every coroutine launched in a `CoroutineScope` tied to a lifecycle. Use `viewModelScope` (auto-cancels on `onCleared()`), `lifecycleScope` (auto-cancels on lifecycle destroy), and `WorkManager` for background tasks.
|
|
51
|
+
- Never launch from `GlobalScope`. Never call `runBlocking` on the main thread.
|
|
52
|
+
- Cold flows (`flow { }`, `flowOf`) for one-shot streams; hot flows (`MutableStateFlow`, `MutableSharedFlow`) for UI state and event buses. `LiveData` is legacy — use `StateFlow` for new code.
|
|
53
|
+
- Use `Dispatchers.IO` for blocking I/O, `Dispatchers.Default` for CPU-bound work. The main dispatcher is for UI updates only; no blocking work there.
|
|
54
|
+
|
|
55
|
+
## Persistence
|
|
56
|
+
|
|
57
|
+
- Room is the SQL persistence floor. Define `@Entity`, `@Dao`, and a `@Database` class with a versioned schema. Migration paths via `Migration` objects committed to VCS.
|
|
58
|
+
- DataStore (Preferences or Proto) for key-value and structured preferences. SharedPreferences is legacy — do not adopt for new code.
|
|
59
|
+
- For network sync: WorkManager with `Constraints` (network, charging, battery) + exponential backoff. Never use `JobScheduler` directly — WorkManager wraps it and handles edge cases.
|
|
60
|
+
- Bind Room DAOs and DataStore to coroutines / Flow — suspend functions for one-shot queries, `Flow<T>` for observed reads.
|
|
61
|
+
|
|
62
|
+
## Networking
|
|
63
|
+
|
|
64
|
+
- Use Retrofit 2.11+ with kotlinx-serialization-converter or Moshi (Gson is in maintenance — prefer one of the modern serializers). Configure OkHttp logging interceptor only in debug builds.
|
|
65
|
+
- Ktor Client is the alternative when the app shares a multi-platform stack with Kotlin Multiplatform.
|
|
66
|
+
- Configure timeouts on every OkHttp client: connect (10s), read (30s), write (15s). Default timeouts are unbounded — production apps must override.
|
|
67
|
+
- Certificate pinning (`CertificatePinner`) for high-security endpoints. Always include a backup pin and a rotation schedule.
|
|
68
|
+
|
|
69
|
+
## Testing
|
|
70
|
+
|
|
71
|
+
- Unit tests with JUnit 5 (`org.junit.jupiter:junit-jupiter`) + MockK for mocking. JUnit 4 + Mockito is legacy — do not add for new modules.
|
|
72
|
+
- Coroutine tests with `kotlinx-coroutines-test` (`runTest`, `TestDispatcher`). Never use `Thread.sleep` to wait for async work.
|
|
73
|
+
- Compose UI tests with `androidx.compose.ui:ui-test-junit4`. Use semantics-based matchers (`hasContentDescription`, `hasTestTag`) — avoid text matchers for resilience.
|
|
74
|
+
- Instrumented tests via `androidTest/` source set on emulators or Firebase Test Lab matrices. Configure `testCoverage` in the AGP block; floor 80% line coverage in `feature:` modules.
|
|
75
|
+
- Screenshot tests via Paparazzi (host-side, no emulator needed) or Roborazzi. Update goldens through PR review.
|
|
76
|
+
|
|
77
|
+
## Accessibility
|
|
78
|
+
|
|
79
|
+
- Every interactive composable has `Modifier.semantics { contentDescription = "..." }` or uses Material 3 widgets that provide semantics by default.
|
|
80
|
+
- TalkBack tested on every PR touching UI. The TalkBack-on screenshot test in Paparazzi catches regressions automatically.
|
|
81
|
+
- Dynamic font scaling: respect `MaterialTheme.typography` and avoid hard-coded `.sp` values in layouts. Test with the largest accessibility font size in the system settings.
|
|
82
|
+
- Touch targets: minimum 48dp × 48dp per Material 3 guidelines. `Modifier.minimumInteractiveComponentSize()` enforces this when composables are below 48dp.
|
|
83
|
+
|
|
84
|
+
## Distribution
|
|
85
|
+
|
|
86
|
+
- Sign release builds with Play App Signing — Google holds the upload key, you hold the signing key in escrow. Configure via Play Console.
|
|
87
|
+
- App Bundle (`*.aab`) for Play Store, APK only for sideload / direct distribution. Enable `bundle { language { enableSplit = true } }`.
|
|
88
|
+
- ProGuard / R8 on release builds (`isMinifyEnabled = true`, `isShrinkResources = true`). Maintain `proguard-rules.pro` per module; verify post-shrink builds in CI before publishing.
|
|
89
|
+
- Use Crashlytics or Sentry for crash reporting. Symbolicate native crashes via NDK symbol upload in CI.
|
|
90
|
+
|
|
91
|
+
## References
|
|
92
|
+
|
|
93
|
+
- AGP 8.x release notes: https://developer.android.com/build/releases/gradle-plugin (accessed 2026-05-27, official-docs)
|
|
94
|
+
- Jetpack Compose: https://developer.android.com/jetpack/compose (accessed 2026-05-27, official-docs)
|
|
95
|
+
- Coroutines + Flow: https://kotlinlang.org/docs/coroutines-overview.html (accessed 2026-05-27, official-docs)
|
|
96
|
+
- Google Play target SDK 35 requirement: https://developer.android.com/google/play/requirements/target-sdk (accessed 2026-05-27, official-docs)
|
|
97
|
+
|
|
98
|
+
## Cross-References
|
|
99
|
+
|
|
100
|
+
- `rules/hatch3r-component-conventions.md` — four-state surface contract maps to Compose `StateFlow<UiState>` patterns.
|
|
101
|
+
- `rules/hatch3r-testing.md` — coverage thresholds and determinism rules apply to JUnit / Compose tests.
|
|
102
|
+
- `rules/hatch3r-accessibility-standards.md` — WCAG mapping for Compose `semantics { ... }` modifiers.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-anti-duplication
|
|
3
|
+
type: rule
|
|
4
|
+
description: Pre-implementation discovery gate (codebase pattern search) + post-write duplication scan (jscpd threshold per maturity tier). Silent duplication is a P4 violation.
|
|
5
|
+
tags: [anti-duplication, code-quality, floor:content-quality]
|
|
6
|
+
precedence: high
|
|
7
|
+
scope: always
|
|
8
|
+
---
|
|
9
|
+
# hatch3r Anti-Duplication
|
|
10
|
+
|
|
11
|
+
**Pillars:** P4 (Comprehensive Lean Coverage), CQ8 (Maintainability Quality)
|
|
12
|
+
|
|
13
|
+
## Pre-Implementation Discovery Gate
|
|
14
|
+
|
|
15
|
+
Before writing any new function, type, or pattern:
|
|
16
|
+
|
|
17
|
+
1. **Grep existing surface** for similar function names: `grep -rn "function.*<similar-name>" src/`
|
|
18
|
+
2. **Grep existing surface** for similar type shapes: `grep -rn "type.*<similar-shape>" src/`
|
|
19
|
+
3. **Grep existing surface** for similar comment headers: `grep -rn "// <similar-purpose>" src/`
|
|
20
|
+
4. **Read closest existing match** end-to-end to confirm it does NOT cover the new requirement.
|
|
21
|
+
|
|
22
|
+
If a similar artifact exists with ≥80% scope overlap, do one of:
|
|
23
|
+
|
|
24
|
+
- Extend the existing artifact with the additional case.
|
|
25
|
+
- Refactor into a shared abstraction consumed by both.
|
|
26
|
+
- Document the distinct scope as an ADR before authoring the new artifact.
|
|
27
|
+
|
|
28
|
+
Report findings of the discovery scan in the iteration summary §Files Mutated section.
|
|
29
|
+
|
|
30
|
+
## Post-Write Duplication Scan
|
|
31
|
+
|
|
32
|
+
After every implementation:
|
|
33
|
+
|
|
34
|
+
1. Run `npx jscpd <changed-dirs>` (or equivalent: PMD CPD, simian, sonar-scanner).
|
|
35
|
+
2. Flag any block matching ≥30 lines OR ≥80% similarity with existing code.
|
|
36
|
+
3. Refactor or justify before merge.
|
|
37
|
+
|
|
38
|
+
Tools accepted as equivalent: `jscpd` (Node), `PMD CPD` (Java/multi-lang), `simian` (multi-lang), `sonar-scanner` duplication module. Pick by toolchain; the threshold below is tool-agnostic.
|
|
39
|
+
|
|
40
|
+
## Tunable Thresholds Per Maturity Tier
|
|
41
|
+
|
|
42
|
+
Per `hatch3r config maturity=<tier>`:
|
|
43
|
+
|
|
44
|
+
- **solo** — jscpd threshold ≤10% (relaxed for early-stage exploration)
|
|
45
|
+
- **team** — jscpd threshold ≤7%
|
|
46
|
+
- **scaleup** — jscpd threshold ≤5%
|
|
47
|
+
- **enterprise** — jscpd threshold ≤3%
|
|
48
|
+
|
|
49
|
+
Tier set via `hatch3r config maturity=<tier>` per CONSTITUTION §6 Decision #16 (Decision 4 in fresh-session-prompt mapping). Threshold breach blocks merge until the offending block is refactored or justified with an inline ADR comment.
|
|
50
|
+
|
|
51
|
+
## Silent Duplication Violation
|
|
52
|
+
|
|
53
|
+
Per CONSTITUTION §2 P4: Single Source of Truth. Silent duplication (no ADR, no refactor) is a P4 violation surfaced by D16 Compound System audit + D22 Content Architecture audit (after authoring).
|
|
54
|
+
|
|
55
|
+
Per CONSTITUTION §2 P5 Silent Failure Contract: a duplication scan that finds matches but emits no warning to the caller is itself a contract violation — the scan must surface findings via the iteration summary or a CI gate.
|
|
56
|
+
|
|
57
|
+
## Discovery Gate Output Schema
|
|
58
|
+
|
|
59
|
+
Report from the pre-implementation grep step lands in the iteration summary as:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
discovery_scan:
|
|
63
|
+
greps_run: <integer>
|
|
64
|
+
candidate_matches: <integer>
|
|
65
|
+
closest_match_path: <relative-path>
|
|
66
|
+
overlap_assessment: none | partial | high (≥80%)
|
|
67
|
+
decision: new-artifact | extend-existing | refactor-shared | adr-distinct
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`overlap_assessment: high` without `decision: extend-existing | refactor-shared | adr-distinct` is a P4 violation — author is creating a duplicate.
|
|
71
|
+
|
|
72
|
+
## Worked Example
|
|
73
|
+
|
|
74
|
+
Task: add a function that formats an ISO-8601 timestamp for a CLI log line.
|
|
75
|
+
|
|
76
|
+
1. Discovery grep: `grep -rn "function format.*Date\|function format.*Time\|function format.*Timestamp" src/`.
|
|
77
|
+
2. Closest match found: `src/cli/util/format.ts::formatLocalTime(date: Date): string` — 11 lines, formats `HH:mm:ss` only.
|
|
78
|
+
3. Overlap assessment: `partial` — same domain (date formatting) but distinct output shape (timestamp vs time-of-day).
|
|
79
|
+
4. Decision: `extend-existing` — add a `format: "iso" | "local"` parameter to `formatLocalTime`, rename to `formatTime`, update 3 callers.
|
|
80
|
+
5. Post-write scan: `npx jscpd src/cli/util/` reports 0% duplication on the change. Merge.
|
|
81
|
+
|
|
82
|
+
The discovery step took ~30 seconds; it prevented a parallel `formatIsoTimestamp` function and a forked test file.
|
|
83
|
+
|
|
84
|
+
## Skip Conditions
|
|
85
|
+
|
|
86
|
+
The discovery + scan procedure binds every code-writing turn EXCEPT:
|
|
87
|
+
|
|
88
|
+
- Single-line edits to existing functions (bug fix, typo, error-message wording).
|
|
89
|
+
- Frontmatter-only edits to canonical content artifacts.
|
|
90
|
+
- Test-file edits that mirror an existing source-file change (the test mirrors a function the discovery step already ran on).
|
|
91
|
+
- Cosmetic edits (whitespace, comment wording, import sorting).
|
|
92
|
+
|
|
93
|
+
When skipped, declare `discovery_scan: skipped (reason: <reason>)` in the iteration summary. Skipping without declaration is itself a P5 silent-failure violation per CONSTITUTION §2 P5 Silent Failure Contract.
|
|
94
|
+
|
|
95
|
+
## Enforcement
|
|
96
|
+
|
|
97
|
+
- `agents/shared/quality-charter.md` §12 binds every agent to this procedure.
|
|
98
|
+
- `agents/hatch3r-implementer.md` runs the discovery gate before writing.
|
|
99
|
+
- `agents/hatch3r-reviewer.md` runs the duplication scan in review.
|
|
100
|
+
- The compound-system and content-architecture audit domains audit duplication at cycle time.
|
|
101
|
+
|
|
102
|
+
## Pillar Service
|
|
103
|
+
|
|
104
|
+
- P4 — every artifact earns its existence; no redundant code or content.
|
|
105
|
+
- CQ8 — generated code carries the same anti-duplication discipline (jscpd ≤5% per CONSTITUTION §2 CQ8 Measurement).
|
|
106
|
+
|
|
107
|
+
## References
|
|
108
|
+
|
|
109
|
+
- CONSTITUTION §6 Decision #21 (pre-implementation discovery + post-write duplication scan).
|
|
110
|
+
- CONSTITUTION §6 Decision #16 (maturity tier `solo|team|scaleup|enterprise`).
|
|
111
|
+
- CONSTITUTION §2 P4 (Single Source of Truth).
|
|
112
|
+
- CONSTITUTION §2 CQ8 (Maintainability Measurement — jscpd ≤5% per cycle).
|
|
113
|
+
- `agents/shared/quality-charter.md` §12 (Anti-Duplication Procedure).
|
|
114
|
+
- The compound-system audit domain (duplication candidate threshold SA 16.3).
|
|
115
|
+
- The content-architecture audit domain (content-corpus duplication audit; authored in subsequent cycle).
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: hatch3r-anti-duplication
|
|
3
|
+
type: rule
|
|
4
|
+
description: Pre-implementation discovery gate (codebase pattern search) + post-write duplication scan (jscpd threshold per maturity tier). Silent duplication is a P4 violation.
|
|
5
|
+
tags: [anti-duplication, code-quality, floor:content-quality]
|
|
6
|
+
precedence: high
|
|
7
|
+
alwaysApply: true
|
|
8
|
+
---
|
|
9
|
+
# hatch3r Anti-Duplication
|
|
10
|
+
|
|
11
|
+
**Pillars:** P4 (Comprehensive Lean Coverage), CQ8 (Maintainability Quality)
|
|
12
|
+
|
|
13
|
+
## Pre-Implementation Discovery Gate
|
|
14
|
+
|
|
15
|
+
Before writing any new function, type, or pattern:
|
|
16
|
+
|
|
17
|
+
1. **Grep existing surface** for similar function names: `grep -rn "function.*<similar-name>" src/`
|
|
18
|
+
2. **Grep existing surface** for similar type shapes: `grep -rn "type.*<similar-shape>" src/`
|
|
19
|
+
3. **Grep existing surface** for similar comment headers: `grep -rn "// <similar-purpose>" src/`
|
|
20
|
+
4. **Read closest existing match** end-to-end to confirm it does NOT cover the new requirement.
|
|
21
|
+
|
|
22
|
+
If a similar artifact exists with ≥80% scope overlap, do one of:
|
|
23
|
+
|
|
24
|
+
- Extend the existing artifact with the additional case.
|
|
25
|
+
- Refactor into a shared abstraction consumed by both.
|
|
26
|
+
- Document the distinct scope as an ADR before authoring the new artifact.
|
|
27
|
+
|
|
28
|
+
Report findings of the discovery scan in the iteration summary §Files Mutated section.
|
|
29
|
+
|
|
30
|
+
## Post-Write Duplication Scan
|
|
31
|
+
|
|
32
|
+
After every implementation:
|
|
33
|
+
|
|
34
|
+
1. Run `npx jscpd <changed-dirs>` (or equivalent: PMD CPD, simian, sonar-scanner).
|
|
35
|
+
2. Flag any block matching ≥30 lines OR ≥80% similarity with existing code.
|
|
36
|
+
3. Refactor or justify before merge.
|
|
37
|
+
|
|
38
|
+
Tools accepted as equivalent: `jscpd` (Node), `PMD CPD` (Java/multi-lang), `simian` (multi-lang), `sonar-scanner` duplication module. Pick by toolchain; the threshold below is tool-agnostic.
|
|
39
|
+
|
|
40
|
+
## Tunable Thresholds Per Maturity Tier
|
|
41
|
+
|
|
42
|
+
Per `hatch3r config maturity=<tier>`:
|
|
43
|
+
|
|
44
|
+
- **solo** — jscpd threshold ≤10% (relaxed for early-stage exploration)
|
|
45
|
+
- **team** — jscpd threshold ≤7%
|
|
46
|
+
- **scaleup** — jscpd threshold ≤5%
|
|
47
|
+
- **enterprise** — jscpd threshold ≤3%
|
|
48
|
+
|
|
49
|
+
Tier set via `hatch3r config maturity=<tier>` per CONSTITUTION §6 Decision #16 (Decision 4 in fresh-session-prompt mapping). Threshold breach blocks merge until the offending block is refactored or justified with an inline ADR comment.
|
|
50
|
+
|
|
51
|
+
## Silent Duplication Violation
|
|
52
|
+
|
|
53
|
+
Per CONSTITUTION §2 P4: Single Source of Truth. Silent duplication (no ADR, no refactor) is a P4 violation surfaced by D16 Compound System audit + D22 Content Architecture audit (after authoring).
|
|
54
|
+
|
|
55
|
+
Per CONSTITUTION §2 P5 Silent Failure Contract: a duplication scan that finds matches but emits no warning to the caller is itself a contract violation — the scan must surface findings via the iteration summary or a CI gate.
|
|
56
|
+
|
|
57
|
+
## Discovery Gate Output Schema
|
|
58
|
+
|
|
59
|
+
Report from the pre-implementation grep step lands in the iteration summary as:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
discovery_scan:
|
|
63
|
+
greps_run: <integer>
|
|
64
|
+
candidate_matches: <integer>
|
|
65
|
+
closest_match_path: <relative-path>
|
|
66
|
+
overlap_assessment: none | partial | high (≥80%)
|
|
67
|
+
decision: new-artifact | extend-existing | refactor-shared | adr-distinct
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`overlap_assessment: high` without `decision: extend-existing | refactor-shared | adr-distinct` is a P4 violation — author is creating a duplicate.
|
|
71
|
+
|
|
72
|
+
## Worked Example
|
|
73
|
+
|
|
74
|
+
Task: add a function that formats an ISO-8601 timestamp for a CLI log line.
|
|
75
|
+
|
|
76
|
+
1. Discovery grep: `grep -rn "function format.*Date\|function format.*Time\|function format.*Timestamp" src/`.
|
|
77
|
+
2. Closest match found: `src/cli/util/format.ts::formatLocalTime(date: Date): string` — 11 lines, formats `HH:mm:ss` only.
|
|
78
|
+
3. Overlap assessment: `partial` — same domain (date formatting) but distinct output shape (timestamp vs time-of-day).
|
|
79
|
+
4. Decision: `extend-existing` — add a `format: "iso" | "local"` parameter to `formatLocalTime`, rename to `formatTime`, update 3 callers.
|
|
80
|
+
5. Post-write scan: `npx jscpd src/cli/util/` reports 0% duplication on the change. Merge.
|
|
81
|
+
|
|
82
|
+
The discovery step took ~30 seconds; it prevented a parallel `formatIsoTimestamp` function and a forked test file.
|
|
83
|
+
|
|
84
|
+
## Skip Conditions
|
|
85
|
+
|
|
86
|
+
The discovery + scan procedure binds every code-writing turn EXCEPT:
|
|
87
|
+
|
|
88
|
+
- Single-line edits to existing functions (bug fix, typo, error-message wording).
|
|
89
|
+
- Frontmatter-only edits to canonical content artifacts.
|
|
90
|
+
- Test-file edits that mirror an existing source-file change (the test mirrors a function the discovery step already ran on).
|
|
91
|
+
- Cosmetic edits (whitespace, comment wording, import sorting).
|
|
92
|
+
|
|
93
|
+
When skipped, declare `discovery_scan: skipped (reason: <reason>)` in the iteration summary. Skipping without declaration is itself a P5 silent-failure violation per CONSTITUTION §2 P5 Silent Failure Contract.
|
|
94
|
+
|
|
95
|
+
## Enforcement
|
|
96
|
+
|
|
97
|
+
- `agents/shared/quality-charter.md` §12 binds every agent to this procedure.
|
|
98
|
+
- `agents/hatch3r-implementer.md` runs the discovery gate before writing.
|
|
99
|
+
- `agents/hatch3r-reviewer.md` runs the duplication scan in review.
|
|
100
|
+
- The compound-system and content-architecture audit domains audit duplication at cycle time.
|
|
101
|
+
|
|
102
|
+
## Pillar Service
|
|
103
|
+
|
|
104
|
+
- P4 — every artifact earns its existence; no redundant code or content.
|
|
105
|
+
- CQ8 — generated code carries the same anti-duplication discipline (jscpd ≤5% per CONSTITUTION §2 CQ8 Measurement).
|
|
106
|
+
|
|
107
|
+
## References
|
|
108
|
+
|
|
109
|
+
- CONSTITUTION §6 Decision #21 (pre-implementation discovery + post-write duplication scan).
|
|
110
|
+
- CONSTITUTION §6 Decision #16 (maturity tier `solo|team|scaleup|enterprise`).
|
|
111
|
+
- CONSTITUTION §2 P4 (Single Source of Truth).
|
|
112
|
+
- CONSTITUTION §2 CQ8 (Maintainability Measurement — jscpd ≤5% per cycle).
|
|
113
|
+
- `agents/shared/quality-charter.md` §12 (Anti-Duplication Procedure).
|
|
114
|
+
- The compound-system audit domain (duplication candidate threshold SA 16.3).
|
|
115
|
+
- The content-architecture audit domain (content-corpus duplication audit; authored in subsequent cycle).
|
|
@@ -2,13 +2,17 @@
|
|
|
2
2
|
id: hatch3r-api-design
|
|
3
3
|
type: rule
|
|
4
4
|
description: REST, GraphQL, and gRPC contract patterns covering versioning, auth, CORS, pagination, webhooks, rate limiting, and security headers
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/api/**,**/routes/**,**/controllers/**,**/endpoints/**,**/*route*,**/*controller*,**/*endpoint*,**/*handler*,**/graphql/**,**/trpc/**"
|
|
6
7
|
tags: [planning]
|
|
8
|
+
precedence: high
|
|
7
9
|
quality_charter: agents/shared/quality-charter.md
|
|
8
10
|
cache_friendly: true
|
|
9
11
|
---
|
|
10
12
|
# API Design
|
|
11
13
|
|
|
14
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ9 (Enhancability Quality)
|
|
15
|
+
|
|
12
16
|
- Use consistent request/response schemas. Document in spec files.
|
|
13
17
|
- All endpoints versioned (URL prefix or header). Backward-compatible changes only.
|
|
14
18
|
- Additive changes only: add fields, never rename or remove without migration.
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
description: REST, GraphQL, and gRPC contract patterns covering versioning, auth, CORS, pagination, webhooks, rate limiting, and security headers
|
|
3
3
|
globs: ["**/api/**", "**/routes/**", "**/controllers/**", "**/endpoints/**", "**/*route*", "**/*controller*", "**/*endpoint*", "**/*handler*", "**/graphql/**", "**/trpc/**"]
|
|
4
4
|
alwaysApply: false
|
|
5
|
+
precedence: high
|
|
5
6
|
---
|
|
6
7
|
# API Design
|
|
7
8
|
|
|
9
|
+
**Pillars:** P2 (Scientific & Practical Quality), CQ9 (Enhancability Quality)
|
|
10
|
+
|
|
8
11
|
- Use consistent request/response schemas. Document in spec files.
|
|
9
12
|
- All endpoints versioned (URL prefix or header). Backward-compatible changes only.
|
|
10
13
|
- Additive changes only: add fields, never rename or remove without migration.
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-api-versioning
|
|
3
3
|
type: rule
|
|
4
4
|
description: API versioning, deprecation lifecycle, and idempotency — RFC 9457 errors, RFC 9745 Deprecation header, RFC 8594 Sunset, OAuth 2.1, Idempotency-Key, semver vs CalVer for APIs
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/api/**,**/openapi*,**/asyncapi*,**/*.proto,**/routes/**,**/handlers/**,**/controllers/**"
|
|
6
7
|
tags: [implementation, devops]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
id: hatch3r-auth-patterns
|
|
3
3
|
type: rule
|
|
4
4
|
description: Authentication and authorization patterns for end-user apps — OAuth 2.1, OIDC, DPoP, JWT rotation, cookie security, RBAC vs ABAC vs ReBAC rubric
|
|
5
|
-
scope:
|
|
5
|
+
scope: conditional
|
|
6
|
+
globs: "**/auth/**,**/login/**,**/session/**,**/oauth/**,**/oidc/**,**/jwt/**,**/permissions/**,**/policies/**,**/middleware/**"
|
|
6
7
|
tags: [implementation, floor:security]
|
|
7
8
|
precedence: high
|
|
8
9
|
quality_charter: agents/shared/quality-charter.md
|
|
@@ -151,6 +152,7 @@ Required event set: login success, login failure, MFA challenge issued, MFA veri
|
|
|
151
152
|
|
|
152
153
|
## Cross-References
|
|
153
154
|
|
|
155
|
+
- `rules/hatch3r-security-patterns.md` — general application security (input validation, output encoding, OWASP/ASI). Auth middleware, token validation, session security, and MFA/AAL mapping live here, not there; security-patterns delegates them to this rule to avoid double-firing on `**/auth/**` + `**/middleware/**`.
|
|
154
156
|
- `rules/hatch3r-passkey-server.md` — server-side WebAuthn ceremony (paired companion).
|
|
155
157
|
- `rules/hatch3r-ux-states-and-flows.md` — frontend identifier-first login + Conditional UI.
|
|
156
158
|
- `rules/hatch3r-ai-ux-patterns.md` — frontend WebAuthn UX patterns.
|
|
@@ -147,6 +147,7 @@ Required event set: login success, login failure, MFA challenge issued, MFA veri
|
|
|
147
147
|
|
|
148
148
|
## Cross-References
|
|
149
149
|
|
|
150
|
+
- `rules/hatch3r-security-patterns.md` — general application security (input validation, output encoding, OWASP/ASI). Auth middleware, token validation, session security, and MFA/AAL mapping live here, not there; security-patterns delegates them to this rule to avoid double-firing on `**/auth/**` + `**/middleware/**`.
|
|
150
151
|
- `rules/hatch3r-passkey-server.md` — server-side WebAuthn ceremony (paired companion).
|
|
151
152
|
- `rules/hatch3r-ux-states-and-flows.md` — frontend identifier-first login + Conditional UI.
|
|
152
153
|
- `rules/hatch3r-ai-ux-patterns.md` — frontend WebAuthn UX patterns.
|