In the dotfiles repo, refuses the checks reserved for the human: make check-full, make test, bin/check --full (AGENTS.md), scripts/test_runner.py and…

Personal macOS dotfiles managed with Chezmoi: Fish, tmux, Neovim, CLI assistants, and package installation.
Read the documentation for setup, command references, and configuration recipes (source: docs/).
| Feature | Description |
|---|---|
| Agent memory | ,ai-kb knowledge base and ,handoff session notes |
| Local inference | llama.cpp router and model sync (,llama-cpp) |
| Git identity | 1Password SSH agent and SSH commit signing |
| Git worktrees | Worktree management with PR integration |
| Neovim | LSP, commit-message assistance, and refactoring tools |
| Fish | Comma-prefixed commands in ~/bin |
| Packages | Homebrew lists by category and mise-managed runtimes |
Use macOS with 1Password installed and signed in for SSH keys and secrets. Applying this setup installs packages, changes shell and macOS settings, and can remove Homebrew packages absent from its Brewfile. Review Getting Started and New machine bootstrap before applying it to an existing machine.
sh -c "$(curl -fsLS get.chezmoi.io/lb)" -- init --apply kapral18
If Chezmoi is already installed, preview with chezmoi init kapral18 && chezmoi diff before running chezmoi apply.
Chezmoi renders templates from home/ into $HOME. Hooks in home/.chezmoiscripts/ install and reconcile packages when lists change.
For the full layout (naming conventions, hook lifecycle, AI config merging, externals), see Architecture.
| Area | Doc | Source-of-truth (edit here) |
|---|---|---|
| Packages (Homebrew, mise, cargo, go, …) | Packages | home/.chezmoitemplates/brews/, home/readonly_dot_default-* |
Custom ~/bin commands | Custom commands | home/exact_bin/, home/exact_lib/ |
| Git identity & worktrees | Worktrees | home/exact_bin/executable_,w |
| GitHub picker & tmux | Tmux | home/dot_config/exact_tmux/ |
| Fish shell | Shell: Fish | home/dot_config/fish/ |
| Neovim | Neovim | home/dot_config/exact_nvim/ |
| macOS automation | macOS | home/dot_hammerspoon/, home/.osx.core |
| Reference map (where to change X) | Reference map | — |
tmux-resurrect / continuum).,w add … or the GitHub picker (prefix + G) for branch/PR worktrees.,update to update tools or chezmoi apply to apply the declared configuration and package lists.See A day in the life for a fuller walkthrough.
docs/intro/index.mdCONTRIBUTING.mdAGENTS.mdhome/.chezmoi.toml.tmplhooks/register.ts 25 lines1import type { Register } from 'claude-code'
2
3// A copy of sop-guard's scanner; scripts/tests/test_claude_mods.py keeps them equal.
4import { base, simpleCommands } from './shell'
5
6// make flags whose next word is their value, not a target.
7const MAKE_VALUE_FLAGS = new Set(['-C', '-f', '-I', '-o', '-W', '--directory', '--file'])
8
9const isReservedCheck = ([name, ...args]: string[]) => {
10 const command = base(name)
11 if (command === 'make') return args.some((arg, i) => (arg === 'test' || arg === 'check-full') && !MAKE_VALUE_FLAGS.has(args[i - 1] ?? ''))
12 if ((name ?? '').endsWith('bin/check')) return args.includes('--full')
13 if (/^(python3?|uv)$/.test(command) && args.some(arg => arg.endsWith('scripts/check.py'))) return args.includes('--full')
14 if (command === 'test_runner.py') return true
15 return /^(python3?|uv)$/.test(command) && args.some(arg => arg.endsWith('scripts/test_runner.py'))
16}
17
18export const register: Register = on => {
19 on('tool.call', { tool: 'Bash' }, ($, e, next) =>
20 simpleCommands(e.command).some(command => isReservedCheck(command.words))
21 ? { deny: `${$.plugin.name}: AGENTS.md reserves make check-full, make test, and bin/check --full for the human, and the user reserved scripts/test_runner.py and scripts/check.py --full. Run make check.` }
22 : next(e),
23 ).catch(($, e, next) => next(e))
24}
25hooks/shell.ts 248 lines1// A small reading of a Bash command: the simple commands it runs, by command word.
2// Quoted text and heredoc bodies are data, never commands, so they are blanked first.
3
4export type Simple = {
5 // The words after assignments, wrappers, and keywords, quotes removed.
6 words: string[]
7 // Inside $(...) or backticks: its stdout feeds another command.
8 isSubstituted: boolean
9 // Its stdout goes to a file or /dev/null.
10 isRedirected: boolean
11 // The pipeline stages after this one.
12 after: Simple[]
13}
14
15const WRAPPERS = new Set(['env', 'time', 'sudo', 'command', 'exec', 'nice', 'nohup'])
16const KEYWORDS = new Set(['if', 'then', 'else', 'elif', 'while', 'until', 'do', '!', '{'])
17// Stdout into a file or /dev/null; `2>` and `>&2` still leave it in the transcript.
18const STDOUT_REDIRECT = /(^|[^0-9&>])>(?!&)|&>|\b1>(?!&)/
19
20// A heredoc operator and the rest of its line; its body starts on the next line.
21// `<<-` lets tabs indent the closing line; quotes and backslashes in the end word (`<<'EOF'`, `<<E\OF`, `<<E"O"F`) are removed.
22const HEREDOC = /<<(-?)\s*((?:\\.|'[^']*'|"(?:\\.|[^"\\])*"|[^\s;&|<>()'"\\])+)[^\n]*\n/y
23const escapeRegExp = (text: string) => text.replace(/[.*+?^${}()|[\]\\-]/g, '\\$&')
24// A command starts after a separator, an opening `(` or `{`, a `)` that is not a substitution's, or a keyword.
25const isCommandStart = (before: string, isCommandParen: (at: number) => boolean) => {
26 const trimmed = before.replace(/[ \t]+$/, '')
27 return isCommandParen(trimmed.length - 1) || /(?:^|[;&|({\n]|(?:^|[\s;&|({])(?:if|elif|while|until|then|do|else|time|coproc|!))$/.test(trimmed)
28}
29// `((` is arithmetic when the `)` that closes it at depth 0 is followed by `)`: `for ((i=0; i<n; i++))` is,
30// `((cd a; ls) )` is two subshells.
31const closesArithmetic = (command: string, from: number) => {
32 let depth = 0
33 for (let j = from; j < command.length; j++) {
34 if (command[j] === '(') depth++
35 else if (command[j] === ')') {
36 if (depth === 0) return command[j + 1] === ')'
37 depth--
38 }
39 }
40 return false
41}
42
43// The command with quoted spans, escaped characters, and heredoc bodies as spaces; offsets kept.
44// A `<<` counts as a heredoc only where the shell reads one: outside quotes, or inside a `$(` within double quotes.
45// Its body is blanked as one block, so a quote inside it never opens a span.
46// `comments` holds where each comment starts, so its words are never read as arguments.
47const mask = (command: string) => {
48 const chars = command.split('')
49 const bodies: [number, number][] = []
50 const comments: number[] = []
51 // A `)` after which a command can follow: one that closes nothing (a case pattern), a function's `()`,
52 // a `(pattern)` after `in` or `;;`, or a subshell. A glob's `*(N)` is none of these.
53 const commandParens = new Set<number>()
54 // Where each open plain `(` starts.
55 const parenOpens: number[] = []
56 // Characters taken by a backslash escape; an escaped newline is removed, so the character before its backslash counts.
57 const escaped = new Set<number>()
58 const before = (j: number) => {
59 while (j >= 1 && command[j] === '\n' && escaped.has(j)) j -= 2
60 return j
61 }
62 // Open spans, innermost last: a quote, a `$'` ANSI-C quote, a `$(` substitution, a `$((` or `((` arithmetic,
63 // a `${` expansion, a `[[` test, or a `(` group.
64 const stack: string[] = []
65 const isQuoted = () => stack.includes('"') || stack.includes("'") || stack.includes("$'")
66 for (let i = 0; i < chars.length; i++) {
67 const body = bodies.find(([start, end]) => i >= start && i < end)
68 if (body) {
69 for (; i < body[1]; i++) chars[i] = ' '
70 i--
71 continue
72 }
73 const c = chars[i]
74 const top = stack[stack.length - 1]
75 const wasQuoted = isQuoted()
76 if (top === "'") {
77 if (c === "'") stack.pop()
78 } else if (c === '\\') {
79 // An escaped character is data; an escaped newline joins two lines into one command.
80 chars[i] = ' '
81 if (i + 1 < chars.length) chars[i + 1] = ' '
82 escaped.add(i + 1)
83 i++
84 continue
85 } else if (top === "$'") {
86 if (c === "'") stack.pop()
87 } else if (c === '$' && chars[i + 1] === '(') {
88 // `$((` opens arithmetic, where `<<` is a shift; `$(` opens a substitution.
89 const open = chars[i + 2] === '(' ? '$((' : '$('
90 stack.push(open)
91 if (wasQuoted) for (let j = i; j < i + open.length; j++) chars[j] = ' '
92 i += open.length - 1
93 continue
94 } else if (top === '"') {
95 if (c === '"') stack.pop()
96 else if (c === '$' && chars[i + 1] === '{') {
97 // A `${` in double quotes opens a span where `"` and `${` nest; `'` stays literal, as in zsh, the Bash tool's shell.
98 stack.push('${"')
99 chars[i] = chars[i + 1] = ' '
100 i++
101 continue
102 }
103 } else if (top === '${"') {
104 if (c === '}') stack.pop()
105 else if (c === '"') stack.push(c)
106 else if (c === '$' && chars[i + 1] === '{') {
107 stack.push('${"')
108 chars[i] = chars[i + 1] = ' '
109 i++
110 continue
111 }
112 } else {
113 const isArithmetic = stack.includes('$((') || stack.includes('((')
114 // Inside `${ }` and `[[ ]]`, parentheses are patterns, not groups, and `<<` is no heredoc.
115 const isBrace = top === '${'
116 const isTest = top === '[['
117 if (!isArithmetic && !isBrace && !isTest && command.startsWith('<<', i) && command[i - 1] !== '<' && command[i + 2] !== '<') {
118 HEREDOC.lastIndex = i
119 const doc = HEREDOC.exec(command)
120 if (doc) {
121 const bodyStart = i + doc[0].length
122 const close = new RegExp(`^${doc[1] ? '\\t*' : ''}${escapeRegExp((doc[2] ?? '').replace(/\\(.)|['"]/g, '$1'))}$`, 'm')
123 const end = close.exec(command.slice(bodyStart))
124 bodies.push([bodyStart, end ? bodyStart + end.index + end[0].length : command.length])
125 }
126 }
127 // A `#` at a word start in the original text, not after an escaped character, starts a comment.
128 // Inside `${ }` it never does; inside `[[ ]]` only after a space (`[[ $l =~ ^(#|$) ]]` holds no comment).
129 const previous = before(i - 1)
130 const isWordStart = previous < 0 || ((isTest ? /\s/ : /[\s;|&()<>]/).test(command[previous] ?? '') && !escaped.has(previous))
131 if (c === '#' && isWordStart && !isBrace && !isArithmetic) {
132 // A comment runs to the end of its line; a quote inside it opens nothing.
133 comments.push(i)
134 for (; i + 1 < chars.length && chars[i + 1] !== '\n'; i++) chars[i + 1] = ' '
135 continue
136 }
137 // `$$` is the shell's PID, so a quote after it is a plain quote.
138 if (c === '$' && chars[i + 1] === '$') {
139 i++
140 continue
141 }
142 if (c === '$' && chars[i + 1] === "'") {
143 stack.push("$'")
144 i++
145 continue
146 }
147 if (c === '$' && chars[i + 1] === '{') {
148 stack.push('${')
149 i++
150 continue
151 }
152 // `[[ ` opens a test only in command position; `]]` closes it only as its own word, so `[[:space:]]` stays inside.
153 if (c === '[' && chars[i + 1] === '[' && /\s/.test(command[i + 2] ?? '') && !isBrace && isCommandStart(command.slice(0, i), at => commandParens.has(at))) {
154 stack.push('[[')
155 i++
156 continue
157 }
158 if (isTest && c === ']' && chars[i + 1] === ']' && /\s/.test(command[i - 1] ?? '') && /^(?:[\s;&|)]|$)/.test(command.slice(i + 2, i + 3))) {
159 stack.pop()
160 i++
161 continue
162 }
163 if (c === "'" || c === '"') stack.push(c)
164 else if (isBrace && c === '}') stack.pop()
165 else if ((isBrace || isTest) && (c === '(' || c === ')')) chars[i] = ' '
166 else if (c === '(' && chars[i + 1] === '(' && closesArithmetic(command, i + 2)) {
167 stack.push('((')
168 i++
169 } else if (c === '(') {
170 stack.push('(')
171 parenOpens.push(i)
172 } else if (c === ')' && (top === '$((' || top === '((') && chars[i + 1] === ')') {
173 stack.pop()
174 if (wasQuoted && isQuoted()) chars[i] = chars[i + 1] = ' '
175 i++
176 continue
177 } else if (c === ')' && top === '$(') stack.pop()
178 else if (c === ')' && top === '(') {
179 stack.pop()
180 const open = parenOpens.pop() ?? -1
181 const head = command.slice(0, open)
182 if (open === i - 1 || /(?:\bin|;;|;&)\s*$/.test(head) || isCommandStart(head, at => commandParens.has(at))) commandParens.add(i)
183 } else if (c === ')') commandParens.add(i)
184 }
185 // Text inside a quote, newlines too, is data; the outermost quote marks stay so words keep their edges.
186 if (wasQuoted && isQuoted()) chars[i] = ' '
187 }
188 return { text: chars.join(''), comments }
189}
190
191const unquote = (raw: string) => (raw.replace(/\\\n/g, '').match(/(?:[^\s'"]+|'[^']*'|"(?:\\.|[^"\\])*")+/g) ?? []).map(word => word.replace(/'([^']*)'|"((?:\\.|[^"\\])*)"/g, '$1$2'))
192
193const commandWords = (raw: string) => {
194 const words = unquote(raw)
195 let i = 0
196 while (i < words.length) {
197 const word = words[i] ?? ''
198 if (/^\w+=/.test(word) || KEYWORDS.has(word)) i++
199 else if (WRAPPERS.has(word)) {
200 i++
201 while ((words[i] ?? '').startsWith('-')) i++
202 } else break
203 }
204 return words.slice(i)
205}
206
207// `}` closes a group only as its own word; `${VAR}` stays one word.
208const SEPARATOR = /\|\||&&|;|\||(?<![>&])&(?![>&])|\n|\$\(|\(|\)|`|(?<=^|[\s;])\}(?=[\s;]|$)/g
209
210// Every simple command in `command`, in order.
211export const simpleCommands = (command: string): Simple[] => {
212 const { text: masked, comments } = mask(command)
213 const found: (Simple & { sep: string })[] = []
214 const stack: string[] = []
215 let start = 0
216 const push = (end: number, sep: string) => {
217 const text = masked.slice(start, end)
218 if (text.trim()) {
219 found.push({
220 words: commandWords(command.slice(start, comments.find(at => at >= start && at < end) ?? end)),
221 isSubstituted: stack.includes('$(') || stack.includes('`'),
222 isRedirected: STDOUT_REDIRECT.test(text),
223 after: [],
224 sep,
225 })
226 }
227 }
228 for (const match of masked.matchAll(SEPARATOR)) {
229 const sep = match[0]
230 const at = match.index ?? 0
231 push(at, sep)
232 if (sep === '$(' || sep === '(') stack.push(sep)
233 else if (sep === ')') stack.pop()
234 else if (sep === '`') stack[stack.length - 1] === '`' ? stack.pop() : stack.push('`')
235 start = at + sep.length
236 }
237 push(masked.length, '')
238 for (let i = found.length - 1; i >= 0; i--) {
239 const stage = found[i]
240 const next = found[i + 1]
241 if (stage && next && stage.sep === '|') stage.after = [next, ...next.after]
242 }
243 return found
244}
245
246// The command name without its directory.
247export const base = (word: string | undefined) => (word ?? '').replace(/^.*\//, '')
248