analyzing-codebases
Detects project languages and monorepo state, runs language-appropriate static analysis (dependency graph, complexity, duplication, semantic patterns), and…
Creates Claude Code hooks that enforce code quality, static analysis, or workflow automation deterministically. Use when user says "add hook", "enforce linting", "add pre-commit check", "block bad code".
$ npx -y skills add wayne930242/Reflexive-Claude-Code --skill writing-hooks --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/writing-hooksContext preview
The summary Claude sees to decide when to auto-load this skill.
Creates Claude Code hooks that enforce code quality, static analysis, or workflow automation deterministically. Use when user says "add hook", "enforce linting", "add pre-commit check", "block bad code".
name: writing-hooks description: Creates Claude Code hooks that enforce code quality, static analysis, or workflow automation deterministically. Use when user says "add hook", "enforce linting", "add pre-commit check", "block bad code".
**Writing hooks IS creating automated quality gates.**
Hooks run on Claude Code events (PreToolUse, PostToolUse, etc.) and can block actions with exit code 2.
**Core principle:** Hooks enforce what humans forget. Fast checks only—slow hooks kill productivity.
Follow [task initialization protocol](../../references/task-initialization.md).
**Tasks:** 0. Fetch latest official hook spec 1. Analyze requirements 2. RED - Test without hook 3. GREEN - Write hook script 4. Configure settings.json 5. Validate behavior 6. Test blocking 7. REFACTOR - Quality review
Announce: "Created 8 tasks (0–7). Starting execution..."
| TDD Phase | Hook Creation | What You Do | |-----------|---------------|-------------| | **RED** | Test without hook | Write code, observe quality issues slip through | | **Verify RED** | Document violations | Note specific issues that should be caught | | **GREEN** | Write hook | Create script that catches those issues | | **Verify GREEN** | Test blocking | Verify exit code 2 blocks violating code | | **REFACTOR** | Optimize speed | Reduce hook runtime, filter file types |
**Goal:** Pull the current Anthropic hook spec before designing — never trust cached memory.
**Action:**
Skill tool: fetching-claude-docs
component: hook
question: "hook events (PreToolUse, PostToolUse, etc.), matcher syntax,
exit code contract, settings.json schema, additionalContext field,
security considerations"**Verification:** Received YAML with `source: https://code.claude.com/docs/en/hooks.md` and non-empty `spec_excerpt`. Use as authoritative reference; if any rule in this SKILL conflicts with the fetched spec, the fetched spec wins.
**Goal:** Understand what quality gate to create.
**Questions to answer:**
**Event Selection:**
| Event | When | Use For | |-------|------|---------| | `PreToolUse` | Before tool runs | Block bad writes before they happen | | `PostToolUse` | After tool runs | Validate written code | | `UserPromptSubmit` | Before prompt processed | Add context to prompts | | `Stop` | When agent tries to end its turn | Self-verify loop — block stop until checks pass (Ralph Wiggum pattern, enables L-Thread) |
**Verification:** Can describe the violation and the command to detect it.
**Goal:** Write code WITHOUT the hook. Observe violations that slip through.
**Process:** 1. Ask agent to write code in the target file type 2. Intentionally introduce the violation (bad format, type error, etc.) 3. Observe that Claude Code doesn't catch it 4. Document the specific violation
**Verification:** Documented at least 1 violation that should have been caught.
**Goal:** Create Python script that catches the violations you documented.
.claude/hooks/ ├── eslint_check.py ├── prettier_check.py └── typecheck.py
| Code | Meaning | Effect | |------|---------|--------| | 0 | Pass | Continue, stdout shown in verbose | | 2 | Block | Action blocked, stderr fed to Claude | | Other | Warning | Continue, stderr shown in verbose |
See [references/static-checks.md](references/static-checks.md) for complete hook templates. For performance-optimized security hooks, see [references/performance-optimization.md](references/performance-optimization.md). Key pattern: read JSON from stdin, filter by extension, run check, exit 2 to block.
When the agent tries to end its turn, block until deterministic checks pass — turning a one-shot agent into a loop that won't quit until the work is actually done. Use for long-running tasks, refactors, migrations, anything where "I think I'm done" is unreliable.
See [references/stop-event-self-verify.md](references/stop-event-self-verify.md) for the hook script and settings.json registration. Critical rule: always check `stop_hook_active` to bail after one retry — otherwise the agent loops forever on unfixable failures.
**Important:** Read [cross-platform-scripts.md](../../references/cross-platform-scripts.md) for full cross-platform rules covering paths, shell commands, line endings, and common pitfalls.
**Verification:**
A Claude Code plugin marketplace for skills-driven Agentic Context Engineering (ACE) — build, analyze, and maintain agent systems with structured workflows.
Repo: wayne930242/Reflexive-Claude-Code
Detects project languages and monorepo state, runs language-appropriate static analysis (dependency graph, complexity, duplication, semantic patterns), and…
Executes a refactor plan phase-by-phase on a dedicated branch with per-phase commits and mandatory reviewer checkpoints. Use when characterization-tests…
Writes AGENTS.md per subproject, archives run artifacts, and suggests rcc handoff conditionally. Use when verifying-refactors passes (PASS or…
Converts a refactor map into a phased plan using parallel-change, branch-by-abstraction, or strangler fig patterns. Use when user has approved the refactor map…
Adds golden/snapshot tests to untested hotspot modules before refactoring. Use when refactor plan marks any phase with…
Validates hard structural rules (no cycles, file/fn line caps, cognitive/cyclomatic complexity) and runs mutation testing on touched modules. Use when…