Writing and git rules: replaces em dashes in prose, and asks before git commit --amend, an unformatted push, or personal info in notes and commits.

<h1 align="center">Claude Code mods</h1>
<a href="https://www.npmjs.com/package/claude-code-mods"><img src="https://img.shields.io/npm/v/claude-code-mods.svg" alt="npm"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="MIT"></a> <a href="https://github.com/hamzafer/claude-code-mods/actions/workflows/ci.yml"><img src="https://github.com/hamzafer/claude-code-mods/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
<a href="#-install">Install</a> · <a href="#-the-mods">All mods</a> · <a href="docs/mods.md">Docs</a> · <a href="https://claude.dev/blog/getting-started-with-claude-code-mods/">What are mods?</a>
<table> <tr> <td align="center" width="33%"><a href="docs/mods.md#-context-bar"><img src="images/context-bar.png" alt="context-bar: Claude Code context window usage as a stacked bar, a color per category" width="260"></a><br>📊 <b>context-bar</b><br>what fills your context</td> <td align="center" width="33%"><a href="docs/mods.md#-review-watch"><img src="images/review-watch.png" alt="review-watch: live lines for running Codex and subagent code reviews in Claude Code" width="260"></a><br>🔍 <b>review-watch</b><br>running code reviews, live</td> <td align="center" width="33%"><a href="docs/mods.md#-md-preview"><img src="images/md-preview.png" alt="md-preview: Markdown that Claude Code edits, rendered like GitHub next to the diff" width="260"></a><br>📝 <b>md-preview</b><br>Markdown rendered like GitHub</td> </tr> <tr> <td align="center" width="33%"><a href="docs/mods.md#-blast-radius"><img src="images/gallery/blast-radius.png" alt="blast-radius: a Claude Code hook holds rm -rf and lists the files it would delete" width="260"></a><br>💥 <b>blast-radius</b><br>see what <code>rm -rf</code> would delete</td> <td align="center" width="33%"><a href="docs/mods.md#-now-playing"><img src="images/now-playing.png" alt="now-playing: Spotify track, progress bar and synced lyrics inside Claude Code" width="260"></a><br>🎵 <b>now-playing</b><br>Spotify and its lyrics, live</td> <td align="center" width="33%"><a href="docs/mods.md#-reels-and-snake"><img src="images/reels-demo.gif" alt="reels: YouTube Shorts in a Claude Code pane while it works" width="260"></a><br>📱 <b>reels</b><br>Shorts while Claude works</td> </tr> <tr> <td align="center" width="33%"><a href="docs/mods.md#-where-am-i"><img src="images/gallery/where-am-i.png" alt="where-am-i: the session goal, current step and what waits on you, above the Claude Code prompt" width="260"></a><br>📍 <b>where-am-i</b><br>goal, now, waiting on you</td> <td align="center" width="33%"><a href="docs/mods.md#-lines-above-the-prompt"><img src="images/gallery/lines.png" alt="token-weather, usage-meter and other Claude Code status lines stacked above the prompt" width="260"></a><br>🌦️ <b>token-weather and friends</b><br>lines above the prompt</td> <td align="center" width="33%"><a href="#mission-control"><img src="images/gallery/mission-control.png" alt="mission-control: Claude Code subagents, tool calls and the files they touch, live" width="260"></a><br>🛰️ <b>mission-control</b><br>agents and the code they touch</td> </tr> <tr> <td align="center" width="33%"><a href="docs/mods.md#-switchboard"><img src="images/switchboard.png" alt="switchboard: subagents routed from opus to sonnet and haiku, with confidence and cost" width="260"></a><br>🔀 <b>switchboard</b><br>cheaper models for subagents</td> <td align="center" width="33%"><a href="docs/mods.md#-agent-radar"><img src="images/agent-radar.png" alt="agent-radar: a running subagent and two background shells with their latest output" width="260"></a><br>📡 <b>agent-radar</b><br>subagents and shells, live</td> <td align="center" width="33%"><a href="docs/mods.md#-reels-and-snake"><img src="images/snake.png" alt="snake: a game of Snake in a Claude Code pane" width="260"></a><br>🐍 <b>snake</b><br>a game while Claude works</td> </tr> </table>
npx claude-code-mods@latest
Tick the mods you want in a checklist, see what each one adds, and press Enter to install. Untick a mod to disable it (its settings stay). Restart Claude Code after. @latest makes npx skip an old cached copy.
--project installs for this project only--dry-run prints the claude commands instead of running them--pick a,b turns on exactly these mods, no checklist (--pick "" turns all off)--yes-community installs picked community mods without asking (outside a terminal they are skipped without it)--help shows usageIt edits the Claude profile that claude uses here, shown at the top. For another profile, set it first: CLAUDE_CONFIG_DIR=~/.claude-other npx claude-code-mods@latest.
Press o in the checklist to order your bands (the lines above the prompt). Move the cursor with up/down or j/k, move a band with Shift+up/down or K/J, and press Enter to save. Esc goes back without saving. The order goes to <config dir>/claude-code-mods/bands.json, where the config dir is CLAUDE_CONFIG_DIR or ~/.claude. Restart Claude Code to apply it. Bands not in the file sit on top.
By hand:
claude plugin marketplace add hamzafer/claude-code-mods
claude plugin install context-bar@claude-code-mods
To try one without installing:
git clone https://github.com/hamzafer/claude-code-mods && cd claude-code-mods
claude --plugin-dir mods/context-bar
Needs Claude Code 2.1.287+. A few mods need more (Chrome,
gh, a connector); the tables say which.
| Mod | What it does | Command | |
|---|---|---|---|
| 🛰️ | mission-control | Live map of agents, tool calls and the code they touch | /mission |
| 📊 | context-bar | Your context window as one stacked bar, a color per category, with token counts and where it compacts | /context-bar |
| 🌦️ | token-weather | Context fill from Clear to Compact soon, plus a prompt-cache countdown | |
| ⏱️ | cache-clock | A prompt-cache line under your status line, from Claude Code's own figures: time left, hit rate and misses, and the tokens your next message re-caches once it goes cold. Needs Node and Claude Code 2.1.287+ | /cache-clock setup |
| 📍 | where-am-i | Goal, doing now, waiting on you, next step | /where |
| ➡️ | next-steps | 2 or 3 likely next prompts after each turn, one key to draft one. language sets their language, layout: rows keeps one per row | 1 2 3, 0 hides |
| 💰 | usage-meter | 5-hour and 7-day plan usage, the reset countdown and the session's cost | |
| 🔥 | heatmap | A GitHub-style grid of your Claude Code time, with your streak, peak hours and top projects | /heatmap |
| 💳 | openai-balance | Your OpenAI API credit: an estimated balance with a gauge, today's spend, where the money mostly went, and the last call. Needs an OpenAI organization Admin key | /openai-balance |
| 🪙 | openrouter-balance | Your OpenRouter credit: the real balance with a gauge, today's spend and the model the money mostly went to. A regular API key shows the balance too when OpenRouter allows it, plus its own spend and limit | /openrouter-balance |
| 📡 | agent-radar | One live line per running subagent or background shell | /radar |
| 🔍 | review-watch | One live line per running code review (Codex or a review subagent) with the model, target, elapsed time and Codex's latest output. A toast lists the findings when it ends | |
| 🌐 | browser-lanes | Whether this session has a browser, and who holds it | /browser |
| 🕌 | prayer-times | The current prayer and how long is left, the next one, and zawal. Computed on your computer, Hanafi or standard Asr | /prayers |
| 🎬 | replay-theater | Steps through the last turn's edits, one diff at a time | /replay |
| 📝 | md-preview | Renders the Markdown files Claude edits like GitHub does, with before and after side by side. Needs Chrome and a terminal that shows images | /md |
| Mod | What it does | Command | |
|---|---|---|---|
| 💥 | blast-radius | Holds rm -r, force pushes and migrations, shows what they'd delete, cancels after 60 s with no answer |
| Mod | What it does | Command | |
|---|---|---|---|
| 🔀 | switchboard | Picks the model for each subagent that doesn't name one, with OpenAI's Decisions API or Jev, from its short label only. Shows what every subagent cost | /route |
These are built around my own tools and rules. Fork them and change the rules to yours.
| Mod | What it does | Command | |
|---|---|---|---|
| 👀 | glance | One line with what needs you: next meeting, PRs, Linear issues, Slack DMs. Needs gh and the Google Calendar, Linear and Slack connectors | /glance |
| 🚦 | merge-gate | Holds gh pr merge until CI is green and Codex reviewed once. Needs gh and the Codex CLI. Reviews run on one fixed model; change it to yours | /gate |
| 📏 | rulebook-guard | Enforces my writing and git rules: rewrites em dashes, asks before --amend, unformatted pushes, emails and phone numbers in notes | |
| 💾 | session-saver | Saves where you left off, shows it on resume. Needs unpause | /park [note] |
| Mod | What it does | Command | |
|---|---|---|---|
| 📱 | reels | YouTube Shorts while Claude works, pauses when it's done | /reels |
| 🐍 | snake | Snake while Claude works | /snake |
| 🎵 | now-playing | What Spotify is playing, with a progress bar, the lyric being sung, and ⏮ ⏸ ⏭ buttons. Needs macOS and the Spotify app | /music |
Mods by other people, in their own marketplaces. They're not maintained here, so read the code before you install. They also show up last in the npx claude-code-mods@latest checklist.
| Mod | What it does | Install | |
|---|---|---|---|
| 🖼️ | image-view by @jarrodwatts | See the images you paste into Claude Code: thumbnails above the prompt instead of bare [Image #1] tags | claude plugin marketplace add jarrodwatts/claude-image-view then claude plugin install image-view@claude-image-view |
| 🏷️ | last-prompt-title by @zhangbububu | Session titles that follow your latest prompt: cut for the CLI, written by Haiku for the desktop sidebar | claude plugin marketplace add zhangbububu/session-titles then claude plugin install last-prompt-title@session-titles |
| 🌏 | cc-zh by @jiangnanquan | Simplified Chinese UI localization via static dictionary: slash-command descriptions, /config labels, spinner, hints, notices, command output, tool summaries and turn duration. Zero tokens / network; verified on CC 2.1.296 | claude plugin marketplace add jiangnanquan/claude-code-zh then claude plugin install cc-zh@claude-code-zh |
| 🎛️ | subagent-tuner by @Kruhlikau | Picks the model and effort of every subagent: a Manual/Auto band, a pick pane, review → Opus and search → Haiku, and a saved default that overrides what the agent asked for | claude plugin marketplace add Kruhlikau/subagent-tuner then claude plugin install subagent-tuner@subagent-tuner |
| 🛒 | mod-store by @hellosverre | An app store in a pane: /mods browses, searches and installs about 2,700 community mods, with what each one can access shown before you install. Or ask Claude to find one | claude plugin marketplace add hellosverre/mod-store then claude plugin install mod-store@mod-store |
| 📈 | cache-meter by @T-AI-Labs | The share of each turn the prompt cache served, next to the context fill, with an auto-compact threshold and Compact and Clear buttons | claude plugin marketplace add T-AI-Labs/claude-code-mods then claude plugin install cache-meter@T-AI-Labs |
| ⏳ | usage-limits by @T-AI-Labs | 5-hour and weekly plan limits in percent, with the time left until each resets | claude plugin marketplace add T-AI-Labs/claude-code-mods then claude plugin install usage-limits@T-AI-Labs |
| 🟣 | pixel-pulse by @air01aditya | A purple pixel strip above the prompt that drifts right to left and glows under the pointer, and a purple pixel spiral in place of the working spinner. Desktop app only; it only draws | claude plugin marketplace add air01aditya/pixel-pulse then claude plugin install pixel-pulse@pixel-pulse |
| 🔗 | open-paths by @kiankhooban | Click a file path in Claude's reply and the file opens in its app: Word, Preview or Excel for documents, your editor at the line for app.py:42, Finder for folders. Launchers, scripts and unknown types are never opened | claude plugin marketplace add kiankhooban/open-paths then claude plugin install open-paths@open-paths |
| 🎼 | workflow-conductor by @bruw | Terminal UI for planning, running and understanding complex agent workflows inside Claude Code: define the workflow as a graph, have Claude script and run it, and watch the run on the same graph. Needs Claude Code 2.1.296+ and a terminal 110+ columns wide | claude plugin marketplace add bruw/workflow-conductor then claude plugin install workflow-conductor@workflow-conductor |
| 💸 | bedrock-meter by @weidu-tpvision | Token and USD meter for Claude Code on Amazon Bedrock: session cost, context fill, cache hit rate and today's total above the prompt, priced at AWS's own on-demand rates (refreshed weekly from the AWS price list), with a per-model breakdown in /bedrock-cost | claude plugin marketplace add weidu-tpvision/claude-mods then claude plugin install bedrock-meter@weidu-claude-mods |
| 📱 | brainrot-break by @BordyV | A TikTok-style feed of 350+ pixel art mini-videos in a pane while Claude answers: scroll, like, pick your themes, and an end card when Claude is done. Every video is a small simulation drawn locally: no tokens, no model calls. Terminal and desktop app, in 6 languages. Try it in the browser | claude plugin marketplace add BordyV/brainrot-break then claude plugin install brainrot-break@brainrot-break |
Built one? Open a PR that adds a row.
<a id="mission-control"></a>
Every subagent, every tool call and every file they touch, in a pane next to the chat. Shown at 4x: two subagents building a logout feature across four files.

Install it like any mod, restart, and type /mission (or /mission code to open the code map). q closes it.
w shows the agents and every tool call, livec shows the code map, with import arrowsThe Code view runs on macOS and Linux and needs Google Chrome or Chromium and a terminal that shows images (Ghostty, kitty, iTerm2). The Who view works everywhere.
hooks/register.ts 225 lines1// rulebook-guard: enforces writing and git rules kept in CLAUDE.md and memory.
2// 1. No em dashes in prose: notes, docs, commit messages, PR text, Slack posts.
3// 2. New commits, not `git commit --amend`.
4// 3. Changed files formatted (ruff format, Prettier) before `git push`. A Prettier the
5// repo commits to git is never run; this is a guardrail, not a security boundary.
6// 4. No personal info (emails, phone numbers) in notes, memory or commits without asking.
7import type { EngineInterface, Register } from 'claude-code'
8
9const PROSE_FILE = /\.(md|mdx|markdown|txt)$/i
10const PROSE_COMMAND = /\bgh\s+(pr|issue)\s+(create|comment|edit|review)\b/
11// `git`, then any global options (`-c k=v`, `-C dir`, `--no-pager`), then the subcommand.
12const GIT = String.raw`\bgit(?:\s+(?:-[cC]\s+\S+|--?[\w-]+(?:=\S+)?))*\s+`
13const GIT_COMMIT = new RegExp(`${GIT}commit\\b`)
14const GIT_AMEND = new RegExp(`${GIT}commit\\b[^|;&]*--amend\\b`)
15const GIT_PUSH = new RegExp(`${GIT}push\\b`)
16const SLACK_POST = /^mcp__claude_ai_Slack__slack_(send_message|send_message_draft|schedule_message)$/
17const EMAIL = /[\w.+-]+@[\w-]+\.[a-z]{2,}/i
18const PHONE = /\+\d{1,3}[\s-]?\d{2,4}[\s-]?\d{2,4}[\s-]?\d{2,4}/
19const PRETTIER_FILE = /\.(js|jsx|ts|tsx|mjs|cjs|json|css|scss|md|mdx|ya?ml|html)$/
20
21export const register: Register = on => {
22 on('tool.call', { tool: 'Write' }, async ($, e, next) => {
23 if (await isPrivatePath($, e.file_path)) {
24 const found = pii(e.content)
25 if (found && !(await allow($, `This write to ${short(e.file_path)} contains what looks like ${found}.`))) {
26 return { deny: `rulebook-guard: the user blocked writing ${found} to ${e.file_path}. Personal info needs the user's approval first. Write the outcome instead of the details.` }
27 }
28 }
29 if (PROSE_FILE.test(e.file_path) && e.content.includes('—')) {
30 $.ui.toast(`rulebook-guard: replaced ${count(e.content)} em dash(es) in ${short(e.file_path)}`)
31 return next({ ...e, content: undash(e.content) })
32 }
33 return next(e)
34 })
35
36 on('tool.call', { tool: 'Edit' }, async ($, e, next) => {
37 if (await isPrivatePath($, e.file_path)) {
38 const found = pii(e.new_string)
39 if (found && !(await allow($, `This edit to ${short(e.file_path)} adds what looks like ${found}.`))) {
40 return { deny: `rulebook-guard: the user blocked writing ${found} to ${e.file_path}. Personal info needs the user's approval first. Write the outcome instead of the details.` }
41 }
42 }
43 if (PROSE_FILE.test(e.file_path) && e.new_string.includes('—')) {
44 $.ui.toast(`rulebook-guard: replaced ${count(e.new_string)} em dash(es) in ${short(e.file_path)}`)
45 return next({ ...e, new_string: undash(e.new_string) })
46 }
47 return next(e)
48 })
49
50 on('tool.call', { tool: 'Bash' }, async ($, e, next) => {
51 let command = e.command
52 const shell = bare(command) // what the shell runs, without quoted text or heredoc bodies
53
54 if (GIT_AMEND.test(shell)) {
55 if (!(await allow($, 'This is `git commit --amend`. Your rule: make a new commit instead.'))) {
56 return { deny: 'rulebook-guard: the user blocked `git commit --amend`. Their rule is new commits, not amend. Make a new commit instead.' }
57 }
58 }
59
60 if (GIT_COMMIT.test(shell)) {
61 const found = pii(command)
62 if (found && !(await allow($, `This commit message contains what looks like ${found}.`))) {
63 return { deny: `rulebook-guard: the user blocked a commit message with ${found}. Personal info needs the user's approval first.` }
64 }
65 }
66
67 if (GIT_PUSH.test(shell)) {
68 const problems = await unformatted($, await runDir($, command))
69 if (problems.length > 0 && !(await allow($, `Not formatted yet: ${problems.join('; ')}. Your rule: format before push.`))) {
70 return { deny: `rulebook-guard: the user blocked the push because these are not formatted: ${problems.join('; ')}. Run the formatter(s), commit, then push.` }
71 }
72 }
73
74 if ((GIT_COMMIT.test(shell) || PROSE_COMMAND.test(shell)) && command.includes('—')) {
75 $.ui.toast(`rulebook-guard: replaced ${count(command)} em dash(es) in the ${GIT_COMMIT.test(shell) ? 'commit message' : 'PR text'}`)
76 command = undash(command)
77 }
78
79 return next(command === e.command ? e : { ...e, command })
80 })
81
82 // Slack posts: no em dashes either.
83 on('tool.call', async ($, e, next) => {
84 if (!SLACK_POST.test(e.tool)) return next(e)
85 const args = e as unknown as { message?: unknown }
86 if (typeof args.message !== 'string' || !args.message.includes('—')) return next(e)
87 $.ui.toast(`rulebook-guard: replaced ${count(args.message)} em dash(es) in the Slack message`)
88 return next({ ...e, message: undash(args.message) } as typeof e)
89 })
90}
91
92// The command as the shell reads it: heredoc bodies and quoted strings blanked, so text
93// that merely mentions a command (a script, a commit message) is not taken for one.
94export function bare(command: string) {
95 return command
96 .replace(/<<-?\s*(['"]?)(\w+)\1[^\n]*\n[\s\S]*?\n\s*\2\s*(\n|$)/g, ' ')
97 .replace(/'[^']*'/g, "''")
98 .replace(/"(?:[^"\\]|\\.)*"/g, '""')
99}
100
101// "a — b" and "a—b" both read "a, b".
102export function undash(text: string) {
103 return text.replace(/\s*—\s*/g, ', ')
104}
105
106function count(text: string) {
107 return text.split('—').length - 1
108}
109
110// What kind of personal info the text seems to hold, by category only; never the value.
111export function pii(text: string): string | null {
112 if (EMAIL.test(text)) return 'an email address'
113 if (PHONE.test(text)) return 'a phone number'
114 return null
115}
116
117// Notes, auto-memory and CLAUDE.md files: where the PII rule applies.
118async function isPrivatePath($: EngineInterface, path: string) {
119 const home = (await $.env.get('HOME')) ?? ''
120 return (
121 (home !== '' && path.startsWith(`${home}/notes/`)) ||
122 /\/(\.claude|\.claude-work)\/projects\/[^/]+\/memory\//.test(path) ||
123 /(^|\/)CLAUDE\.md$/.test(path)
124 )
125}
126
127// Asks the person; anything but "Allow once" (or no one to ask) blocks.
128async function allow($: EngineInterface, why: string) {
129 try {
130 const answer = await $.ui.ask(`rulebook-guard: ${why} Allow it anyway?`, {
131 options: ['Block it', 'Allow once'],
132 header: 'Rulebook',
133 })
134 return answer === 'Allow once'
135 } catch {
136 return false
137 }
138}
139
140// The directory a leading `cd x &&` moves to, if any.
141export function cdOf(command: string): string | undefined {
142 return /^\s*cd\s+("[^"]+"|'[^']+'|\S+)\s*&&/.exec(command)?.[1]?.replace(/^["']|["']$/g, '')
143}
144
145// Git with the repo's own fsmonitor hook off: a cloned repo's config must not run code.
146export const GIT_SAFE = ['git', '-c', 'core.fsmonitor=false'] as const
147
148// Where the push runs: the session's folder, or a `cd x` inside it. A `cd` that leaves
149// the session's folder is ignored, so a command can't point the check at another repo.
150async function runDir($: EngineInterface, command: string): Promise<string> {
151 const base = await $.session.cwd()
152 const target = cdOf(command)
153 if (target === undefined) return base
154 const home = (await $.env.get('HOME')) ?? ''
155 const spelled = target === '~' || target.startsWith('~/') ? (home ? home + target.slice(1) : '') : target
156 if (spelled === '' || spelled.includes('$')) return base
157 const real = await realPath($, spelled.startsWith('/') ? spelled : `${base.replace(/\/$/, '')}/${spelled}`)
158 const root = await realPath($, base)
159 return real && root && inside(real, root) ? real : base
160}
161
162async function realPath($: EngineInterface, path: string) {
163 return (await $.fs.stat(path, { resolve: true }).catch(() => undefined))?.realPath
164}
165
166function inside(path: string, root: string) {
167 const r = root.replace(/\/$/, '')
168 return path === r || path.startsWith(`${r}/`)
169}
170
171// Changed files the repo's own formatters would change, as short reasons.
172async function unformatted($: EngineInterface, cwd: string): Promise<string[]> {
173 const top = await $.process.run([...GIT_SAFE, 'rev-parse', '--show-toplevel'], { cwd }).catch(() => null)
174 if (!top || top.exitCode !== 0) return []
175 const root = top.stdout.trim()
176 const at = { cwd: root, timeoutMs: 60_000 }
177
178 let diff = await $.process.run([...GIT_SAFE, 'diff', '--name-only', '--diff-filter=ACMR', '@{u}...HEAD'], at)
179 if (diff.exitCode !== 0) diff = await $.process.run([...GIT_SAFE, 'diff', '--name-only', '--diff-filter=ACMR', 'origin/main...HEAD'], at)
180 if (diff.exitCode !== 0) return []
181 const files = diff.stdout.split('\n').filter(Boolean)
182 const problems: string[] = []
183
184 const py = files.filter(f => f.endsWith('.py'))
185 if (py.length > 0) {
186 const ruff = await $.process.run(['ruff', 'format', '--check', '--', ...py], at).catch(() => null)
187 if (ruff && ruff.exitCode === 1) {
188 const bad = ruff.stdout.split('\n').filter(l => l.startsWith('Would reformat:')).map(l => l.slice(16).trim())
189 problems.push(`ruff format: ${bad.join(', ') || 'some Python files'}`)
190 }
191 }
192
193 const web = files.filter(f => PRETTIER_FILE.test(f))
194 const bin = `${root}/node_modules/.bin/prettier`
195 const hasPrettier = await $.fs.exists(bin).catch(() => false)
196 if (web.length > 0 && hasPrettier) {
197 if (!(await trustedPrettier($, root, bin))) {
198 $.ui.toast('rulebook-guard: Prettier not checked: this repo ships its own node_modules/.bin/prettier')
199 return problems
200 }
201 // After --, a file named --plugin=x is a file, not a flag.
202 const prettier = await $.process.run([bin, '--check', '--', ...web], at).catch(() => null)
203 if (prettier && prettier.exitCode === 1) {
204 const bad = `${prettier.stdout}\n${prettier.stderr}`.split('\n').filter(l => l.startsWith('[warn] ') && !l.includes('Code style issues')).map(l => l.slice(7).trim())
205 problems.push(`prettier: ${bad.join(', ') || 'some files'}`)
206 }
207 }
208 return problems
209}
210
211// A Prettier npm installed: it lands inside the repo's node_modules, and git tracks
212// nothing in there. A copy the repo commits, or any file it commits under node_modules, is never run.
213// Its config still runs, as it would for `npm test`: reading the repo is on Claude, not this hook.
214async function trustedPrettier($: EngineInterface, root: string, bin: string) {
215 const realRoot = await realPath($, root)
216 const real = await realPath($, bin)
217 if (!realRoot || !real || !inside(real, `${realRoot.replace(/\/$/, '')}/node_modules`)) return false
218 const tracked = await $.process.run([...GIT_SAFE, 'ls-files', '--', 'node_modules'], { cwd: root }).catch(() => null)
219 return tracked !== null && tracked.exitCode === 0 && tracked.stdout.trim() === ''
220}
221
222function short(path: string) {
223 return path.split('/').slice(-2).join('/')
224}
225