anthropics/claude-cookbooks
Duplication Places in code with 6 or more lines that are exactly the same. |
Duplication Overall
- 21% duplication:
- 50,946 cleaned lines of cleaned code (without empty lines, comments, and frequently duplicated constructs such as imports)
- 10,749 duplicated lines
- 48,412 duplicates
Duplication per Extension
Duplication per Component (primary)
Duplication Between Components (50+ lines)
flowchart TB
n0["misc"]
n1["tool_use"]
n2["claude_agent_sdk"]
n3["managed_agents"]
n4["capabilities"]
n5["patterns"]
n6["coding"]
n7["finetuning"]
n8["extended_thinking"]
n9["fable_5_fallback_billing"]
n10["multimodal"]
n11["evals"]
n0 ---|"2234"| n1
n2 ---|"1960"| n3
n3 ---|"1840"| n0
n2 ---|"1747"| n0
n2 ---|"1637"| n1
n3 ---|"1606"| n1
n4 ---|"1506"| n2
n4 ---|"1216"| n1
n4 ---|"1168"| n0
n0 ---|"1120"| n5
n5 ---|"1015"| n1
n6 ---|"1005"| n0
n6 ---|"940"| n1
n4 ---|"718"| n3
n7 ---|"701"| n0
n7 ---|"696"| n1
n8 ---|"695"| n0
n3 ---|"659"| n5
n9 ---|"608"| n0
n9 ---|"528"| n1
n6 ---|"519"| n3
n8 ---|"501"| n1
n0 ---|"437"| n10
n4 ---|"431"| n5
n4 ---|"344"| n6
n4 ---|"319"| n7
n7 ---|"315"| n3
n6 ---|"313"| n5
n7 ---|"311"| n5
n8 ---|"291"| n3
n9 ---|"282"| n3
n2 ---|"249"| n5
n3 ---|"248"| n10
n6 ---|"220"| n7
n2 ---|"216"| n6
n10 ---|"203"| n1
n4 ---|"194"| n9
n9 ---|"173"| n5
n8 ---|"162"| n9
n2 ---|"148"| n10
n6 ---|"140"| n9
n4 ---|"132"| n8
n9 ---|"128"| n7
n8 ---|"108"| n5
n10 ---|"105"| n5
n11 ---|"105"| n3
n2 ---|"93"| n8
n11 ---|"84"| n0
n8 ---|"83"| n10
n9 ---|"80"| n10
classDef default fill:#00b2ee,stroke:#ffffff,color:#000000;
classDef highlighted fill:#00b2ee,stroke:#ffffff,color:#000000;
linkStyle 0 stroke:#DC143CFF,stroke-width:10px
linkStyle 1 stroke:#DC143CDB,stroke-width:8px
linkStyle 2 stroke:#DC143CDB,stroke-width:8px
linkStyle 3 stroke:#DC143CC9,stroke-width:7px
linkStyle 4 stroke:#DC143CC9,stroke-width:7px
linkStyle 5 stroke:#DC143CC9,stroke-width:7px
linkStyle 6 stroke:#DC143CB7,stroke-width:6px
linkStyle 7 stroke:#DC143CA5,stroke-width:5px
linkStyle 8 stroke:#DC143CA5,stroke-width:5px
linkStyle 9 stroke:#DC143CA5,stroke-width:5px
linkStyle 10 stroke:#DC143C93,stroke-width:4px
linkStyle 11 stroke:#DC143C93,stroke-width:4px
linkStyle 12 stroke:#DC143C93,stroke-width:4px
linkStyle 13 stroke:#DC143C82,stroke-width:3px
linkStyle 14 stroke:#DC143C82,stroke-width:3px
linkStyle 15 stroke:#DC143C82,stroke-width:3px
linkStyle 16 stroke:#DC143C82,stroke-width:3px
linkStyle 17 stroke:#DC143C70,stroke-width:2px
linkStyle 18 stroke:#DC143C70,stroke-width:2px
linkStyle 19 stroke:#DC143C70,stroke-width:2px
linkStyle 20 stroke:#DC143C70,stroke-width:2px
linkStyle 21 stroke:#DC143C70,stroke-width:2px
linkStyle 22 stroke:#DC143C5E,stroke-width:1px
linkStyle 23 stroke:#DC143C5E,stroke-width:1px
linkStyle 24 stroke:#DC143C5E,stroke-width:1px
linkStyle 25 stroke:#DC143C5E,stroke-width:1px
linkStyle 26 stroke:#DC143C5E,stroke-width:1px
linkStyle 27 stroke:#DC143C5E,stroke-width:1px
linkStyle 28 stroke:#DC143C5E,stroke-width:1px
linkStyle 29 stroke:#DC143C5E,stroke-width:1px
linkStyle 30 stroke:#DC143C5E,stroke-width:1px
linkStyle 31 stroke:#DC143C5E,stroke-width:1px
linkStyle 32 stroke:#DC143C5E,stroke-width:1px
linkStyle 33 stroke:#DC143C4C,stroke-width:1px
linkStyle 34 stroke:#DC143C4C,stroke-width:1px
linkStyle 35 stroke:#DC143C4C,stroke-width:1px
linkStyle 36 stroke:#DC143C4C,stroke-width:1px
linkStyle 37 stroke:#DC143C4C,stroke-width:1px
linkStyle 38 stroke:#DC143C4C,stroke-width:1px
linkStyle 39 stroke:#DC143C4C,stroke-width:1px
linkStyle 40 stroke:#DC143C4C,stroke-width:1px
linkStyle 41 stroke:#DC143C4C,stroke-width:1px
linkStyle 42 stroke:#DC143C4C,stroke-width:1px
linkStyle 43 stroke:#DC143C4C,stroke-width:1px
linkStyle 44 stroke:#DC143C4C,stroke-width:1px
linkStyle 45 stroke:#DC143C4C,stroke-width:1px
linkStyle 46 stroke:#DC143C4C,stroke-width:1px
linkStyle 47 stroke:#DC143C4C,stroke-width:1px
linkStyle 48 stroke:#DC143C4C,stroke-width:1px
linkStyle 49 stroke:#DC143C4C,stroke-width:1px
Download:
Mermaid (.mmd)
(open online Mermaid editor)
2D force graph
|
3D force graph
Show more details on duplication between components...
From Component
--> To Component
Duplicated
Lines
File Pairs
Details
misc (14%)
  --> tool_use (13%)
