Screen-record Claude Code without leaking secrets: tells the model to keep keys, emails and private words off screen, and masks them in the transcript display…

Lawrence Chase's Claude Code marketplace: code review, diagram, test-evidence and software factory skills, plus a set of small Claude Code mods that add band lines and panes to the terminal UI.
/plugin marketplace add lchase/coding-agent-plugins
/plugin install smart-review@lchase
/plugin install tldraw@lchase
/plugin install test-drive@lchase
/plugin install cache-clock@lchase
/plugin install usage-gauge@lchase
/plugin install auto-handoff@lchase
/plugin install agent-watch@lchase
/plugin install recording-mode@lchase
/plugin install factory@lchase
Each plugin is independent; install only what you want. @lchase is the marketplace name (from .claude-plugin/marketplace.json), not the GitHub slug.
New versions ship whenever the version string in a plugin's manifest changes. Claude Code refreshes marketplaces in the background by default, so you normally pick up updates without doing anything. To pull them right now:
/plugin marketplace update lchase # refresh this marketplace's manifest
/plugin update smart-review@lchase # apply a pending update to one plugin
/plugin update tldraw@lchase
/plugin marketplace update (no name) refreshes every marketplace. From a shell: claude plugin marketplace update lchase and claude plugin update <plugin>@lchase.
If a plugin gets into a bad state (stale cached script, half-applied update), do a clean reinstall:
/plugin uninstall tldraw
/plugin marketplace update lchase
/plugin install tldraw@lchase
Nuclear option, re-register the whole marketplace:
/plugin marketplace remove lchase
/plugin marketplace add lchase/coding-agent-plugins
/plugin install smart-review@lchase
/plugin install tldraw@lchase
Before this repo became a multi-plugin marketplace it published one plugin from the repo root under a marketplace named chase. If you installed it back then, clear the old registration first:
/plugin uninstall smart-review
/plugin uninstall tldraw # only if you installed the short-lived tldraw@chase
/plugin marketplace remove chase
/plugin marketplace add lchase/coding-agent-plugins
/plugin install smart-review@lchase
/plugin install tldraw@lchase
The tldraw skill's command also changed: /tldraw:tldraw → /tldraw:diagram.
| Plugin | What it does | Skills / commands | Harnesses |
|---|---|---|---|
| smart-review | Ensemble code review: six specialized lenses over a diff, merged into one deduplicated, severity-ranked verdict | /smart-review:{review,min,max,add-pr-review,review-pr-comments} + auto-trigger | Claude Code, Cursor, Codex, Gemini CLI, any AGENTS.md agent |
| tldraw | Natural-language description → editable tldraw document (.tldr) + rendered PNG/SVG | /tldraw:diagram + auto-trigger | Claude Code only (needs Node + npx) |
| test-drive | Before/after evidence of a UI or API change: record the app before you edit, replay the same scripted scenario after, with a deterministic verdict | /test-drive:{baseline,compare} + auto-trigger | Claude Code only (needs Node; UI also needs Playwright and ffmpeg) |
| cache-clock | Mod: band line showing whether the prompt cache is warm. TTL, expiry, hit ratio, and re-cache size come from Claude Code when the status-line bridge is installed; otherwise the countdown is a marked estimate | Compact button (warm only), /cache-clock | Claude Code only |
| usage-gauge | Mod: band line with plan usage windows (5-hour, weekly, spend limit), reset times, pace warning, session cost on API billing, threshold toasts | /usage-gauge (detail pane) | Claude Code only |
| auto-handoff | Mod: band line showing how full the chat is; saves a HANDOFF.md at a threshold (auto or on request), then clear and continue or resume in a new session | /auto-handoff | Claude Code only |
| agent-watch | Mod: band line showing who is doing the work this turn (main chat, helper agents, models, tasks, status, skills), plus a pane with per-agent blocks, per-model totals, timeline | /agent-watch | Claude Code only |
| recording-mode | Mod: screen-record without leaking secrets; tells the model to keep keys, emails, private words off screen and masks them in the transcript display only, red REC chip | /rec | Claude Code only |
| factory | Software factory: a feature or bug goes through spec-writer, builder, four parallel reviewers and an approver on its own branch, then merges to main or waits for you; live dashboard | /factory <input>, /factory {setup,next,approve,rework,serve} | Claude Code only (dashboard needs Bun) |
An ensemble code review: several specialized lenses, one merged verdict, not another pile of comments.
Most code review, human or AI, is one reviewer making a single pass and leaving a list of comments. This runs six specialized lenses instead (spec-conformance, correctness, security, performance, design, and tests), then merges the results into one verdict: duplicates collapsed, findings that several lenses independently raise weighted up, conflicting advice reconciled, severity rolled up, structural problems first, nits capped. The merge is the point. An ensemble without it is just louder, and a longer checklist handed to one reviewer only dilutes its attention and repeats its own misses.
Two modes: a fast single pass (min) for tight loops, and an orchestrated ensemble (max) for pre-merge review. Auto-routing picks between them by change size and sensitivity.
The skill lives in plugins/smart-review/skills/smart-review/ as harness-neutral markdown. Each harness gets a thin manifest pointing at that same directory, so no skill content is copied or forked.
| Harness | Install | min | max | Slash commands / auto-trigger |
|---|---|---|---|---|
| Claude Code | /plugin marketplace add lchase/coding-agent-plugins then /plugin install smart-review@lchase | ✅ | ✅ isolated parallel subagents | ✅ |
| Cursor | point Cursor at plugins/smart-review/.cursor-plugin/ | ✅ | ✅ sequential ensemble | via session-start hook |
| Codex | plugins/smart-review/.codex-plugin/ manifest | ✅ | ✅ sequential ensemble | no |
| Gemini CLI | gemini extensions install https://github.com/lchase/coding-agent-plugins (reads root gemini-extension.json) | ✅ | ✅ sequential ensemble | via GEMINI.md |
| Any AGENTS.md agent | reads root AGENTS.md | ✅ | ✅ sequential ensemble | no |
max's isolated parallel subagents are a Claude Code capability. A model panel (plugins/smart-review/skills/smart-review/references/ensemble.md, off by default) rides on top when the harness can route more than one model. Otherwise max is single-model. Elsewhere max runs the same spec-gate, six lenses, and merge as a disciplined sequential walk. Design and internals: plugins/smart-review/SMART-REVIEW.md.
Claude Code slash commands:
/smart-review:review: auto (routes to min or max by size + sensitivity)/smart-review:min: fast single-pass review/smart-review:max: orchestrated ensemble review/smart-review:add-pr-review <PR number or URL>: reviews a GitHub PR and, after you confirm what to publish, posts the findings as PR comments/smart-review:review-pr-comments <PR number or URL>: triages a PR's existing unresolved review comments, fixes or explains each after your approval, replies, and resolves the threadThe skill also triggers automatically when you ask Claude to review a diff, PR, or branch.
Turn a described diagram (flowchart, architecture / system diagram, process map, decision tree, state machine) into two artifacts: an editable .tldr document (opens at tldraw.com or in the tldraw editor) and a rendered PNG/SVG for docs and PRs.
Claude writes a {nodes, edges} spec from your description; a bundled Node script does a simple layered auto-layout, emits the .tldr, and renders images by loading it into a headless-Chromium tldraw instance via @kitschpatrol/tldraw-cli (first run downloads Chromium, ~1 min, cached).
/plugin install tldraw@lchase
Claude Code only. Skill: /tldraw:diagram (also auto-triggers on "draw this diagram", "diagram this flow", "make a tldraw of…"). Details: plugins/tldraw/skills/diagram/SKILL.md.
A test drive is an e2e test that happens to produce video, and the "before" is part of the process rather than something reconstructed later. Run /test-drive:baseline before you edit: it writes a short browser scenario and records the app as it stands. Make the change, then run /test-drive:compare: it replays the identical scenario with Playwright and composes a labeled side-by-side MP4. The pass/warn/fail verdict comes from the scenario's assertions, not from reading the video.
Backend changes work the same way with "kind": "api": the scenario is a list of HTTP steps (method, path, body, expected status, JSON fields, and server-log lines to expect or avoid). There is nothing to screen-record, so each step captures the request, the response, and the server log lines it produced, and compare writes a before/after report.md instead of a video. Secrets are redacted from the stored transcript (best effort, extendable per scenario with redact), and the finished report is scanned and flagged if anything still looks secret.
/plugin install test-drive@lchase
Claude Code only. UI scenarios need ffmpeg and Playwright in the repo under test; API scenarios need only Node 18+. Only the working tree is ever run, so there is no second checkout to boot. Details: baseline and compare.
Five small plugins that change Claude Code's own interface instead of adding a task skill. Each draws a band line above the prompt (some add a side pane or slash command), is independent of the others, and works on Claude Code only.
/cache-clock setup, the countdown, TTL, hit ratio, re-cache size, and last miss cause come from Claude Code's own prompt_cache (v2.1.251+). Without that, the band uses your promptCacheTtl or cache environment variables, and only then a fallback (cacheMinutes, default 5) marked with ?. Compact is offered only while the cache is warm. Dollar figures stay hand-kept list-price estimates./usage-gauge opens a detail pane.HANDOFF.md at a threshold (automatically or on request), then clears and continues, or resumes in a new session. /auto-handoff./agent-watch opens a pane with per-agent blocks, per-model totals, and a timeline./rec to toggle./plugin install cache-clock@lchase # or usage-gauge, auto-handoff, agent-watch, recording-mode
Claude Code tells a status-line script whether the prompt cache is warm, when it expires, and the session hit ratio (prompt_cache on the status-line JSON, v2.1.251 or later). A plugin cannot register a status line, and the mods API does not include those fields, so cache-clock reads them through a small bridge.
In Claude Code, run:
/cache-clock setup
That edits your user settings (~/.claude/settings.json, or $CLAUDE_CONFIG_DIR/settings.json when that variable is set). It saves whatever statusLine was there and points statusLine at cache-clock/bridge.mjs, which still runs your previous status line and writes Claude Code's prompt_cache for the band to read. /cache-clock remove puts the previous value back. node must be on PATH. Setup refuses to edit a status line that comes from managed settings, --settings, or a project or local settings file.
The same edit by hand, when you have no status line yet:
{
"statusLine": {
"type": "command",
"command": "node ~/.claude/cache-clock/bridge.mjs"
}
}
Run /cache-clock setup once so the script is copied into that folder. After the next reply the band's TTL and expiry are Claude Code's figures, not a guess. The band redraws every 30 seconds from the last expires_at. Claude Code also re-runs the status line on its own events, and when a warm cache reaches expires_at.
Until the bridge is installed, the band still works. It follows this order: prompt_cache if the bridge has written it, then FORCE_PROMPT_CACHING_5M, CLAUDE_CODE_PROMPT_CACHE_TTL, the promptCacheTtl setting, ENABLE_PROMPT_CACHING_1H, then the cacheMinutes option (5 or 60, default 5). Only that last step is marked with ?. A subscription within plan usage is often 60 minutes and an API key, cloud provider, or usage-credit session is often
/cache-clock status names which of those sources the band is using.
A small, visual software factory. /factory <input> takes a feature or bug as text, a path to a requirements .md, an issue key or URL, or a GitHub issue, and runs it through a fixed loop: spec-writer writes a spec with testable acceptance criteria, builder implements it in its own git worktree (via the Orca CLI when present, so .env and setup hooks come along, else plain git worktree), four reviewers (security, ux, ui, code) run in parallel and each writes a VERDICT: PASS | CHANGES file, the builder is resumed while any review says CHANGES (max two rounds), then an approver writes APPROVE or ESCALATE. APPROVE merges to main locally; ESCALATE parks the job as needs-human.
/plugin install factory@lchase
Then, in a repo:
/factory setup # once per repo: profiles it into .factory/repo.md, review that file
/factory <text | path.md | KEY-123 | #123>
/factory next # first unchecked item in .factory/backlog.md
/factory approve <job-id> # merge a needs-human job
/factory rework <job-id> <note> # send it back to the builder with your note
/factory serve # live board at http://localhost:8765 (needs Bun)
Nothing repo-specific is baked in: commands, conventions, commit rules, issue tracker and the approver's never-auto-merge list all come from .factory/repo.md, which /factory setup drafts and you edit. Job state is .factory/jobs/<id>/ (gitignored), one folder of markdown per job, so several sessions can run jobs at once and the dashboard shows them all.
Claude Code only. Dashboard needs Bun. Full guide, including what happens when a job stops for you: plugins/factory/README.md.
benchmarks/token-savings/ compares stock Claude Code with plugins and settings that claim to cut tokens or cost. It is not a marketplace plugin. Click 8.5.0 is fetched at a pinned commit when you run it. The full matrix calls the Anthropic API and has a hard ceiling of $600 at the default per-session cap. Read the benchmark README before you run it. ./benchmarks/token-savings/check.sh is the offline check and does not spend API money.
.claude-plugin/marketplace.json # the "lchase" marketplace: 9 plugin entries
AGENTS.md # repo-level agent pointer (→ smart-review)
gemini-extension.json + GEMINI.md # Gemini CLI installs the repo as an extension (→ smart-review)
plugins/smart-review/ # plugin 1, multi-harness code review
.claude-plugin/plugin.json
skills/smart-review/ # the harness-neutral core (SKILL.md + references/)
agents/ commands/ hooks/ # Claude Code packaging
.cursor-plugin/ .codex-plugin/ # thin per-harness manifests
scripts/ # validate-adapters.sh, bump-version.sh
evals/ # dev-only eval kit (not shipped to installers)
SMART-REVIEW.md # design writeup
plugins/tldraw/ # plugin 2, Claude Code only
.claude-plugin/plugin.json
skills/diagram/ # SKILL.md + scripts/build-tldr.mjs + references/
plugins/test-drive/ # plugin 3, Claude Code only
.claude-plugin/plugin.json
skills/{baseline,compare}/ # SKILL.md each
scripts/{lib.mjs,record.mjs,record-api.mjs,redact.mjs,verdict.mjs,compose.sh,report.mjs} # shared by both skills
references/ # UI and API scenario schemas + examples
plugins/factory/ # plugin 4, Claude Code only
.claude-plugin/plugin.json
skills/factory/SKILL.md # the orchestrator loop, commands, setup, job.json and repo.md schemas
agents/ # spec-writer, builder, review-{security,ux,ui,code}, approver, repo-profiler
dashboard/ # dashboard.html + serve.ts (Bun) + example/ dummy jobs
plugins/{cache-clock,usage-gauge,auto-handoff,agent-watch,recording-mode}/ # plugins 5-9, Claude Code mods
.claude-plugin/plugin.json # each with its own version
hooks/ # register.tsx (the mod) + hooks.json, tests where present
types/ # mod API typings
benchmarks/token-savings/ # paired Claude Code cost benchmark (not a plugin)
claude plugin validate . # marketplace + all plugins
./plugins/smart-review/scripts/validate-adapters.sh # smart-review's per-harness manifests
./benchmarks/token-savings/check.sh # benchmark lint and graders; no API spend
claude plugin test plugins/cache-clock # mod tests, including the native prompt_cache path
node --test plugins/cache-clock/statusline/bridge.test.mjs
Releasing: users only get an update when a plugin's version string changes, so bump it on every user-facing change and push to main.
./plugins/smart-review/scripts/bump-version.sh <version>..claude-plugin/plugin.json.Once pushed, installed clients pick it up on their next background marketplace refresh, or immediately with /plugin marketplace update lchase.
hooks/register.tsx 202 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Settings } from '../types'
5import { HELP, hint, mask, maskDeep, policyText } from './lib'
6import type { MaskOptions } from './lib'
7
8const DEFAULTS: Settings = { isOn: false, isStrict: false }
9const settings = atom({ plugin: 'recording-mode', key: 'settings' } as const, DEFAULTS)
10
11const isSettings = (v: unknown): v is Settings =>
12 typeof v === 'object' &&
13 v !== null &&
14 typeof (v as Settings).isOn === 'boolean' &&
15 typeof (v as Settings).isStrict === 'boolean'
16
17const loadWords = async ($: EngineInterface): Promise<string[]> => {
18 const raw = await $.store.get('words')
19
20 return Array.isArray(raw) ? raw.filter((w): w is string => typeof w === 'string') : []
21}
22
23/** The masking options, or null while recording mode is off. */
24const optionsOf = async ($: EngineInterface): Promise<MaskOptions | null> => {
25 const cfg = ((await read($, settings)) as Settings | undefined) ?? DEFAULTS
26 if (!cfg.isOn) return null
27
28 return { isStrict: cfg.isStrict, words: await loadWords($) }
29}
30
31function show($: EngineInterface, cfg: Settings) {
32 $.ui.status(cfg.isOn ? (cfg.isStrict ? '● REC strict' : '● REC') : undefined)
33}
34
35async function apply($: EngineInterface, cfg: Settings) {
36 await update($, settings, () => cfg)
37 await $.store.set('settings', cfg)
38 show($, cfg)
39}
40
41export const register: Register = on => {
42 on('session.start', async ($, e, next) => {
43 const saved = await $.store.get('settings')
44 if (isSettings(saved)) {
45 await update($, settings, () => saved)
46 if (saved.isOn) {
47 show($, saved)
48 $.ui.toast('Recording mode is still ON')
49 }
50 }
51 await $.command.register({
52 name: 'rec',
53 description: 'Recording mode: mask secrets on screen',
54 argumentHint: 'strict | off | hide <word> | unhide <word> | list | test <text>',
55 })
56
57 return next(e)
58 })
59
60 on('prompt.compose', async ($, e, next) => {
61 const result = await next(e)
62 const cfg = ((await read($, settings)) as Settings | undefined) ?? DEFAULTS
63 if (!cfg.isOn) return result
64
65 return {
66 sections: [
67 ...result.sections,
68 { id: 'recording-mode:policy', text: policyText(cfg.isStrict), scope: 'session' as const },
69 ],
70 }
71 })
72
73 on('command.run', { command: 'rec' }, async ($, e) => {
74 const [head = '', ...rest] = e.args.trim().split(/\s+/)
75 const verb = head.toLowerCase()
76 const arg = rest.join(' ').trim()
77 const cfg = ((await read($, settings)) as Settings | undefined) ?? DEFAULTS
78
79 if (verb === '' || verb === 'on') {
80 const next: Settings = verb === '' && cfg.isOn ? { ...cfg, isOn: false } : { isOn: true, isStrict: false }
81 await apply($, next)
82 $.ui.toast(next.isOn ? 'Recording mode ON' : 'Recording mode OFF')
83
84 return { text: next.isOn ? 'Recording mode is on.' : 'Recording mode is off.' }
85 }
86 if (verb === 'strict') {
87 await apply($, { isOn: true, isStrict: true })
88 $.ui.toast('Recording mode ON (strict)')
89
90 return { text: 'Recording mode is on, strict: amounts and home paths hidden too.' }
91 }
92 if (verb === 'off') {
93 await apply($, { ...cfg, isOn: false })
94 $.ui.toast('Recording mode OFF')
95
96 return { text: 'Recording mode is off.' }
97 }
98 if (verb === 'hide' || verb === 'unhide') {
99 if (arg === '') return { text: `Usage: /rec ${verb} <word>` }
100 const words = await loadWords($)
101 const has = words.some(w => w.toLowerCase() === arg.toLowerCase())
102 if (verb === 'hide') {
103 if (!has) await $.store.set('words', [...words, arg])
104
105 return { text: `Hiding ${hint(arg)} (${has ? words.length : words.length + 1} private words).` }
106 }
107 await $.store.set('words', words.filter(w => w.toLowerCase() !== arg.toLowerCase()))
108
109 return { text: has ? `Unhid ${hint(arg)}.` : `${hint(arg)} was not hidden.` }
110 }
111 if (verb === 'list') {
112 const words = await loadWords($)
113
114 return {
115 text: words.length === 0 ? 'No private words.' : `${words.length} private words: ${words.map(hint).join(' ')}`,
116 }
117 }
118 if (verb === 'test') {
119 const words = await loadWords($)
120 // Preview shows what strict-or-not would look like for the current setting, masked even while off.
121 const out = mask(e.args.trim().slice(head.length).trim(), { isStrict: cfg.isStrict, words })
122
123 return { text: `Masked: ${out}` }
124 }
125
126 return { text: HELP }
127 })
128
129 // Display only: each site rewrites the props the engine draws, never what the model read.
130 on('ui.render', { component: 'UserMessage' }, async ($, e, next) => {
131 const o = await optionsOf($)
132 if (o === null) return next(e)
133
134 return next({ ...e, props: { ...e.props, text: mask(e.props.text, o) } })
135 })
136
137 on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
138 const o = await optionsOf($)
139 if (o === null) return next(e)
140
141 return next({ ...e, props: { ...e.props, text: mask(e.props.text, o) } })
142 })
143
144 on('ui.render', { component: 'CommandOutput' }, async ($, e, next) => {
145 const o = await optionsOf($)
146 if (o === null) return next(e)
147
148 return next({ ...e, props: { ...e.props, text: mask(e.props.text, o) } })
149 })
150
151 on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
152 const o = await optionsOf($)
153 if (o === null) return next(e)
154
155 return next({ ...e, props: { ...e.props, input: maskDeep(e.props.input, o) } })
156 })
157
158 on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
159 const o = await optionsOf($)
160 if (o === null) return next(e)
161
162 return next({ ...e, props: { ...e.props, output: maskDeep(e.props.output, o) } })
163 })
164
165 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
166 const cfg = ((await read($, settings)) as Settings | undefined) ?? DEFAULTS
167 if (e.props.hasSurvey || !cfg.isOn) return next(e)
168
169 const { Box, Text } = $.ui.resolve(e)
170 const note = cfg.isStrict ? 'secrets, amounts and home paths masked' : 'secrets masked on screen'
171 // label column is 7 wide, the length of 'handoff', so stacked bands line up
172 const chip = e.surface !== 'terminal' ? (
173 // proportional fonts collapse the padding and box-drawing glyphs, so space the parts with gap
174 <Box flexDirection="row" alignItems="center">
175 <Box width={9} flexShrink={0}><Text dimColor bold>rec</Text></Box>
176 <Box flexDirection="row" alignItems="center" flexWrap="wrap" flexGrow={1} gap={1}>
177 <Text bold color="#f87171">● {cfg.isStrict ? 'strict' : 'recording'}</Text>
178 <Text dimColor>{note}</Text>
179 </Box>
180 </Box>
181 ) : (
182 <Box>
183 <Text dimColor>{'rec'.padStart(7)}</Text>
184 <Text dimColor>{' │ '}</Text>
185 <Text bold color="#f87171">● </Text>
186 <Text bold>{cfg.isStrict ? 'strict' : 'recording'}</Text>
187 <Text dimColor> · {note}</Text>
188 </Box>
189 )
190 const below = await next(e)
191
192 return below ? (
193 <Box flexDirection="column">
194 {chip}
195 {below}
196 </Box>
197 ) : (
198 chip
199 )
200 })
201}
202hooks/lib.ts 77 lines1export type MaskOptions = { isStrict: boolean; words: readonly string[] }
2
3export const OFF_SCREEN = "Recording mode is on, so I'll keep that off screen"
4
5export const POLICY = [
6 'Recording mode is on: the user is screen-recording this session.',
7 'Never print API keys, tokens, passwords, secret environment values, email addresses, phone numbers or the user\'s private words, whether they come from files, tool output or the user.',
8 'Refer to them generically ("your API key", "the email address in the config") and, when you hold back something the user asked for, say: "' + OFF_SCREEN + '".',
9 'Do not echo such values inside commands or code you show either; use placeholders.',
10].join('\n')
11
12const STRICT_POLICY = ' Also keep dollar amounts and home-folder paths off screen.'
13
14export const policyText = (isStrict: boolean): string => (isStrict ? POLICY + STRICT_POLICY : POLICY)
15
16const escape = (s: string): string => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
17
18// Order matters: key shapes first so a token is never half-eaten by a later rule.
19const KEY_RULES: readonly (readonly [RegExp, string])[] = [
20 [/\bsk-[A-Za-z0-9_-]{16,}/g, '[key]'],
21 [/\bgh[pousr]_[A-Za-z0-9]{20,}/g, '[key]'],
22 [/\bgithub_pat_[A-Za-z0-9_]{20,}/g, '[key]'],
23 [/\bxox[abposr]-[A-Za-z0-9-]{10,}/g, '[key]'],
24 [/\bBearer\s+[A-Za-z0-9._~+/=-]{8,}/g, 'Bearer [key]'],
25 [
26 /^([ \t]*(?:export[ \t]+)?[A-Za-z_][A-Za-z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIAL)[A-Za-z0-9_]*[ \t]*=[ \t]*)\S.*$/gim,
27 '$1[key]',
28 ],
29]
30
31const EMAIL = /[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+/g
32// Needs a separator or a leading plus, so commit ids and plain numbers stay.
33const PHONE = /(?<![\w.])(?:\+\d{1,3}[\s.-]?)?(?:\(\d{3}\)\s?|\d{3}[\s.-])\d{3}[\s.-]\d{4}(?![\w])|(?<![\w.])\+\d{1,3}[\s.-]\d{2,4}[\s.-]\d{3,4}(?:[\s.-]\d{2,4})?(?![\w])/g
34
35const MONEY = /[$€£]\s?\d[\d,]*(?:\.\d+)?(?:\s?[kKmMbB]\b)?/g
36const HOME = /(?:\/Users\/|\/home\/|[A-Za-z]:\\Users\\)[^\s/\\:"'`]+/g
37
38export function mask(text: string, o: MaskOptions): string {
39 let out = text
40 for (const [re, to] of KEY_RULES) out = out.replace(re, to)
41 out = out.replace(EMAIL, '[email]').replace(PHONE, '[phone]')
42 for (const w of o.words) {
43 if (w === '') continue
44 out = out.replace(new RegExp(`(?<![A-Za-z0-9])${escape(w)}(?![A-Za-z0-9])`, 'gi'), '[private]')
45 }
46 if (o.isStrict) out = out.replace(MONEY, '[amount]').replace(HOME, '[home]')
47
48 return out
49}
50
51/** Masks every string in a JSON-like value, leaving shape and other types alone. */
52export function maskDeep(v: unknown, o: MaskOptions): unknown {
53 if (typeof v === 'string') return mask(v, o)
54 if (Array.isArray(v)) return v.map(x => maskDeep(x, o))
55 if (typeof v === 'object' && v !== null) {
56 const out: Record<string, unknown> = {}
57 for (const [k, x] of Object.entries(v)) if (x !== undefined) out[k] = maskDeep(x, o)
58
59 return out
60 }
61
62 return v
63}
64
65/** First letter and dots, so a list never shows the word itself. */
66export const hint = (w: string): string => `${[...w][0] ?? ''}•••`
67
68export const HELP = [
69 '/rec toggle recording mode',
70 '/rec strict on, and also hide $ amounts and home-folder paths',
71 '/rec off turn off',
72 '/rec hide <w> mask a private word',
73 '/rec unhide <w> stop masking it',
74 '/rec list count and first letters',
75 '/rec test <t> preview masking',
76].join('\n')
77types/index.d.ts 9 lines1export type Settings = { isOn: boolean; isStrict: boolean }
2
3declare module 'claude-code' {
4 interface PluginState {
5 // Private words are never kept here, only in $.store.
6 'recording-mode': { settings: Settings }
7 }
8}
9