Plan: Agent Quality Gate — Pre-PR Checks#
Summary#
Add a shared pre-commit quality gate that runs unit tests and lint before any agent-created commit is made. Implement using husky (a standard Node.js git-hooks manager) as a pre-commit hook, with override support via a new /agent skip-quality-gate directive, and pass the override flag through the phase-router invocation.
Files#
| File | Action | Description |
|---|---|---|
package.json | modify | Add husky as devDependency; add prepare script to install husky hooks |
.husky/pre-commit | create | Husky pre-commit hook: runs npm run lint && npm run test before each commit |
src/directive/dto/directive.dto.ts | modify | Add 'skip-quality-gate' to ALLOWED_DIRECTIVES |
src/directive/directive.service.ts | modify | Handle skip-quality-gate directive: set flag on task, post confirmation comment |
src/phase-router/phase-router.service.ts | modify | Add skip-quality-gate to VALID_DIRECTIVES; pass quality-gate-override env var to Claude invocation |
src/database/entities/task.entity.ts | modify | Add qualityGateOverride boolean column (default false) |
src/task-state/task-state.service.ts | modify | Add method to set/get quality gate override flag |
src/directive/directive.service.spec.ts | modify | Add test for skip-quality-gate directive handling |
src/phase-router/phase-router.service.spec.ts | modify | Add test for quality gate override pass-through |
Steps#
- Add
skip-quality-gatedirective — add toALLOWED_DIRECTIVESindirective.dto.ts, add handling inDirectiveService.applyDirective()to set aqualityGateOverrideflag on the task entity, and add toVALID_DIRECTIVESin phase-router. - Add
qualityGateOverridecolumn to TaskEntity — boolean column defaulting tofalse. Add setter/getter inTaskStateService. - Install husky and add pre-commit hook — add husky as a devDependency in
package.jsonwith apreparescript; create.husky/pre-committhat runsnpm run lint && npm run test. This replaces the custompre-pr-gate.shapproach with the idiomatic Node.js git-hooks solution. - Wire override env var through phase-router invocation and write tests — in
PhaseRouterService, when building the Claude invocation env fordeliverphase, check task'squalityGateOverrideflag and setQUALITY_GATE_OVERRIDE=1if true. Write unit tests forskip-quality-gatedirective handling and override env passthrough.
Verification#
npm run testpasses with new directive and task entity testsnpm run lintpasses with zero warnings- Manual:
/agent skip-quality-gatesets override flag and posts confirmation comment - Husky pre-commit hook blocks commits when lint or tests fail
Risks#
- Existing in-flight tasks lack the new column — mitigate with SQLite default value (
false), no migration needed.
Open Questions#
- Should
skip-quality-gatebe a one-time override (reset after use) or persist for the task lifetime? Recommend one-time (reset after deliver phase completes).