Skip to main content
hook

plan-gate — Claude Code hook: what it does, how to install

This hook checks for a recent .spec.md before code changes and warns when the project lacks an approved specification.

Install into Claude Code · claude-code-templates All methods and platforms ↓
npx claude-code-templates@latest --hook quality-gates/plan-gate
Open on GitHub

What plan-gate does

plan-gate runs before Claude Code uses Edit, MultiEdit, or Write. Its shell script searches the project directory for .spec.md files from the last 14 days. When it finds no recent specification, it displays a reminder to create one before editing production code.

The check is non-blocking. It exits with code 0, so Claude Code can continue after the warning. The hook supports 16 programming languages and follows the Spec-Driven Development method, where implementation work is backed by an approved specification.

Installation places the executable plan-gate.sh at .claude/hooks/plan-gate.sh. The configured command calls it with bash "$CLAUDE_PROJECT_DIR"/.claude/hooks/plan-gate.sh for each supported tool action. Without a recent .spec.md, the agent still proceeds, but the warning appears first.

What it helps with

  • check for a recent .spec.md before editing code
  • warn when implementation lacks an approved specification
  • remind the agent to prepare a plan before coding
  • cover Edit, MultiEdit, and Write actions

Example prompts for the agent

  • Edit the production code in src/app.ts, and check for a recent project specification first.
  • Create src/payment.py, then warn me if no suitable .spec.md exists.
  • Update several files with MultiEdit and show the plan warning when the specification is stale.

How to install plan-gate

1claude-code-templates

npx claude-code-templates@latest --hook quality-gates/plan-gate

2Manually: put the files in place

.claude/settings.json

The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command

Questions about plan-gate

How do I install plan-gate in Claude Code?

Run npx claude-code-templates@latest --hook quality-gates/plan-gate, then configure .claude/settings.json.

What does plan-gate do?

The hook looks for recent .spec.md files before Edit, MultiEdit, and Write actions. If it finds none, Claude Code receives a warning to prepare a specification.

Does plan-gate stop edits without a specification?

No. The hook exits with code 0, so it reminds the agent without preventing the file operation.

Source text

plan-gate.json · MIT
{
  "description": "Planning gate that warns when editing production code without an approved specification. Checks for recent .spec.md files in the project directory (last 14 days). If no spec is found, shows a warning suggesting to create one first. Non-blocking (exit 0) — acts as a reminder, not a hard gate. Supports 16 programming languages. Part of the Spec-Driven Development (SDD) methodology where every implementation should be backed by an approved specification.",
  "supportingFiles": [
    {
      "source": "plan-gate.sh",
      "destination": ".claude/hooks/plan-gate.sh",
      "executable": true
    }
  ],
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit",
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/plan-gate.sh"
          }
        ]
      },
      {
        "matcher": "MultiEdit",
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/plan-gate.sh"
          }
        ]
      },
      {
        "matcher": "Write",
        "hooks": [
          {
            "type": "command",
            "command": "bash \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/plan-gate.sh"
          }
        ]
      }
    ]
  }
}

© davila7 · MIT · davila7/claude-code-templates

Similar hooks

All hooks for Agent setup: memory, context, orchestration →

From the same set804

The whole set →

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor