Summary
Add PostToolUse hooks that automatically run fast quality checks after file edits — formatting, type checking, console.log detection. Distinct from PreToolUse enforcement (#98) which blocks unwanted actions; PostToolUse hooks run AFTER successful tool execution and provide advisory feedback.
Motivation (from Harness Alpha Analysis)
Harness Alpha implements 7 PostToolUse hooks that catch issues at edit-time rather than waiting for end-of-workflow review:
| Hook |
Trigger |
Action |
| post-edit-format |
After Edit/Write on .js/.ts |
Auto-format with Biome or Prettier (async) |
| post-edit-typecheck |
After Edit/Write on .ts |
Run tsc --noEmit on changed file (async) |
| post-edit-console-warn |
After Edit/Write |
Warn if console.log was introduced |
| quality-gate |
After Edit/Write |
Fast quality checklist (async, non-blocking) |
| build-complete |
After Bash (build commands) |
Analyze build output for warnings |
| pr-created |
After Bash (gh pr create) |
Log PR URL and suggest review command |
| observe |
After any tool |
Capture observations for learning (async) |
Why This Is Different from #98
| Aspect |
#98 (PreToolUse) |
This Issue (PostToolUse) |
| Timing |
Before tool runs |
After tool completes |
| Purpose |
Block unwanted actions |
Catch quality issues |
| Effect |
Prevents execution (exit 2) |
Advisory feedback |
| Blocking? |
Yes (gate) |
No (inform) |
| Example |
"Reviewer can't Write" |
"Your edit introduced a type error" |
Why This Matters for DevFlow
Currently, quality issues accumulate during implementation and are caught either by:
- Scrutinizer (end of
/implement — late feedback)
- Manual
npm run build / tsc (user-initiated)
- Self-review (
/self-review — explicit command)
PostToolUse hooks catch issues immediately — before the agent moves on. This prevents cascading errors where one type error leads to workarounds in subsequent edits.
Technical Approach
Phase 1: Core Hooks (High Value, Low Risk)
1. Auto-Format Hook
# scripts/hooks/post-edit-format.sh
# Triggers: PostToolUse on Edit/Write for .ts/.tsx/.js/.jsx
# Detects: Biome (biome.json) → Prettier (.prettierrc) → skip
# Runs: async, non-blocking, 5-second timeout
# Output: Silent on success, warn on format diff
2. TypeScript Check Hook
# scripts/hooks/post-edit-typecheck.sh
# Triggers: PostToolUse on Edit/Write for .ts/.tsx
# Runs: tsc --noEmit --pretty on the changed file
# Output: Warn with error details if type errors found
# Async: Yes, non-blocking
3. Console.log Detection Hook
# scripts/hooks/post-edit-console-warn.sh
# Triggers: PostToolUse on Edit/Write
# Checks: Did the edit introduce console.log/console.debug/console.warn?
# Output: Advisory warning (not blocking)
Phase 2: Extended Hooks (Future)
- Build analysis after Bash commands containing build keywords
- PR creation logging and review command suggestion
- Test result capture after Bash test commands
Integration with Existing Infrastructure
CLI Management
devflow init --quality-hooks # Enable PostToolUse quality hooks
devflow init --no-quality-hooks # Skip (default for now)
Register in settings.json under hooks.PostToolUse[].
Effort & Impact
- Effort: Medium (3 hook scripts + CLI integration + tests)
- Impact: High — catches errors at edit-time instead of end-of-workflow
- Risk: Low — hooks are async and non-blocking; worst case is a false positive warning
Cross-Reference
Summary
Add PostToolUse hooks that automatically run fast quality checks after file edits — formatting, type checking, console.log detection. Distinct from PreToolUse enforcement (#98) which blocks unwanted actions; PostToolUse hooks run AFTER successful tool execution and provide advisory feedback.
Motivation (from Harness Alpha Analysis)
Harness Alpha implements 7 PostToolUse hooks that catch issues at edit-time rather than waiting for end-of-workflow review:
tsc --noEmiton changed file (async)console.logwas introducedWhy This Is Different from #98
Why This Matters for DevFlow
Currently, quality issues accumulate during implementation and are caught either by:
/implement— late feedback)npm run build/tsc(user-initiated)/self-review— explicit command)PostToolUse hooks catch issues immediately — before the agent moves on. This prevents cascading errors where one type error leads to workarounds in subsequent edits.
Technical Approach
Phase 1: Core Hooks (High Value, Low Risk)
1. Auto-Format Hook
2. TypeScript Check Hook
3. Console.log Detection Hook
Phase 2: Extended Hooks (Future)
Integration with Existing Infrastructure
DEVFLOW_HOOK_PROFILEwhen implementedCLI Management
Register in
settings.jsonunderhooks.PostToolUse[].Effort & Impact
Cross-Reference