2234
84 file pairs
details...
claude_agent_sdk (9%)
  --> managed_agents (10%)
1960
37 file pairs
details...
managed_agents (9%)
  --> misc (12%)
1840
110 file pairs
details...
claude_agent_sdk (8%)
  --> misc (11%)
1747
47 file pairs
details...
claude_agent_sdk (8%)
  --> tool_use (9%)
1637
27 file pairs
details...
managed_agents (8%)
  --> tool_use (9%)
1606
62 file pairs
details...
capabilities (20%)
  --> claude_agent_sdk (7%)
1506
4 file pairs
details...
capabilities (16%)
  --> tool_use (7%)
1216
7 file pairs
details...
capabilities (15%)
  --> misc (7%)
1168
12 file pairs
details...
misc (7%)
  --> patterns (17%)
1120
59 file pairs
details...
patterns (16%)
  --> tool_use (6%)
1015
34 file pairs
details...
coding (42%)
  --> misc (6%)
1005
12 file pairs
details...
coding (40%)
  --> tool_use (5%)
940
7 file pairs
details...
capabilities (9%)
  --> managed_agents (3%)
718
10 file pairs
details...
finetuning (135%)
  --> misc (4%)
701
12 file pairs
details...
finetuning (134%)
  --> tool_use (4%)
696
7 file pairs
details...
extended_thinking (40%)
  --> misc (4%)
695
11 file pairs
details...
managed_agents (3%)
  --> patterns (10%)
659
46 file pairs
details...
fable_5_fallback_billing (53%)
  --> misc (4%)
608
12 file pairs
details...
fable_5_fallback_billing (46%)
  --> tool_use (3%)
