v2/bin/init/templates/commands/hooks/post-command.md
Execute post-command processing including output analysis and state updates.
npx claude-flow hook post-command [options]
--command, -c <cmd> - Command that was executed--exit-code, -e <code> - Command exit code--analyze-output - Analyze command output (default: true)--update-cache - Update command cache--track-metrics - Track performance metricsnpx claude-flow hook post-command --command "npm test" --exit-code 0
npx claude-flow hook post-command -c "git status" -e 0 --analyze-output
npx claude-flow hook post-command -c "npm list" -e 0 --update-cache
npx claude-flow hook post-command -c "build.sh" -e 0 --track-metrics
This hook is automatically called by Claude Code when:
Manual usage in agents:
# After running commands
npx claude-flow hook post-command --command "npm build" --exit-code 0 --analyze-output
Returns JSON with:
{
"command": "npm test",
"exitCode": 0,
"duration": 45230,
"outputSummary": "All 42 tests passed",
"cached": true,
"metrics": {
"cpuUsage": "45%",
"memoryPeak": "256MB"
},
"stateChanges": ["test-results.json updated"],
"warnings": []
}
hook pre-command - Pre-command validationBash - Command execution toolcache manage - Cache operationsmetrics collect - Performance data