1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
#!/usr/bin/env bats
#
# Tests for scripts/install-lang.sh — install a language ruleset into a project.
#
# Strategy: scaffold a fresh git project in a temp dir, run install-lang.sh
# against it. Canonical source stays the real one (install-lang.sh resolves
# languages/ and claude-rules/ relative to its own location).
REAL_REPO="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
INSTALL_LANG="$REAL_REPO/scripts/install-lang.sh"
setup() {
PROJECT="$(mktemp -d -t install-lang-bats.XXXXXX)"
(cd "$PROJECT" && git init -q)
}
teardown() {
rm -rf "$PROJECT"
}
@test "install-lang elisp: lands the tooling footprint" {
run bash "$INSTALL_LANG" elisp "$PROJECT"
[ "$status" -eq 0 ]
[ -d "$PROJECT/.claude/rules" ]
[ -d "$PROJECT/githooks" ]
[ -f "$PROJECT/CLAUDE.md" ]
# The coverage-summary script ships inside the gitignored .claude footprint.
[ -f "$PROJECT/.claude/scripts/coverage-summary.el" ]
}
@test "install-lang elisp: seeds the project-owned coverage Makefile fragment" {
run bash "$INSTALL_LANG" elisp "$PROJECT"
[ "$status" -eq 0 ]
[ -f "$PROJECT/coverage-makefile.txt" ]
}
@test "install-lang elisp: does not overwrite an existing fragment without FORCE" {
echo "MY OWN VERSION" > "$PROJECT/coverage-makefile.txt"
run bash "$INSTALL_LANG" elisp "$PROJECT"
[ "$status" -eq 0 ]
grep -qxF "MY OWN VERSION" "$PROJECT/coverage-makefile.txt"
}
@test "install-lang elisp: gitignores the full Claude tooling footprint" {
run bash "$INSTALL_LANG" elisp "$PROJECT"
[ "$status" -eq 0 ]
# The whole .claude/, CLAUDE.md, and githooks/ stay out of the project's
# git history — Claude tooling is delivered by install/sync, never committed.
grep -qxF ".claude/" "$PROJECT/.gitignore"
grep -qxF "CLAUDE.md" "$PROJECT/.gitignore"
grep -qxF "githooks/" "$PROJECT/.gitignore"
# Elisp byte-compile artifacts.
grep -qxF "*.elc" "$PROJECT/.gitignore"
grep -qxF "*.eln" "$PROJECT/.gitignore"
}
@test "install-lang python: lands the coverage script in the gitignored footprint" {
run bash "$INSTALL_LANG" python "$PROJECT"
[ "$status" -eq 0 ]
[ -f "$PROJECT/.claude/scripts/coverage-summary.py" ]
[ -f "$PROJECT/coverage-makefile.txt" ]
# The .claude footprint must be gitignored so the script isn't committed.
grep -qxF ".claude/" "$PROJECT/.gitignore"
grep -qxF "coverage.json" "$PROJECT/.gitignore"
}
@test "install-lang typescript: lands the coverage script in the gitignored footprint" {
run bash "$INSTALL_LANG" typescript "$PROJECT"
[ "$status" -eq 0 ]
[ -f "$PROJECT/.claude/scripts/coverage-summary.js" ]
[ -f "$PROJECT/coverage-makefile.txt" ]
grep -qxF ".claude/" "$PROJECT/.gitignore"
grep -qxF "coverage/" "$PROJECT/.gitignore"
}
@test "install-lang: seeds the language-neutral default CLAUDE.md when the bundle ships none" {
# Every shipping bundle now carries its own CLAUDE.md (python and typescript
# gained theirs 2026-07-23), so the fallback needs a synthetic bundle to
# exercise. Keep testing it: the fallback is what stops a bundle added later,
# before its CLAUDE.md is written, from inheriting another language's header.
fake="$REAL_REPO/languages/zz-test-noclaude"
mkdir -p "$fake/claude/rules"
printf '# rule\n' > "$fake/claude/rules/zz.md"
run bash "$INSTALL_LANG" zz-test-noclaude "$PROJECT"
rm -rf "$fake"
[ "$status" -eq 0 ]
[ -f "$PROJECT/CLAUDE.md" ]
# The default names no language, so it can't mislabel a project the way
# inheriting elisp's "Elisp project" header did.
! grep -qi "Elisp project" "$PROJECT/CLAUDE.md"
grep -qF "names no language" "$PROJECT/CLAUDE.md"
[[ "$output" == *"language-neutral default"* ]]
}
@test "install-lang python: seeds the bundle's own CLAUDE.md, not the default" {
run bash "$INSTALL_LANG" python "$PROJECT"
[ "$status" -eq 0 ]
grep -qF "Python project." "$PROJECT/CLAUDE.md"
[[ "$output" == *"CLAUDE.md installed (python)"* ]]
}
@test "install-lang typescript: seeds the bundle's own CLAUDE.md, not the default" {
run bash "$INSTALL_LANG" typescript "$PROJECT"
[ "$status" -eq 0 ]
grep -qF "TypeScript/JavaScript project." "$PROJECT/CLAUDE.md"
[[ "$output" == *"CLAUDE.md installed (typescript)"* ]]
}
@test "install-lang elisp: seeds the bundle's own CLAUDE.md, not the default" {
run bash "$INSTALL_LANG" elisp "$PROJECT"
[ "$status" -eq 0 ]
grep -qF "Elisp project." "$PROJECT/CLAUDE.md"
[[ "$output" == *"CLAUDE.md installed (elisp)"* ]]
}
@test "install-lang python: does not overwrite an existing CLAUDE.md without FORCE" {
echo "MY OWN CLAUDE" > "$PROJECT/CLAUDE.md"
run bash "$INSTALL_LANG" python "$PROJECT"
[ "$status" -eq 0 ]
grep -qxF "MY OWN CLAUDE" "$PROJECT/CLAUDE.md"
}
@test "install-lang bash: full bundle lands (rules, hook, settings, githook, CLAUDE.md)" {
run bash "$INSTALL_LANG" bash "$PROJECT"
[ "$status" -eq 0 ]
# Language + testing rules — the bundle's sync fingerprint
[ -f "$PROJECT/.claude/rules/bash.md" ]
[ -f "$PROJECT/.claude/rules/bash-testing.md" ]
# PostToolUse validate hook, executable and wired into settings
[ -x "$PROJECT/.claude/hooks/validate-bash.sh" ]
grep -qF "validate-bash.sh" "$PROJECT/.claude/settings.json"
# Pre-commit githook
[ -x "$PROJECT/githooks/pre-commit" ]
# The bundle ships its own CLAUDE.md, so it wins over the neutral default
grep -qF "Bash/shell project" "$PROJECT/CLAUDE.md"
# Gitignore footprint
grep -qxF ".claude/" "$PROJECT/.gitignore"
}
@test "install-lang go: full bundle lands (rules, hook, settings, githook, CLAUDE.md, coverage)" {
run bash "$INSTALL_LANG" go "$PROJECT"
[ "$status" -eq 0 ]
# Coverage slice
[ -f "$PROJECT/.claude/scripts/coverage-summary.go" ]
[ -f "$PROJECT/coverage-makefile.txt" ]
# Language + testing rules — these are the bundle's sync fingerprint
[ -f "$PROJECT/.claude/rules/go.md" ]
[ -f "$PROJECT/.claude/rules/go-testing.md" ]
# PostToolUse validate hook, executable and wired into settings
[ -x "$PROJECT/.claude/hooks/validate-go.sh" ]
grep -qF "validate-go.sh" "$PROJECT/.claude/settings.json"
# Pre-commit githook
[ -x "$PROJECT/githooks/pre-commit" ]
# CLAUDE.md seeded
[ -f "$PROJECT/CLAUDE.md" ]
# Gitignore footprint
grep -qxF ".claude/" "$PROJECT/.gitignore"
grep -qxF "cover.out" "$PROJECT/.gitignore"
}
@test "install-lang python: full bundle lands (rules, hook, settings, githook, CLAUDE.md, coverage)" {
run bash "$INSTALL_LANG" python "$PROJECT"
[ "$status" -eq 0 ]
[ -f "$PROJECT/.claude/rules/python-testing.md" ]
# PostToolUse validate hook, executable and wired into settings
[ -x "$PROJECT/.claude/hooks/validate-python.sh" ]
grep -qF "validate-python.sh" "$PROJECT/.claude/settings.json"
# Pre-commit githook — the secret scan. Absent until 2026-07-23.
[ -x "$PROJECT/githooks/pre-commit" ]
grep -qF "potential secret" "$PROJECT/githooks/pre-commit"
# Coverage slice
[ -f "$PROJECT/.claude/scripts/coverage-summary.py" ]
grep -qxF ".claude/" "$PROJECT/.gitignore"
}
@test "install-lang typescript: full bundle lands (rules, hook, settings, githook, CLAUDE.md, coverage)" {
run bash "$INSTALL_LANG" typescript "$PROJECT"
[ "$status" -eq 0 ]
[ -f "$PROJECT/.claude/rules/typescript-testing.md" ]
[ -x "$PROJECT/.claude/hooks/validate-typescript.sh" ]
grep -qF "validate-typescript.sh" "$PROJECT/.claude/settings.json"
[ -x "$PROJECT/githooks/pre-commit" ]
grep -qF "potential secret" "$PROJECT/githooks/pre-commit"
[ -f "$PROJECT/.claude/scripts/coverage-summary.js" ]
grep -qxF ".claude/" "$PROJECT/.gitignore"
}
|