Skip to content

feat: Implement hooks system (PreToolUse, PostToolUse) #101

Description

@CarGDev

Summary

Implement a hooks system that allows intercepting tool execution before and after it happens.

Why It's Needed

  • Safety: Block dangerous commands before execution
  • Backup: Create file backups before modifications
  • Security: Prevent credential exposure
  • Extensibility: Enable plugins and custom workflows

Hook Types to Implement

PreToolUse

  • Fires before any tool executes
  • Can block, allow, or modify tool input
  • Returns: { decision: "allow" | "deny" | "ask", modifiedInput?, message? }

PostToolUse

  • Fires after tool completes
  • Can log results, provide feedback, trigger follow-up
  • Returns: { feedback?, metadata? }

Configuration Format

{
  "hooks": {
    "PreToolUse": [
      {
        "name": "security-check",
        "matcher": "bash|write|edit",
        "script": ".codetyper/hooks/security.ts"
      }
    ]
  }
}

Acceptance Criteria

  • Hook registration and discovery
  • PreToolUse hook with allow/deny/ask decisions
  • PostToolUse hook with feedback support
  • Matcher patterns for tool filtering
  • Timeout handling for hooks
  • Built-in hook examples

Effort Estimate

3 days

References

  • Claude Code: 10 hook types
  • OpenCode: 12+ hook types

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthooksHooks systempriority-criticalCritical priority - implement first

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions