refactor(workflow): deduplicate deviation rules and commit protocol (#1968) (#2057)

The deviation rules and task commit protocol were duplicated between
gsd-executor.md (agent definition) and execute-plan.md (workflow).
The copies had diverged: the agent had scope boundary and fix attempt
limits the workflow lacked; the workflow had 3 extra commit types
(perf, docs, style) the agent lacked.

Consolidate gsd-executor.md as the single source of truth:
- Add missing commit types (perf, docs, style) to gsd-executor.md
- Replace execute-plan.md's ~90 lines of duplicated content with
  concise references to the agent definition

Saves ~1,600 tokens per workflow spawn and eliminates maintenance
drift between the two copies.

Closes #1968

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tibsfox
2026-04-10 12:17:03 -07:00
committed by GitHub
parent 2a08f11f46
commit 7857d35dc1
2 changed files with 16 additions and 79 deletions

View File

@@ -342,6 +342,9 @@ git add src/types/user.ts
| `fix` | Bug fix, error correction |
| `test` | Test-only changes (TDD RED) |
| `refactor` | Code cleanup, no behavior change |
| `perf` | Performance improvement, no behavior change |
| `docs` | Documentation only |
| `style` | Formatting, whitespace, no logic change |
| `chore` | Config, tooling, dependencies |
**4. Commit:**

View File

@@ -188,32 +188,12 @@ Auth errors during execution are NOT failures — they're expected interaction p
## Deviation Rules
You WILL discover unplanned work. Apply automatically, track all for Summary.
| Rule | Trigger | Action | Permission |
|------|---------|--------|------------|
| **1: Bug** | Broken behavior, errors, wrong queries, type errors, security vulns, race conditions, leaks | Fix → test → verify → track `[Rule 1 - Bug]` | Auto |
| **2: Missing Critical** | Missing essentials: error handling, validation, auth, CSRF/CORS, rate limiting, indexes, logging | Add → test → verify → track `[Rule 2 - Missing Critical]` | Auto |
| **3: Blocking** | Prevents completion: missing deps, wrong types, broken imports, missing env/config/files, circular deps | Fix blocker → verify proceeds → track `[Rule 3 - Blocking]` | Auto |
| **4: Architectural** | Structural change: new DB table, schema change, new service, switching libs, breaking API, new infra | STOP → present decision (below) → track `[Rule 4 - Architectural]` | Ask user |
**Rule 4 format:**
```
⚠️ Architectural Decision Needed
Current task: [task name]
Discovery: [what prompted this]
Proposed change: [modification]
Why needed: [rationale]
Impact: [what this affects]
Alternatives: [other approaches]
Proceed with proposed change? (yes / different approach / defer)
```
**Priority:** Rule 4 (STOP) > Rules 1-3 (auto) > unsure → Rule 4
**Edge cases:** missing validation → R2 | null crash → R1 | new table → R4 | new column → R1/2
**Heuristic:** Affects correctness/security/completion? → R1-3. Maybe? → R4.
Apply deviation rules from the gsd-executor agent definition (single source of truth):
- **Rules 1-3** (bugs, missing critical, blockers): auto-fix, test, verify, track as deviations
- **Rule 4** (architectural changes): STOP, present decision to user, await approval
- **Scope boundary**: do not auto-fix pre-existing issues unrelated to current task
- **Fix attempt limit**: max 3 retries per deviation before escalating
- **Priority**: Rule 4 (STOP) > Rules 1-3 (auto) > unsure → Rule 4
</deviation_rules>
@@ -266,59 +246,13 @@ If a commit is BLOCKED by a hook:
<task_commit>
## Task Commit Protocol
After each task (verification passed, done criteria met), commit immediately.
**1. Check:** `git status --short`
**2. Stage individually** (NEVER `git add .` or `git add -A`):
```bash
git add src/api/auth.ts
git add src/types/user.ts
```
**3. Commit type:**
| Type | When | Example |
|------|------|---------|
| `feat` | New functionality | feat(08-02): create user registration endpoint |
| `fix` | Bug fix | fix(08-02): correct email validation regex |
| `test` | Test-only (TDD RED) | test(08-02): add failing test for password hashing |
| `refactor` | No behavior change (TDD REFACTOR) | refactor(08-02): extract validation to helper |
| `perf` | Performance | perf(08-02): add database index |
| `docs` | Documentation | docs(08-02): add API docs |
| `style` | Formatting | style(08-02): format auth module |
| `chore` | Config/deps | chore(08-02): add bcrypt dependency |
**4. Format:** `{type}({phase}-{plan}): {description}` with bullet points for key changes.
<sub_repos_commit_flow>
**Sub-repos mode:** If `sub_repos` is configured (non-empty array from init context), use `commit-to-subrepo` instead of standard git commit. This routes files to their correct sub-repo based on path prefix.
```bash
node ~/.claude/get-shit-done/bin/gsd-tools.cjs commit-to-subrepo "{type}({phase}-{plan}): {description}" --files file1 file2 ...
```
The command groups files by sub-repo prefix and commits atomically to each. Returns JSON: `{ committed: true, repos: { "backend": { hash: "abc", files: [...] }, ... } }`.
Record hashes from each repo in the response for SUMMARY tracking.
**If `sub_repos` is empty or not set:** Use standard git commit flow below.
</sub_repos_commit_flow>
**5. Record hash:**
```bash
TASK_COMMIT=$(git rev-parse --short HEAD)
TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
```
**6. Check for untracked generated files:**
```bash
git status --short | grep '^??'
```
If new untracked files appeared after running scripts or tools, decide for each:
- **Commit it** — if it's a source file, config, or intentional artifact
- **Add to .gitignore** — if it's a generated/runtime output (build artifacts, `.env` files, cache files, compiled output)
- Do NOT leave generated files untracked
Follow the task commit protocol from the gsd-executor agent definition (single source of truth):
- Stage files individually (NEVER `git add .` or `git add -A`)
- Format: `{type}({phase}-{plan}): {concise description}` with bullet points for key changes
- Types: feat, fix, test, refactor, perf, docs, style, chore
- Sub-repos: use `commit-to-subrepo` when `sub_repos` is configured
- Record commit hash for SUMMARY tracking
- Check for untracked generated files after each commit
</task_commit>