Skip to content
Development
Hook

Hooks

What planning-with-files runs automatically, and when. A hook is a command Claude Code fires at a fixed moment, without you asking for it.

From plugin
planning-with-files
28k6 skills13 commands6 hooks

Claude Code

> /plugin marketplace add OthmanAdi/planning-with-files
> /plugin install planning-with-files@planning-with-files

What fires, and when

SessionStart

Fires once when a session begins, and again after a context compaction. It is where a plugin sets up its environment, or restores state the compaction dropped.

  • Matchesstartup|resume|clear|compactsh

UserPromptSubmit

Fires before Claude sees each prompt you send. A plugin can use it to inject context, so the same instruction reaches the model every turn instead of only at session start.

  • sh

PreToolUse

  • MatchesWrite|Edit|Bash|Read|Glob|Grepsh

PostToolUse

  • MatchesWrite|Editsh

PreCompact

  • Matches*sh

Stop

  • sh
Read hooks/hooks.json

In the plugin's words

How planning-with-files describes its own hook set.

Planning with Files lifecycle integration for Claude Code

Where it lives

  • hooks/claude-hook.shGitHub
    Read the script
    #!/bin/sh
    # Claude Code plugin lifecycle dispatcher.
    #
    # Plugin execution is deliberately rooted only at CLAUDE_PLUGIN_ROOT. The
    # standalone skill keeps its own activation-scoped frontmatter hooks, while
    # this launcher is the single plugin-level lifecycle route.
    
    set -u
    
    [ "${PLANNING_DISABLED:-}" = "1" ] && exit 0
    
    EVENT="${1:-}"
    PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-}"
    [ -n "$PLUGIN_ROOT" ] || exit 0
    
    SCRIPTS_DIR="${PLUGIN_ROOT}/scripts"
    INJECT_PLAN="${SCRIPTS_DIR}/inject-plan.sh"
    GATE_STOP="${SCRIPTS_DIR}/gate-stop.sh"
    RESOLVE_PLAN_DIR="${SCRIPTS_DIR}/resolve-plan-dir.sh"
    SESSION_CATCHUP="${SCRIPTS_DIR}/session-catchup.py"
    FAST_PATH="${SCRIPTS_DIR}/inject-plan.py"
    
    # --- One interpreter instead of one fork per tool (v3.17.0). ---
    # Everything below this block answers an event by running resolve-plan-dir.sh
    # and inject-plan.sh, and those answer by forking: realpath, stat, sha256sum,
    # awk, tr, mktemp, head, tail, sed, wc, four Python starts, and a $(...)
    # around most of them. A UserPromptSubmit fire forks about 130 times. On Linux
    # and macOS a fork costs one to three milliseconds. Under Git Bash on Windows
    # it costs about 90 ms, so the same fire took seven to twelve seconds against
    # the 10 s hook timeout: Claude Code discarded the output, the plan never
    # reached the model, and every Bash, Read, Grep and Edit call waited five
    # more seconds in PreToolUse first.
    #
    # scripts/inject-plan.py is a byte-identical twin of the chain below
    # (tests/test_inject_plan_python_parity.py proves it against this file and
    # inject-plan.sh on every CI leg). When a CPython 3 is on PATH the event runs
    # there in one process. The twin exits 0 only when its stdout is the complete
    # answer; any other status, including an interpreter that cannot run it, falls
    # through to the reference chain below unchanged. PWF_FAST_PATH=0 forces the
    # reference chain. The Stop event never takes the fast path because it must
    # forward Claude's stdin payload to gate-stop.sh.
    #
    # The PATH walk below is pure shell on purpose: `$(command -v python3)` is
    # itself a fork, and the whole point of this block is to spend none. The
    # Microsoft Store python.exe/python3.exe aliases are skipped by path: they are
    # discoverable on PATH yet refuse to run a script. python3 is preferred over
    # python across the whole PATH so an old distro's Python 2 `python` is never
    # tried while a python3 exists further down.
    find_python() {
        FOUND_PYTHON=""
        for _fp_explicit in "${PWF_TRUSTED_PYTHON:-}" "${PYTHON_BIN:-}"; do
            [ -n "$_fp_explicit" ] || continue
            case "$_fp_explicit" in
                /*|[A-Za-z]:[\\/]*) ;;
                *) continue ;;
            esac
            case "$_fp_explicit" in
                *[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
            esac
            if [ -f "$_fp_explicit" ] && [ -x "$_fp_explicit" ]; then
                FOUND_PYTHON="$_fp_explicit"
                return 0
            fi
        done
        # set -u is active: an unset IFS or PATH must not kill the dispatcher
        # before the reference chain gets its turn.
        if [ "${IFS+set}" = set ]; then
            _fp_saved_ifs="$IFS"
            _fp_ifs_was_set=1
        else
            _fp_saved_ifs=""
            _fp_ifs_was_set=0
        fi
        for _fp_name in python3 python; do
            IFS=:
            set -f
            for _fp_dir in ${PATH-}; do
                case "$_fp_dir" in
                    /*) ;;
                    *) continue ;;
                esac
                case "$_fp_dir" in
                    *[Ww][Ii][Nn][Dd][Oo][Ww][Ss][Aa][Pp][Pp][Ss]*) continue ;;
                esac
                if [ -f "${_fp_dir}/${_fp_name}" ] && [ -x "${_fp_dir}/${_fp_name}" ]; then
                    FOUND_PYTHON="${_fp_dir}/${_fp_name}"
                    break
                fi
            done
            set +f
            if [ "$_fp_ifs_was_set" = 1 ]; then IFS="$_fp_saved_ifs"; else unset IFS; fi
            [ -n "$FOUND_PYTHON" ] && return 0
        done
        return 1
    }
    
    case "$EVENT" in
        session-start|user-prompt-submit|pre-tool-use|post-tool-use|pre-compact)
            # A recovery with a temporarily missing plan must invalidate a view
            # delivered to the old context. With no cache, keep the zero-probe exit.
            _pretool_recovery=0
            case "$EVENT" in
                session-start|user-prompt-submit|pre-compact)
                    if [ -n "${XDG_CACHE_HOME:-}" ]; then
                        [ ! -d "${XDG_CACHE_HOME}/pwf-pretool" ] || _pretool_recovery=1
                    elif [ -n "${HOME:-}" ]; then
                        [ ! -d "${HOME}/.cache/pwf-pretool" ] || _pretool_recovery=1
                    fi
                    ;;
            esac
            # No planning state where the resolver will look and no selector to
            # validate: every route below answers with nothing, so answer with
            # nothing now, before any interpreter or fork. Byte-identical to the
            # reference chain, which reaches the same silence about ten forks
            # later. A set PLAN_ID or PWF_PLAN_ROOT still gets its refusal notice.
            if [ -z "${PLAN_ID:-}" ] && [ -z "${PWF_PLAN_ROOT:-}" ] \
                && [ ! -f task_plan.md ] && [ ! -d .planning ] && [ "$_pretool_recovery" = 0 ]; then
                exit 0
            fi
            # Own one native payload for these events. Keep Stop's stdin untouched.
            # Preserve it for the shell fallback if the Python twin cannot run.
            HOOK_PAYLOAD="$(cat 2>/dev/null)" || HOOK_PAYLOAD=""
            # Classify before plan resolution or cache mutation, even on fallback.
            # Missing/broken parsing fails closed only for opted-in tool events.
            if [ "${PWF_SKIP_SUBAGENTS:-}" = "1" ]; then
                case "$EVENT" in
                    pre-tool-use|post-tool-use)
                        [ -f "$FAST_PATH" ] && find_python || exit 0
                        _main_agent=$(printf '%s' "$HOOK_PAYLOAD" | "$FOUND_PYTHON" -I -B "$FAST_PATH" --hook-main-agent 2>/dev/null) || exit 0
                        [ "$_main_agent" = "main" ] || exit 0
                        ;;
                esac
            fi
            if [ "${PWF_FAST_PATH:-}" != "0"

Read the script before you install anything that runs on your machine. This is the one part of a plugin that acts without being asked.

@othmanadi
Ships withplanning-with-files

Persistent file-based planning for AI coding agents and long-running tasks. Crash-proof markdown plans, session recovery after /clear and compaction, per-turn re-injection against context rot, deterministic completion gate. Manus-style. Install from npm, the Claude Code plugin marketplace, or npx skills. Codex, Cursor, OpenCode, 60+ agents.

Stars on GitHub

Momentum

stars in total
27.8k
Star history of OthmanAdi/planning-with-files on GitHub, a chart by star-history.com

More plugins that ship hooks.

superpowers

superpowers

A development methodology for coding agents that makes the agent brainstorm before building, follow plans, run parallel work and finish branches in a disciplined way. You get fewer skipped steps and more consistent results from your coding assistant.

15 skills1 hook311k
@obra@obra
Install Plugin
ponytail

ponytail

A Claude Code plugin with skills for auditing a whole repo, reviewing a change, listing deferred shortcut comments, and showing measured savings and a quick command reference.

6 skills10 hooks188k
@dietrichgebert@dietrichgebert
Install Plugin
agent-skills

agent-skills

Walks a software change from a written spec through design, testing, code review, CI/CD, and release, applying the matching engineering skill at each stage. Useful for developers using Claude Code on full development workflows.

25 skills+3112k
@addyosmani@addyosmani
Install Plugin
gsd-core

gsd-core

A spec-driven development workflow for Claude Code that guides a project through planning, phases, milestone audits and fixes. Includes skills to generate tests from UAT criteria and to audit completed work.

72 skills+311k
@open-gsd@open-gsd
Install Plugin
superpowers-zh

superpowers-zh

Chinese-language skill pack for Claude Code that adds workflow guidance for brainstorming, TDD, debugging, and code review, plus Chinese conventions for commits, documentation, and domestic Git platforms like Gitee and Coding.net.

21 skills1 hook8.5k
@jnmetacode@jnmetacode
Install Plugin
socraticode

socraticode

Gives Claude Code semantic search, dependency graph and architecture context over a codebase, so an AI assistant can explore and understand a project's code. Includes skills for indexing a project and managing its file watching.

2 skills+33.4k
@giancarloerra@giancarloerra
Install Plugin
cocoindex-code

cocoindex-code

A lightweight code search engine that uses AST-based semantic search with local embeddings and incremental indexing. It helps Claude Code users find code faster and more efficiently.

1 skill1 MCP+13k
@cocoindex-io@cocoindex-io
Install Plugin
myclaude

myclaude

Bundles skills for developers using Claude Code to run AI coding tasks across Codex, Claude, Gemini, and OpenCode backends. It also covers structured feature development, multi-session agent work with checkpoints, and browser automation via Chrome DevTools.

11 skills+32.8k
@cexll@cexll
Install Plugin

Questions about the hooks in planning-with-files.

Which coding agents can use the hooks in planning-with-files?
The hooks in planning-with-files install in Claude Code and Cursor: each runs Claude Code hooks from .claude/settings.json, so copy the hooks there.