After a deploy command, runs 5 post-deploy checks from the project's .claude/deploy-verify.json and tells Claude the result.

Formerly
ai-prompts. Old links and clones redirect to this repo.
Skills, mods, subagents, hooks, slash commands and guides for Claude Code — installable by your agent (INSTALL.md).
Project-agnostic guides and executable agents for setting up Claude Code with 70-90% token reduction.
This library contains reusable prompts for implementing global Claude Code optimization across any project. Share with other developers or use to recreate your setup.
Point your coding agent at INSTALL.md:
Read https://github.com/escapeboy/claude-code-kit/blob/master/INSTALL.md and install what fits my setup.
The agent inspects your environment, proposes a selection (starter, code intelligence, delivery, multi-agent, mods, security, unattended, stack-specific), installs it from the latest release tag after your yes, without overwriting your files, and verifies the result. llms.txt is the index agents use to find their way around.
Set up global optimization (ONE-TIME, applies to ALL projects)
~/.claude/skills/)optimize/ - /optimize — max token efficiency mode (multi-file: thin core + references/)context/ - /ctx — memory management (multi-file: thin core + references/)cache-inspector/ - /cache-inspector — cache monitoring (multi-file: thin core + references/)update-docs/ - /update-docs — documentation refresh (multi-file: thin core + references/)init-project/ - /init-project — new project setup (multi-file: thin core + references/)agent-ready/ - /agent-ready — AI-agent-readiness audit + selective remediation (multi-file: scanner script + ROI/implementation references)continuity/ - /continuity — repo-local resume→work→finalize lifecycle + evidence-weighted .continuity/STATE.md (multi-file: lint/scaffold script + format reference)self-improve/ - /self-improve — closing-the-loop for the skill library: mine recurring feedback → bounded edit → tiered eval gate (deterministic skill-lint.py + trigger accuracy + LLM judge + with/without-skill behavioral eval via claude plugin eval) → converge (multi-file: linter + behavior-stats.py + deepeval_tier3.py scripts, rubric/behavior-eval/integration/deepeval-setup references)video-digest/ - /video-digest — video or recording → short digest, related notes, fact-checked memory candidatescode-research/ - /code-research — multi-agent grounded audit of a local or git codebase into a cross-linked knowledge base (multi-file: per-phase references/)agent-team/ - /agent-team — Agent Teams presets: pr-review, debug, feature, customcodebase-memory/ - codebase-memory-mcp knowledge-graph queries: callers, call chains, dead code, Cypherconfidence-check/ - /confidence-check — ≥90% readiness gate before implementation (+ confidence.ts reference implementation)decision-classify/ - /decision-classify — Mechanical / Taste / User Challenge classification to cut interruptionssprint-orchestrate/ - /sprint-orchestrate — Think → Plan → Build → Review → Test → Ship → Reflect with decision gates (--from-design, --no-merge for callers like /company)company/ - /company — an IT company for one task: clarify → research → split into parts → staff teams with fitting models → deliver through sprint-orchestrate; two stops for the user (multi-file: org-design, roster, briefs, workflows, memory references; back office in the company-hq mod)sync-features/ - /sync-features — sync a project's feature inventory into Serena memories and auto-memoryui-ux-review/ - /ui-ux-review — audit UI code for design consistency and accessibility (multi-file: examples + sample report)global-optimization.md - Core optimization rulessymbol-first-protocol.md - Symbol-first exploration protocolTime: 2-3 hours (one-time) Benefit: 70-90% token reduction on ALL future projects ROI: Pays for itself in 2-3 sessions
Activate optimization for a specific project (10-15 min per project)
architecture-template.md - Project structure templateconventions-template.md - Coding patterns templateTime: 10-15 minutes per project Benefit: Project-specific memories for 60-70% session savings Required: After global setup, before starting work
Create custom slash commands (skills)
example-simple-skill.md - Simple single-action skillexample-complex-skill.md - Multi-action skill with integrationpwa.md - PWA features skill (service worker, manifest, offline, push notifications)/module:mcp — Add a Laravel MCP server to any project (dual transport, domain tools, auth)/module:assistant — Add an AI assistant chat panel (Livewire, PrismPHP tools, local agent support)Use when: You want custom commands like /deploy or /migrate, or full modules like /module:mcp and /module:assistant Benefit: Encapsulate common workflows, reduce repetition; module skills bootstrap entire features
Research and integrate new Claude API features
Use when: New Claude API features released, quarterly reviews Benefit: Keep documentation current, adopt new optimizations
Deep dive into token reduction techniques
Use when: Analyzing token usage, optimizing specific workflows Benefit: Understand and maximize savings, track ROI
Advanced techniques for complex scenarios
/agent-team skill with pr-review, debug, feature, custom presetsUse when: Complex projects, team coordination, critical decisions, cost visibility Benefit: Handle advanced scenarios with proven patterns; understand where tokens go
Custom slash commands for specialized workflows
Use when: Specialized workflows, testing, debugging, sprint retrospectives, content quality assurance Benefit: Encapsulate complex workflows into simple commands
Production-ready UI/UX implementation with Claude Code
Use when: Building dashboards, admin panels, landing pages, SaaS interfaces Benefit: 40-60% token savings, production-ready code with security and accessibility Time: 60-90 minutes per dashboard (vs 3-4 hours manual)
Connect Claude Code with Laravel's MCP ecosystem
Use when: Working on Laravel 11.x/12.x projects with Claude Code Benefit: Project-aware assistance via Laravel Boost + package discovery via LaraPlugins.io Setup: 5 minutes per project (composer install + MCP registration)
Create custom AI agents with specialized knowledge and tools
plan-challenger (Opus) — adversarial plan review across 5 dimensions with refutation checkoutput-evaluator (Haiku) — LLM-as-Judge: APPROVE/NEEDS_REVIEW/REJECT before commitloop-monitor (Haiku) — watchdog for autonomous sessions: stall/runaway/loop detectioncode-reviewer.md - Read-only code review agentlaravel-specialist.md - Laravel development agentdebugger.md - Debugging specialisttest-generator.md - Test generation agentUse when: Repetitive specialized tasks, team standardization, cost optimization Benefit: Reusable agents with controlled tool access and model selection Setup: 5-10 minutes per agent definition
Mobile development with Claude Code across all major platforms
Use when: Developing iOS (Swift/SwiftUI), Android (Kotlin/Compose), React Native, or Flutter apps Benefit: Platform-specific MCP integration, build/test automation, device control Setup: 5-10 minutes per platform (MCP installation + CLAUDE.md template)
Desktop development with Claude Code for macOS, Tauri, and Electron
Use when: Building macOS native (SwiftUI/AppKit), Tauri (Rust + Web), or Electron (Node.js + Chromium) desktop apps Benefit: Platform-specific MCP integration, build/package automation, code signing and notarization workflows Setup: 5-10 minutes per platform (MCP installation + CLAUDE.md template)
WebMCP — structured browser tools for AI agents (W3C Draft, Chrome 146 Canary)
navigator.modelContext API reference with code examplesUse when: Building web applications that AI agents will interact with Benefit: Structured tool access instead of DOM scraping; 89% token reduction Status: Early Preview — Chrome 146 Canary only, spec actively changing
Protect Claude Code workflows from MCP attacks, prompt injection, and accidental data loss
settings.json + hook implementationspermissions.deny hardening templates (global + project-level)dangerous-actions-blocker.py — blocks rm -rf /-class commands in any spelling, force-push to main, DROP TABLE, over-broad pkill/killall, edits to key filespre-commit-secrets.py — scans staged content for API keys / private keys / DB URLs before every git commitblock-interactive-sudo.py — refuses sudo that would hang on a password prompttests/ — two-sided matrices (must-block AND must-pass) · WHY.md — the failure behind each hooksettings.json wiring and the PreToolUse hook contractUse when: Team environments, production codebases, regulated industries, before adding new MCP servers Benefit: Prevent data exfiltration, block destructive operations, audit MCP supply chain Time: 15-30 minutes for initial hardening; 5 minutes per new MCP added
Run Claude Code unattended — cron agents, heartbeat watchdogs, and session journaling
/loop, and hooks — and when each appliesHEARTBEAT_OK token, 200-token failure budget, probe allowlist — born from sessions killed for drifting into investigationsUse when: Scheduled health checks, automated journaling, any unattended Claude Code run Benefit: Agents that complete within budget instead of drifting; a daily work journal nobody has to write Time: 30-60 minutes for the first cron agent
Claude Code mods (v2.1.287+) — TypeScript hooks inside the engine
ai-prompts-mods: 13 mods with tests — context-meter, cache-guard, spend-ledger, subagent-models, secret-redactor, ssh-guard, deploy-verify, ci-watch, cleanup-tracker, aside, fleet-status, lang-guard, company-hqUse when: A policy must hold on every tool call or subagent spawn, output must be rewritten before the model sees it, or you want live UI (meters, panes, status) Benefit: Secrets out of transcripts, model routing that plugin updates cannot undo, cache and spend visible while you work Time: 10 minutes to install the set; 1-2 hours to write your first mod
Option 1: Automated (Recommended)
# Navigate to Claude Code
cd ~/.claude
# Use the setup agent
# Copy contents of 01-global-optimization/setup-agent.md
# Paste into Claude Code conversation
# Agent will create all files automatically
Option 2: Manual
# Follow the step-by-step guide
# Read: 01-global-optimization/guide.md
# Create files as instructed
# Verify with: 01-global-optimization/checklist.md
# Navigate to your project
cd ~/projects/your-project
# Use the activation agent
# Copy contents of 02-project-activation/activation-agent.md
# Paste into Claude Code conversation
# Agent will activate Serena and create memories
# In your project directory
/optimize "Your task here"
# Or use /init-project for new projects
/init-project --full
| Scenario | Baseline | Optimized | Savings |
|---|---|---|---|
| Simple task (bug fix) | 22,000 tokens | 1,600 tokens | 93% |
| Medium task (new feature) | 31,000 tokens | 8,500 tokens | 73% |
| Complex task (module creation) | 85,000 tokens | 18,000 tokens | 79% |
Conservative target: 30-50% overall reduction Aggressive target: 50-70% with full optimization Maximum achieved: 80-90% with prompt caching on large contexts
Per session (average medium task):
Monthly (30 sessions):
Annual (360 sessions):
Multiple projects (3 projects, 60 sessions/month):
~/.claude/)Agents (orchestration):
agents/pm-orchestrator.md - Central coordinatoragents/plan-challenger.md - Adversarial plan review (Opus)agents/output-evaluator.md - Code quality judge before commit (Haiku)agents/loop-monitor.md - Autonomous session watchdog (Haiku)Hooks (automation):
hooks/dangerous-actions-blocker.py - Blocks destructive commands and protected fileshooks/pre-commit-secrets.py - Scans staged files for API keys before commithooks/register.ts 157 lines1import type { EngineInterface, Register } from 'claude-code'
2
3// CLAUDE.md "Deploying to Production": after a deploy, run the 5 checks of the
4// post-deploy checklist (homepage, endpoints, app log, nginx 500s, OPcache)
5// before calling it done. This runs them by itself after
6// a command the project's .claude/deploy-verify.json calls a deploy, and hands
7// Claude the result with the command's output.
8
9const CONFIG = '.claude/deploy-verify.json'
10// Without a config, these only earn a reminder.
11const LIKELY_DEPLOY = /\b(envoy\s+run\s+deploy|dep\s+deploy|deploy\.sh|git\s+push\b[^|;&]*\b(main|master|production|prod)\b|gh\s+workflow\s+run\s+\S*deploy)/
12
13export type Config = {
14 deployCommands: string[]
15 homepage?: string
16 endpoints?: string[]
17 ssh?: string
18 laravelLog?: string
19 nginxLog?: string
20 opcacheClear?: string
21}
22
23export const TEMPLATE: Config = {
24 deployCommands: ['envoy run deploy', 'git push \\S+ main'],
25 homepage: 'https://example.com',
26 endpoints: ['https://example.com/api/health'],
27 ssh: 'my-server',
28 laravelLog: 'docker exec <app-container> tail -n 200 storage/logs/laravel.log',
29 nginxLog: 'sudo -n tail -n 300 /var/log/nginx/access.log',
30 opcacheClear: 'docker exec <app-container> php artisan opcache:clear',
31}
32
33export const errorLines = (log: string) => log.split('\n').filter(l => /\.(ERROR|CRITICAL|ALERT|EMERGENCY):/.test(l))
34export const count500 = (log: string) => log.split('\n').filter(l => /"\s500\s/.test(l)).length
35
36type Found = { path: string; raw: string; config: Config } | undefined
37// The config runs shell commands, and a cloned repo can ship one. It runs only
38// after the user approved this exact content with /deploy-verify trust.
39const TRUST_KEY = 'trusted'
40
41export async function isTrusted($: EngineInterface, f: { path: string; raw: string }) {
42 const t = ((await $.store.get(TRUST_KEY)) as Record<string, string> | undefined) ?? {}
43 return t[f.path] === f.raw
44}
45
46async function trust($: EngineInterface, path: string, raw: string) {
47 const t = ((await $.store.get(TRUST_KEY)) as Record<string, string> | undefined) ?? {}
48 await $.store.set(TRUST_KEY, { ...t, [path]: raw })
49}
50// Looked up once per working directory; /deploy-verify init clears it.
51const found = new Map<string, Found>()
52
53async function findConfig($: EngineInterface): Promise<Found> {
54 const cwd = await $.session.cwd()
55 if (found.has(cwd)) return found.get(cwd)
56 const hit = await searchConfig($, cwd)
57 found.set(cwd, hit)
58 return hit
59}
60
61async function searchConfig($: EngineInterface, cwd: string): Promise<Found> {
62 let dir = cwd
63 for (let i = 0; i < 8 && dir; i++) {
64 const path = `${dir}/${CONFIG}`
65 if (await $.fs.exists(path)) {
66 const raw = await $.fs.read(path)
67 return { path, raw, config: JSON.parse(raw) as Config }
68 }
69 dir = dir.slice(0, dir.lastIndexOf('/'))
70 }
71 return undefined
72}
73
74async function remote($: EngineInterface, c: Config, cmd: string) {
75 if (c.ssh?.startsWith('-')) throw new Error(`ssh host must not start with '-': ${c.ssh}`)
76 const argv = c.ssh ? ['ssh', '-o', 'ConnectTimeout=10', '-o', 'BatchMode=yes', c.ssh, cmd] : ['sh', '-c', cmd]
77 return $.process.run(argv, { timeoutMs: 60_000 })
78}
79
80async function verify($: EngineInterface, c: Config): Promise<string[]> {
81 const out: string[] = []
82 // 1. Homepage
83 if (c.homepage) {
84 const r = await $.http.fetch(c.homepage).catch(err => ({ status: 0, ok: false, text: String(err) }))
85 out.push(`1. ${r.status === 200 ? '✅' : '❌'} homepage ${c.homepage} → ${r.status}`)
86 } else out.push('1. ⚪ homepage: not configured')
87 // 2. Key endpoints
88 const eps = c.endpoints ?? []
89 if (eps.length) {
90 const res = await Promise.all(eps.map(async u => [u, (await $.http.fetch(u).catch(() => ({ status: 0 }))).status] as const))
91 const bad = res.filter(([, s]) => s === 0 || s >= 400)
92 out.push(`2. ${bad.length ? '❌' : '✅'} endpoints: ${res.map(([u, s]) => `${u.replace(/^https?:\/\/[^/]+/, '')} ${s}`).join(', ')}`)
93 } else out.push('2. ⚪ endpoints: not configured')
94 // 3. Laravel log
95 if (c.laravelLog) {
96 const r = await remote($, c, c.laravelLog)
97 const errs = errorLines(r.stdout)
98 out.push(r.exitCode !== 0 ? `3. ❌ laravel log unreadable: ${r.stderr.trim().slice(0, 120)}` : `3. ${errs.length ? '⚠️' : '✅'} laravel log: ${errs.length} error lines in the tail${errs.length ? `; last: ${errs.at(-1)!.slice(0, 200)}` : ''}`)
99 } else out.push('3. ⚪ laravel log: not configured')
100 // 4. nginx 500s
101 if (c.nginxLog) {
102 const r = await remote($, c, c.nginxLog)
103 const needsSudo = /sudo/.test(r.stderr) && r.exitCode !== 0
104 out.push(r.exitCode !== 0 ? `4. ❌ nginx log unreadable${needsSudo ? ' (needs passwordless sudo, or read it through docker)' : ''}: ${r.stderr.trim().slice(0, 120)}` : `4. ${count500(r.stdout) ? '⚠️' : '✅'} nginx: ${count500(r.stdout)} × 500 in the tail`)
105 } else out.push('4. ⚪ nginx: not configured')
106 // 5. OPcache
107 if (c.opcacheClear) {
108 const r = await remote($, c, c.opcacheClear)
109 out.push(`5. ${r.exitCode === 0 ? '✅' : '❌'} opcache clear (exit ${r.exitCode})${r.exitCode ? `: ${r.stderr.trim().slice(0, 120)}` : ''}`)
110 } else out.push('5. ⚪ opcache: not configured')
111 return out
112}
113
114export const register: Register = on => {
115 on('session.start', async ($, e, next) => {
116 await $.command.register({ name: 'deploy-verify', description: 'Run the 5 post-deploy checks from .claude/deploy-verify.json', argumentHint: '[init|trust]' })
117 return next(e)
118 })
119
120 on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
121 const ran = await next(e)
122 if (ran.deny !== undefined || ran.isError === true) return ran
123 const cfg = await findConfig($)
124 const isDeploy = cfg ? cfg.config.deployCommands.some(p => new RegExp(p).test(e.command)) : LIKELY_DEPLOY.test(e.command)
125 if (!isDeploy) return ran
126 if (!cfg) {
127 return { ...ran, context: [...(ran.context ?? []), `deploy-verify: this looks like a deploy, but there is no ${CONFIG} here. Run your post-deploy checks now, or /deploy-verify init to set the project up.`] }
128 }
129 if (!(await isTrusted($, cfg))) {
130 return { ...ran, context: [...(ran.context ?? []), `deploy-verify: ${cfg.path} is new or changed since the user last approved it, so its checks did not run. Ask the user to read it and run /deploy-verify trust; meanwhile run the post-deploy checks yourself.`] }
131 }
132 const lines = await verify($, cfg.config)
133 for (const l of lines) $.ui.log(l)
134 return { ...ran, context: [...(ran.context ?? []), `deploy-verify (${cfg.path}), checks run after this deploy:\n${lines.join('\n')}\nDo not report the deploy as done while any line is ❌ or ⚠️ unexplained.`] }
135 }).catch(($, e, next) => next(e))
136
137 on('command.run', { command: 'deploy-verify' }, async ($, e) => {
138 if (e.args.trim() === 'init') {
139 const path = `${await $.session.cwd()}/${CONFIG}`
140 if (await $.fs.exists(path)) return { text: `${path} already exists.` }
141 const raw = JSON.stringify(TEMPLATE, null, 2) + '\n'
142 await $.fs.write(path, raw)
143 found.clear()
144 return { text: `Wrote ${path}. Fill in the URLs, the ssh host and the container, then /deploy-verify to test it.` }
145 }
146 found.clear()
147 const cfg = await findConfig($)
148 if (!cfg) return { text: `No ${CONFIG} in this project. /deploy-verify init writes a template.` }
149 if (e.args.trim() === 'trust') {
150 await trust($, cfg.path, cfg.raw)
151 return { text: `Trusted ${cfg.path} as it is now. Any later change needs /deploy-verify trust again.\n\n${cfg.raw}` }
152 }
153 if (!(await isTrusted($, cfg))) return { text: `${cfg.path} is new or changed. Read it, then /deploy-verify trust:\n\n${cfg.raw}` }
154 return { text: (await verify($, cfg.config)).join('\n') }
155 })
156}
157