Skip to content

Commit d76b972

Browse files
committed
docs(ip-audit): record cross-repo similarity audit and repeat recipe
Ran jscpd (token-level clone detector) cross-comparing src/ against the Claude Code leaked source at ~/claude-code-source/src. Zero cross-repo clones at default sensitivity (min-lines 5, min-tokens 30) and at strict mode (min-lines 3, min-tokens 20). Also grepped for 14 distinctive CC phrases — zero hits. Documented the method, the result, and the recipe for re-running so future contributors can verify before adding code that touches surfaces where CC has a counterpart.
1 parent f3218b9 commit d76b972

2 files changed

Lines changed: 143 additions & 0 deletions

File tree

.settings/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and you'll know enough to ship code:
88
2. **[architecture.md](architecture.md)** — what's actually in `src/`
99
3. **[extending.md](extending.md)** — adding a tool, slash command, or provider
1010
4. **[testing.md](testing.md)** — how to write tests that catch real bugs
11+
5. **[ip-audit.md](ip-audit.md)** — how we verify independence from Claude Code's leaked source
1112

1213
If you only have 5 minutes, read `tenets.md`.
1314

.settings/ip-audit.md

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# IP audit — independence from Claude Code source
2+
3+
This is a record of the cross-repo similarity audit we ran to confirm
4+
codebase-cli contains no copy-paste from the leaked Claude Code source.
5+
Repeat the audit any time you're considering using CC's source as
6+
architectural reference for a new feature.
7+
8+
## Method
9+
10+
Three layers, smallest noise → largest:
11+
12+
1. **Token-level clone detection** with `jscpd` (open-source, MIT). Catches
13+
exact copies, near-copies (whitespace/identifier changes), and
14+
re-indented copies. Doesn't catch high-level algorithmic similarity —
15+
that's intentional, because the same algorithm written independently
16+
isn't infringement.
17+
18+
2. **Distinctive-phrase grep**. Hand-picked sentences from CC's source
19+
that would only appear if we copied them verbatim — prompt openings,
20+
characteristic comments, structural markers.
21+
22+
3. **Manual review of high-overlap surfaces**. The places where copy is
23+
most tempting: system prompts, tool descriptions, slash-command help
24+
text, error messages.
25+
26+
## Last run
27+
28+
**Date:** 2026-05-13
29+
**CC source path:** `~/claude-code-source/src` (leaked source repo)
30+
**Our path:** `src/`
31+
32+
### Layer 1 — `jscpd`
33+
34+
```
35+
npx jscpd@4.0.5 us cc --min-lines 5 --min-tokens 30 \
36+
--format "javascript,typescript,jsx,tsx" \
37+
--reporters json --output ./report
38+
```
39+
40+
Then filter the JSON to clones where one side lives in `us/` and the other
41+
in `cc/` (the default report mixes intra- and inter-repo clones).
42+
43+
**Result:** **0 cross-repo clones** at default sensitivity.
44+
45+
Re-ran tighter:
46+
47+
```
48+
--min-lines 3 --min-tokens 20 --mode strict
49+
```
50+
51+
**Result:** **0 cross-repo clones** at strict mode with looser thresholds.
52+
53+
### Layer 2 — distinctive-phrase grep
54+
55+
Phrases checked (each chosen from CC's source as something only their
56+
codebase would contain):
57+
58+
- `Anthropic's official CLI`
59+
- `demonstrate thoroughness`
60+
- `gold-plate`
61+
- `Mark it as in_progress BEFORE beginning work`
62+
- `Mark it as completed and add any new follow-up tasks`
63+
- `track progress, organize complex tasks`
64+
- `Use this tool proactively`
65+
- `If completed, you should not mark`
66+
- `ONLY mark a task as completed when you have`
67+
- `file search specialist`
68+
- `verification specialist`
69+
- `elite AI agent architect`
70+
- `forked worker process`
71+
- `Claude guide agent`
72+
73+
**Result:** 0 hits across all phrases.
74+
75+
### Layer 3 — manual review
76+
77+
| Surface | CC location | Our location | Outcome |
78+
|---|---|---|---|
79+
| Main system prompt | `src/context.ts` (`getSystemPrompt`) | `src/agent/system-prompt.ts` (`buildSystemPrompt`) | Opens differently ("You are codebase, a CLI coding agent" vs "You are Claude Code, Anthropic's official CLI for Claude"). Task-checklist section *covers the same behavioral concept* as CC's TodoWriteTool prompt (one-in-progress, complete-immediately), but the actual wording is paraphrased. Concept is a generic task-management pattern, not protectable. |
80+
| Prompt suggestion | `src/commands/AutoCompleteCommand` (CC's variant) | `src/agent/prompt-suggestion.ts` | Explicitly noted in our source code: "Claude Code uses a similar idea with different words; we're not copying that text." |
81+
| Tool descriptions | `src/tools/*/prompt.ts` | inline in `src/tools/*.ts` | Different structure (CC uses bullet lists, we use headings + bullets) and different wording. Sampled GlobTool: CC says "Fast file pattern matching tool that works with any codebase size" — we say "Find files matching a glob pattern." |
82+
| Paste placeholder format | `src/history.ts` (`formatPastedTextRef`) | `src/ui/input-state.ts` (`formatPastePlaceholder`) | CC: `[Pasted text #1 +10 lines]`. Ours: `[Pasted #1 · 3 lines]`. Different function name, different file, different format. |
83+
84+
## Concepts we adopted
85+
86+
These are *patterns* — not protectable. We re-implemented each from scratch
87+
with independent wording / structure:
88+
89+
- Slash-command system with typo suggestions
90+
- Collapsed-read groups for tool-call rendering
91+
- Paste placeholders (substitute long content with a side-mapped reference)
92+
- OSC 8 hyperlinks for file paths
93+
- OSC 9;4 terminal progress notifications
94+
- Tool-call status spinners
95+
- `!cmd` shell escape
96+
- `@path` file attachments
97+
- Multi-line input via `\<Enter>`
98+
- Plan mode as a pre-execution Q&A gate
99+
- One spinner-state-per-action UI
100+
101+
## Things to NOT do going forward
102+
103+
- Don't read CC's source for *new* feature inspiration. We've already
104+
taken what's useful as a benchmark; further reading creates fresh
105+
derivation risk for new code.
106+
- If a CC feature is genuinely better than what we'd design independently,
107+
describe it from memory / behavior — not from re-reading the source.
108+
- Treat their source as evidence-of-prior-art only ("yes, this UX exists
109+
and was shipped publicly"), not as an implementation template.
110+
111+
## Repeating this audit
112+
113+
```sh
114+
# 1. Token-level clones
115+
mkdir -p /tmp/ipcheck
116+
cp -r src /tmp/ipcheck/us
117+
cp -r ~/claude-code-source/src /tmp/ipcheck/cc
118+
cd /tmp/ipcheck && npx jscpd@4.0.5 us cc \
119+
--min-lines 5 --min-tokens 30 \
120+
--format "javascript,typescript,jsx,tsx" \
121+
--reporters json --output ./report --silent
122+
123+
# 2. Filter to cross-repo only
124+
node -e "
125+
const r = require('./report/jscpd-report.json');
126+
const cross = r.duplicates.filter(d =>
127+
(d.firstFile.name.includes('/us/') && d.secondFile.name.includes('/cc/')) ||
128+
(d.firstFile.name.includes('/cc/') && d.secondFile.name.includes('/us/'))
129+
);
130+
console.log('Cross-repo clones:', cross.length);
131+
"
132+
133+
# 3. Phrase scan (in repo root)
134+
for p in "Anthropic's official CLI" "demonstrate thoroughness" "gold-plate" \
135+
"Use this tool proactively" "file search specialist" \
136+
"elite AI agent architect"; do
137+
grep -rc "$p" src/ 2>/dev/null | grep -v ':0$' || echo "0 hits | $p"
138+
done
139+
```
140+
141+
If the audit ever reports cross-repo clones, treat that as a real finding —
142+
read the matched ranges and rewrite our side with independent wording.

0 commit comments

Comments
 (0)