A green/red environment badge above the prompt that turns red when Claude's tool calls touch anything that looks like production.

A small collection of Claude Code mods.
/plugin install <mod> --marketplace Arkboi-GG/claude-mods
The bars stack above the prompt, so you can install any combination.
/compact with instructions to keep the thread (goal, decisions, files, key values, open questions, next steps) so work carries on in the same topic; change them with the compactInstructions option. The 5-hour and 7-day rings show the time left until they reset (the ring still fills with the share used). If you also use the skins mod, run /skin band off once so its own usage band doesn't show twice.git; gh is optional).web=5173,api=3000).checks) and shows pass/fail with an error count.LOCAL badge that turns red PROD when a tool call matches your production patterns, and toasts when it happens.Name: , e.g. Olivia: rewrite welcome email; map names to outfits with the outfits option. While an agent runs, a playful stage word (Waking up, Analyzing, Cooking, Wrapping up) follows what its tool calls show it doing; "Wrapping up" is a guess, since an agent reports no progress.hooks/register.tsx 145 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { Touch } from '../types'
5
6const touchAtom = atom({ plugin: 'env-guard', key: 'touch' } as const, null as Touch)
7
8const WIDE = 110
9
10const gateAtom = atom({ plugin: 'env-guard', key: 'gate' } as const, false)
11
12// The bars only show in a GitHub repository: true when the session's folder is inside a git
13// repository whose remote is on GitHub (any git repository when `githubOnly` is off).
14async function inGithubRepo($: any, githubOnly: boolean): Promise<boolean> {
15 try {
16 const r = await $.process.run(['git', 'remote', '-v'], { timeoutMs: 5000 })
17 if (r.exitCode !== 0) return false
18 return !githubOnly || /github\.com/i.test(r.stdout)
19 } catch {
20 return false
21 }
22}
23
24async function checkGate($: any, githubOnly: boolean) {
25 const ok = await inGithubRepo($, githubOnly)
26 await update($, gateAtom, p => (p === ok ? p : ok))
27}
28
29// Shared "dev row" protocol (the same helper sits in every mod of this repo):
30// each mod adds a keyed zone to one row, so the mods fill a single line together
31// and still work alone. Zones sort by their key, `zone-<order>`.
32function addZone(below: any, zone: any, order: number): any {
33 const tagged = { ...zone, props: { ...zone.props, key: `zone-${order}`, flexShrink: 0 } }
34 const byKey = (a: any, b: any) => String(a?.props?.key).localeCompare(String(b?.props?.key))
35 const merge = (node: any): any => {
36 if (!node || typeof node !== 'object') return null
37 if (node.props?.key === 'devrow') return { ...node, children: [...(node.children ?? []), tagged].sort(byKey) }
38 const kids: any[] = node.children ?? []
39 for (let i = 0; i < kids.length; i++) {
40 const hit = merge(kids[i])
41 if (hit) return { ...node, children: kids.map((k, j) => (j === i ? hit : k)) }
42 }
43 return null
44 }
45 const merged = merge(below)
46 if (merged) return merged
47 const row = {
48 type: 'Box',
49 props: { key: 'devrow', paddingX: 1, justifyContent: 'space-between', flexWrap: 'wrap', columnGap: 3 },
50 children: [tagged],
51 }
52 return {
53 type: 'Box',
54 props: { flexDirection: 'column' },
55 children: below ? [below, row] : [row],
56 }
57}
58
59export const register: Register = (on, options) => {
60 const githubOnly = options.githubOnly !== false
61
62 // The session moved to another folder: check it again.
63 on('classic.CwdChanged', async ($, e, next) => {
64 await checkGate($, githubOnly)
65 return next(e)
66 })
67
68 on('session.start', async ($, e, next) => {
69 await checkGate($, githubOnly)
70 $.clock.every(15000, () => checkGate($, githubOnly))
71 return next(e)
72 })
73
74 const holdMs = Math.max(1, Number(options.holdMinutes ?? 10)) * 60000
75 const patterns: RegExp[] = []
76 for (const p of String(options.patterns ?? '\\bprod\\b,\\bproduction\\b').split(',')) {
77 const s = p.trim()
78 if (!s) continue
79 try {
80 patterns.push(new RegExp(s, 'i'))
81 } catch {
82 // an invalid pattern is skipped
83 }
84 }
85
86 // What a call is judged on: the command, URL or arguments it acts with, never
87 // the text of a file it edits or reads, and not a commit message or heredoc body.
88 const subject = (e: Record<string, unknown>): string => {
89 const tool = String(e.tool)
90 if (tool === 'Bash') {
91 return String(e.command ?? '')
92 .replace(/<<-?\s*['"]?(\w+)['"]?[\s\S]*?\n\s*\1\b/g, '')
93 .replace(/(-m|--message|--body|-b|--title|-t)\s+("[^"]*"|'[^']*')/g, '')
94 }
95 if (tool === 'WebFetch') return String(e.url ?? '')
96 if (tool.startsWith('mcp__')) {
97 const { tool: _t, tool_use_id: _i, ...args } = e
98 return `${tool} ${JSON.stringify(args)}`
99 }
100 return ''
101 }
102
103 const hitOf = (e: Record<string, unknown>): string | null => {
104 const text = subject(e)
105 if (!text) return null
106 for (const re of patterns) if (re.test(text)) return re.source
107 return null
108 }
109
110 on('tool.call', async ($, e, next) => {
111 const tool = String(e.tool)
112 const hit = hitOf(e as Record<string, unknown>)
113 if (hit) {
114 const at = await $.clock.now()
115 await update($, touchAtom, () => ({ at, tool, hit }))
116 $.ui.toast(`Production touched by ${tool} (matched "${hit}")`)
117 // clear the red badge once the hold time has passed
118 $.clock.after(holdMs + 1000, () => update($, touchAtom, t => (t && t.at === at ? { ...t } : t)))
119 }
120 return next(e)
121 })
122
123 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
124 const below = await next(e)
125 if (e.props.hasSurvey) return below
126
127 const touch = await read($, touchAtom)
128 const now = await $.clock.now()
129 const isRed = touch !== null && now - touch.at < holdMs
130 // The LOCAL badge only shows in a GitHub repository; a red PROD warning shows anywhere.
131 if (!isRed && !(await read($, gateAtom))) return below
132
133 const { Box, Text } = $.ui.resolve(e)
134 const zone = (
135 <Box gap={1}>
136 <Text color={isRed ? '#ef4444' : '#22c55e'} bold>
137 {isRed ? '▲ PROD' : '● LOCAL'}
138 </Text>
139 {isRed && touch ? <Text dimColor>{touch.tool} matched "{touch.hit}"</Text> : null}
140 </Box>
141 )
142 return addZone(below, zone, 9)
143 })
144}
145types/index.d.ts 8 lines1export type Touch = { at: number; tool: string; hit: string } | null
2
3declare module 'claude-code' {
4 interface PluginState {
5 'env-guard': { touch: Touch; gate: boolean }
6 }
7}
8