528
7 file pairs
details...
coding (22%)
  --> managed_agents (2%)
519
8 file pairs
details...
extended_thinking (29%)
  --> tool_use (2%)
501
6 file pairs
details...
misc (2%)
  --> multimodal (43%)
437
12 file pairs
details...
capabilities (5%)
  --> patterns (6%)
431
5 file pairs
details...
capabilities (4%)
  --> coding (14%)
344
1 file pair
details...
capabilities (4%)
  --> finetuning (61%)
319
1 file pair
details...
finetuning (61%)
  --> managed_agents (1%)
315
10 file pairs
details...
coding (13%)
  --> patterns (4%)
313
5 file pairs
details...
finetuning (60%)
  --> patterns (4%)
311
5 file pairs
details...
extended_thinking (16%)
  --> managed_agents (1%)
291
6 file pairs
details...
fable_5_fallback_billing (25%)
  --> managed_agents (1%)
282
6 file pairs
details...
claude_agent_sdk (1%)
  --> patterns (3%)
249
19 file pairs
details...
managed_agents (1%)
  --> multimodal (24%)
248
12 file pairs
details...
coding (9%)
  --> finetuning (42%)
220
1 file pair
details...
claude_agent_sdk (1%)
  --> coding (9%)
216
4 file pairs
details...
multimodal (19%)
  --> tool_use (1%)
203
7 file pairs
details...
capabilities (2%)
  --> fable_5_fallback_billing (17%)
194
1 file pair
details...
fable_5_fallback_billing (15%)
  --> patterns (2%)
173
4 file pairs
details...
extended_thinking (9%)
  --> fable_5_fallback_billing (14%)
162
1 file pair
details...
claude_agent_sdk (<1%)
  --> multimodal (14%)
148
4 file pairs
details...
coding (5%)
  --> fable_5_fallback_billing (12%)
140
1 file pair
details...
capabilities (1%)
  --> extended_thinking (7%)
132
1 file pair
details...
fable_5_fallback_billing (11%)
  --> finetuning (24%)
128
1 file pair
details...
extended_thinking (6%)
  --> patterns (1%)
108
3 file pairs
details...
multimodal (10%)
  --> patterns (1%)
105
5 file pairs
details...
evals (5%)
  --> managed_agents (<1%)
105
9 file pairs
details...
claude_agent_sdk (<1%)
  --> extended_thinking (5%)
93
2 file pairs
details...
evals (4%)
  --> misc (<1%)
84
8 file pairs
details...
extended_thinking (4%)
  --> multimodal (8%)
83
1 file pair
details...
fable_5_fallback_billing (7%)
  --> multimodal (7%)
80
1 file pair
details...
coding (3%)
  --> extended_thinking (4%)
78
1 file pair
details...
claude_agent_sdk (<1%)
  --> finetuning (14%)
74
4 file pairs
details...
extended_thinking (3%)
  --> finetuning (12%)
66
1 file pair
details...
evals (3%)
  --> patterns (1%)
65
5 file pairs
details...
evals (3%)
  --> tool_use (<1%)
63
6 file pairs
details...
claude_agent_sdk (<1%)
  --> fable_5_fallback_billing (4%)
