Files
ruflo/v2/bin/init/templates/commands/hooks/pre-command.md
T
rUvandClaude Opus 4.5 1b6a1971f7 feat(v3): add comprehensive v3 implementation plans and swarm architecture
- Reorganize v3/ into implementation/ subfolders:
  - planning/, architecture/, migration/, integration/
  - security/, adrs/, research/, swarm-plans/

- Add 15-agent concurrent swarm implementation plans:
  - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases
  - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities
  - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology
  - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x)
  - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback
  - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies

- Update .claude/settings.json with proper hooks format
- Add bash aliases for claude --dangerously-skip-permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:40:51 +00:00

2.1 KiB

hook pre-command

Execute pre-command validations and safety checks before running shell commands.

Usage

npx claude-flow hook pre-command [options]

Options

  • --command, -c <cmd> - Command to be executed
  • --validate-safety - Check command safety (default: true)
  • --check-permissions - Verify execution permissions
  • --estimate-duration - Estimate command runtime
  • --dry-run - Preview without executing

Examples

Basic pre-command hook

npx claude-flow hook pre-command --command "npm install express"

Safety validation

npx claude-flow hook pre-command -c "rm -rf node_modules" --validate-safety

Permission check

npx claude-flow hook pre-command -c "sudo apt update" --check-permissions

Dry run preview

npx claude-flow hook pre-command -c "git push origin main" --dry-run

Features

Safety Validation

  • Detects dangerous commands
  • Warns about destructive operations
  • Checks for sudo/admin usage
  • Validates command syntax

Permission Checking

  • Verifies execution rights
  • Checks directory access
  • Validates file permissions
  • Ensures proper context

Duration Estimation

  • Predicts execution time
  • Warns about long operations
  • Suggests timeouts
  • Tracks historical data

Dry Run Mode

  • Shows command effects
  • Lists files affected
  • Previews changes
  • No actual execution

Integration

This hook is automatically called by Claude Code when:

  • Using Bash tool
  • Running shell commands
  • Executing npm/pip/cargo commands
  • System operations

Manual usage in agents:

# Before running commands
npx claude-flow hook pre-command --command "your command here" --validate-safety

Output

Returns JSON with:

{
  "continue": true,
  "command": "npm install express",
  "safe": true,
  "estimatedDuration": 15000,
  "warnings": [],
  "permissions": "user",
  "affectedFiles": ["package.json", "package-lock.json"],
  "dryRunOutput": "Would install 50 packages"
}

See Also

  • hook post-command - Post-command processing
  • Bash - Command execution tool
  • terminal execute - Terminal operations
  • security scan - Security validation