52
3 file pairs
details...
flowchart TB
n0["misc"]
n1["tool_use"]
n2["claude_agent_sdk"]
n3["managed_agents"]
n4["capabilities"]
n5["patterns"]
n6["coding"]
n7["finetuning"]
n8["extended_thinking"]
n9["fable_5_fallback_billing"]
n10["multimodal"]
n11["evals"]
n0 ---|"2234"| n1
n2 ---|"1960"| n3
n3 ---|"1840"| n0
n2 ---|"1747"| n0
n2 ---|"1637"| n1
n3 ---|"1606"| n1
n4 ---|"1506"| n2
n4 ---|"1216"| n1
n4 ---|"1168"| n0
n0 ---|"1120"| n5
n5 ---|"1015"| n1
n6 ---|"1005"| n0
n6 ---|"940"| n1
n4 ---|"718"| n3
n7 ---|"701"| n0
n7 ---|"696"| n1
n8 ---|"695"| n0
n3 ---|"659"| n5
n9 ---|"608"| n0
n9 ---|"528"| n1
n6 ---|"519"| n3
n8 ---|"501"| n1
n0 ---|"437"| n10
n4 ---|"431"| n5
n4 ---|"344"| n6
n4 ---|"319"| n7
n7 ---|"315"| n3
n6 ---|"313"| n5
n7 ---|"311"| n5
n8 ---|"291"| n3
n9 ---|"282"| n3
n2 ---|"249"| n5
n3 ---|"248"| n10
n6 ---|"220"| n7
n2 ---|"216"| n6
n10 ---|"203"| n1
n4 ---|"194"| n9
n9 ---|"173"| n5
n8 ---|"162"| n9
n2 ---|"148"| n10
n6 ---|"140"| n9
n4 ---|"132"| n8
n9 ---|"128"| n7
n8 ---|"108"| n5
n10 ---|"105"| n5
n11 ---|"105"| n3
n2 ---|"93"| n8
n11 ---|"84"| n0
n8 ---|"83"| n10
n9 ---|"80"| n10
classDef default fill:#00b2ee,stroke:#ffffff,color:#000000;
classDef highlighted fill:#00b2ee,stroke:#ffffff,color:#000000;
linkStyle 0 stroke:#DC143CFF,stroke-width:10px
linkStyle 1 stroke:#DC143CDB,stroke-width:8px
linkStyle 2 stroke:#DC143CDB,stroke-width:8px
linkStyle 3 stroke:#DC143CC9,stroke-width:7px
linkStyle 4 stroke:#DC143CC9,stroke-width:7px
linkStyle 5 stroke:#DC143CC9,stroke-width:7px
linkStyle 6 stroke:#DC143CB7,stroke-width:6px
linkStyle 7 stroke:#DC143CA5,stroke-width:5px
linkStyle 8 stroke:#DC143CA5,stroke-width:5px
linkStyle 9 stroke:#DC143CA5,stroke-width:5px
linkStyle 10 stroke:#DC143C93,stroke-width:4px
linkStyle 11 stroke:#DC143C93,stroke-width:4px
linkStyle 12 stroke:#DC143C93,stroke-width:4px
linkStyle 13 stroke:#DC143C82,stroke-width:3px
linkStyle 14 stroke:#DC143C82,stroke-width:3px
linkStyle 15 stroke:#DC143C82,stroke-width:3px
linkStyle 16 stroke:#DC143C82,stroke-width:3px
linkStyle 17 stroke:#DC143C70,stroke-width:2px
linkStyle 18 stroke:#DC143C70,stroke-width:2px
linkStyle 19 stroke:#DC143C70,stroke-width:2px
linkStyle 20 stroke:#DC143C70,stroke-width:2px
linkStyle 21 stroke:#DC143C70,stroke-width:2px
linkStyle 22 stroke:#DC143C5E,stroke-width:1px
linkStyle 23 stroke:#DC143C5E,stroke-width:1px
linkStyle 24 stroke:#DC143C5E,stroke-width:1px
linkStyle 25 stroke:#DC143C5E,stroke-width:1px
linkStyle 26 stroke:#DC143C5E,stroke-width:1px
linkStyle 27 stroke:#DC143C5E,stroke-width:1px
linkStyle 28 stroke:#DC143C5E,stroke-width:1px
linkStyle 29 stroke:#DC143C5E,stroke-width:1px
linkStyle 30 stroke:#DC143C5E,stroke-width:1px
linkStyle 31 stroke:#DC143C5E,stroke-width:1px
linkStyle 32 stroke:#DC143C5E,stroke-width:1px
linkStyle 33 stroke:#DC143C4C,stroke-width:1px
linkStyle 34 stroke:#DC143C4C,stroke-width:1px
linkStyle 35 stroke:#DC143C4C,stroke-width:1px
linkStyle 36 stroke:#DC143C4C,stroke-width:1px
linkStyle 37 stroke:#DC143C4C,stroke-width:1px
linkStyle 38 stroke:#DC143C4C,stroke-width:1px
linkStyle 39 stroke:#DC143C4C,stroke-width:1px
linkStyle 40 stroke:#DC143C4C,stroke-width:1px
linkStyle 41 stroke:#DC143C4C,stroke-width:1px
linkStyle 42 stroke:#DC143C4C,stroke-width:1px
linkStyle 43 stroke:#DC143C4C,stroke-width:1px
linkStyle 44 stroke:#DC143C4C,stroke-width:1px
linkStyle 45 stroke:#DC143C4C,stroke-width:1px
linkStyle 46 stroke:#DC143C4C,stroke-width:1px
linkStyle 47 stroke:#DC143C4C,stroke-width:1px
linkStyle 48 stroke:#DC143C4C,stroke-width:1px
linkStyle 49 stroke:#DC143C4C,stroke-width:1px
Show more details on duplication between components...
| From Component --> To Component |
Duplicated Lines |
File Pairs | Details |
|---|---|---|---|
| misc (14%)   --> tool_use (13%) |
2234 | 84 file pairs | details... |
| claude_agent_sdk (9%)   --> managed_agents (10%) |
1960 | 37 file pairs | details... |
| managed_agents (9%)   --> misc (12%) |
1840 | 110 file pairs | details... |
| claude_agent_sdk (8%)   --> misc (11%) |
1747 | 47 file pairs | details... |
| claude_agent_sdk (8%)   --> tool_use (9%) |
1637 | 27 file pairs | details... |
| managed_agents (8%)   --> tool_use (9%) |
1606 | 62 file pairs | details... |
| capabilities (20%)   --> claude_agent_sdk (7%) |
1506 | 4 file pairs | details... |
| capabilities (16%)   --> tool_use (7%) |
1216 | 7 file pairs | details... |
| capabilities (15%)   --> misc (7%) |
1168 | 12 file pairs | details... |
| misc (7%)   --> patterns (17%) |
1120 | 59 file pairs | details... |
| patterns (16%)   --> tool_use (6%) |
1015 | 34 file pairs | details... |
| coding (42%)   --> misc (6%) |
1005 | 12 file pairs | details... |
| coding (40%)   --> tool_use (5%) |
940 | 7 file pairs | details... |
| capabilities (9%)   --> managed_agents (3%) |
718 | 10 file pairs | details... |
| finetuning (135%)   --> misc (4%) |
701 | 12 file pairs | details... |
| finetuning (134%)   --> tool_use (4%) |
696 | 7 file pairs | details... |
| extended_thinking (40%)   --> misc (4%) |
695 | 11 file pairs | details... |
| managed_agents (3%)   --> patterns (10%) |
659 | 46 file pairs | details... |
| fable_5_fallback_billing (53%)   --> misc (4%) |
608 | 12 file pairs | details... |
| fable_5_fallback_billing (46%)   --> tool_use (3%) |
528 | 7 file pairs | details... |
| coding (22%)   --> managed_agents (2%) |
519 | 8 file pairs | details... |
| extended_thinking (29%)   --> tool_use (2%) |
501 | 6 file pairs | details... |
| misc (2%)   --> multimodal (43%) |
437 | 12 file pairs | details... |
| capabilities (5%)   --> patterns (6%) |
431 | 5 file pairs | details... |
| capabilities (4%)   --> coding (14%) |
344 | 1 file pair | details... |
| capabilities (4%)   --> finetuning (61%) |
319 | 1 file pair | details... |
| finetuning (61%)   --> managed_agents (1%) |
315 | 10 file pairs | details... |
| coding (13%)   --> patterns (4%) |
313 | 5 file pairs | details... |
| finetuning (60%)   --> patterns (4%) |
311 | 5 file pairs | details... |
| extended_thinking (16%)   --> managed_agents (1%) |
291 | 6 file pairs | details... |
| fable_5_fallback_billing (25%)   --> managed_agents (1%) |
282 | 6 file pairs | details... |
| claude_agent_sdk (1%)   --> patterns (3%) |
249 | 19 file pairs | details... |
| managed_agents (1%)   --> multimodal (24%) |
248 | 12 file pairs | details... |
| coding (9%)   --> finetuning (42%) |
220 | 1 file pair | details... |
| claude_agent_sdk (1%)   --> coding (9%) |
216 | 4 file pairs | details... |
| multimodal (19%)   --> tool_use (1%) |
203 | 7 file pairs | details... |
| capabilities (2%)   --> fable_5_fallback_billing (17%) |
194 | 1 file pair | details... |
| fable_5_fallback_billing (15%)   --> patterns (2%) |
173 | 4 file pairs | details... |
| extended_thinking (9%)   --> fable_5_fallback_billing (14%) |
162 | 1 file pair | details... |
| claude_agent_sdk (<1%)   --> multimodal (14%) |
148 | 4 file pairs | details... |
| coding (5%)   --> fable_5_fallback_billing (12%) |
140 | 1 file pair | details... |
| capabilities (1%)   --> extended_thinking (7%) |
132 | 1 file pair | details... |
| fable_5_fallback_billing (11%)   --> finetuning (24%) |
128 | 1 file pair | details... |
| extended_thinking (6%)   --> patterns (1%) |
108 | 3 file pairs | details... |
| multimodal (10%)   --> patterns (1%) |
105 | 5 file pairs | details... |
| evals (5%)   --> managed_agents (<1%) |
105 | 9 file pairs | details... |
| claude_agent_sdk (<1%)   --> extended_thinking (5%) |
93 | 2 file pairs | details... |
| evals (4%)   --> misc (<1%) |
84 | 8 file pairs | details... |
| extended_thinking (4%)   --> multimodal (8%) |
83 | 1 file pair | details... |
| fable_5_fallback_billing (7%)   --> multimodal (7%) |
80 | 1 file pair | details... |
| coding (3%)   --> extended_thinking (4%) |
78 | 1 file pair | details... |
| claude_agent_sdk (<1%)   --> finetuning (14%) |
74 | 4 file pairs | details... |
| extended_thinking (3%)   --> finetuning (12%) |
66 | 1 file pair | details... |
| evals (3%)   --> patterns (1%) |
65 | 5 file pairs | details... |
| evals (3%)   --> tool_use (<1%) |
63 | 6 file pairs | details... |
| claude_agent_sdk (<1%)   --> fable_5_fallback_billing (4%) |
52 | 3 file pairs | details... |
Longest Duplicates
The list of 50 longest duplicates.
Most Frequent Duplicates
The list of 50 most frequently found duplicates.
Duplicated Units
The list of top 1 duplicated units.
About This Analysis
- For duplication, we look at places in code where there are 6 or more lines of code that are exactly the same.
- Before duplication is calculated, the code is cleaned to remove empty lines, comments, and frequently duplicated constructs such as imports.
- You should aim at having as little as possible (<5%) of duplicated code as high-level of duplication can lead to maintenance difficulties, poor factoring, and logical contradictions.
Learn more...
- To learn more about duplications and techniques for eliminating duplication, Sokrates recommends the following resources:
- Avoid Repetition, MartinFlower.com (IEEE Software article)
- Refactoring duplicated code, sourcemaking.com
- Beck Design Rules, MartinFowler.com
- DRY (Don't Repeat Yourself) Principle, Wikipedia
- The Cut-and-Paste Programming Software Development Anti-Pattern, sourcemaking.com
- Code Smells / Duplicated Code, Jeff Atwood, codinghorror.com:
- "Duplicated code is the bane of software development. Stamp out duplication whenever possible. You should always be on the lookout for more subtle cases of near-duplication, too. Don't Repeat Yourself!"
- Reducing Coupling, MartinFlower.com (IEEE Software article):
- "There are several ways to describe coupling, but it boils down to this: If changing one module in a program requires changing another module, then coupling exists. ... Duplication always implies coupling, because changing one piece of duplicate code implies changing the other."