carrick-reuse
The task skill that compares the functions a task added against the whole function index, and groups the places a project has built the same thing twice.
carrick-reuse identifies existing functions across your project that already implement the behaviour you are writing. It searches against semantic function descriptions rather than function names, discovering utilities implemented under different identifiers in other services.
Invocation triggers
Agents execute carrick-reuse in the following scenarios:
- Automatically at the end of a task when new functions have been declared
- When you ask whether an implementation already exists in the project
- When you ask whether a proposed function duplicates code in other repositories
- When conducting an audit to identify duplicate implementations across services
Operational modes and tool sequence
- Targeted mode:
find_similar(functions: [...])evaluates specific functions added or modified during a task. Entries specify anameandfilefor indexed functions, or adescriptionfor new code. - Audit mode:
find_similar()(with nofunctionsarray) clusters similar functions across the entire project. Paginating withoffsetcontinues through clusters untilhas_moreis false.
Comparisons evaluate intent vectors:
intent: Semantic vector derived purely from the function description.name_anchored: Vector incorporating the function name alongside the description.
Classification rules
The skill evaluates candidate matches in source code and assigns one of three mutually exclusive classifications:
FALSE POSITIVE: The contracts differ. The functions accept different inputs, return different shapes, or perform different side effects.VARIANT: The functions share a contract but differ in a specific behavioural detail (such as input normalisation, error handling, or default values).DUPLICATE: The functions share identical contracts and runtime behaviour.
Reports include total cluster counts, compared function counts, and lists of excluded files (such as test files or generated code).
Coverage boundaries
- Body hashes: Carrick compares semantic intent descriptions rather than raw AST hashes. You must inspect both source spans to confirm exact functional equivalence.
- Intra-file duplication: The skill excludes duplicates within the same file, focusing exclusively on cross-file and cross-service redundancy.
- Transitive cluster drift: In audit mode, clusters are formed transitively (A matches B, and B matches C). Large clusters may contain members that diverge from the initial function, which the skill classifies individually.
Example: targeted function check
Querying find_similar for a hashing utility:
{
"mode": "targeted",
"vector_basis": "intent",
"results": [
{
"input": "sha256Hex (functions/shared/verify_api_key.js:118)",
"kind": "indexed",
"similarity_threshold": 0.85,
"matches": [
{
"repo": "acme-platform",
"services": ["acme-gateway"],
"name": "sha256Hex",
"file_path": "functions/gateway/src/utils/request-log.ts",
"line_number": 30,
"end_line": 32,
"exported": true,
"signature": "(value: string) => string",
"intent": "Generates a SHA-256 cryptographic hash of a given string and returns the result as a hexadecimal string.",
"matched_on": "similarity"
}
]
}
]
}
The skill generates the following findings row:
| class | member | file:line | against | why |
|---|---|---|---|---|
| DUPLICATE | sha256Hex | functions/gateway/src/utils/request-log.ts:30 | functions/shared/verify_api_key.js:118 | one contract, one line, same hex digest |
Example: project-wide audit
Executing find_similar() in audit mode:
{
"mode": "audit",
"vector_basis": "intent",
"clusters_note": "clusters lists groups 1-3 of 55, ordered by how exactly the members match (exact, then near_exact, then similar), then by member count, then by how many services those members span. Re-call with offset: 3 to continue.",
"clusters": [
{
"size": 4,
"files": 4,
"services": [
"acme-billing",
"acme-inventory",
"acme-notifications",
"acme-search"
],
"matched_on": "both",
"exactness": "exact",
"lowest_similarity": 1,
"members_form": "expanded",
"members": [
{
"name": "semverCompare",
"file_path": "functions/billing/index.ts",
"line_number": 179,
"end_line": 187,
"signature": "(a: any, b: any) => 0 | 1 | -1",
"intent": "Compares two semantic version strings by evaluating their major, minor, and patch components numerically."
},
{
"name": "semverCompare",
"file_path": "functions/inventory/index.ts",
"line_number": 299,
"end_line": 307,
"signature": "(a: string, b: string) => number",
"intent": "Compares two semantic version strings by evaluating their major, minor, and patch components numerically."
}
]
}
]
}
The skill evaluates all cluster members against the primary function and produces a consolidated report:
| class | member | file:line | against | why |
|---|---|---|---|---|
| DUPLICATE | semverCompare | functions/inventory/index.ts:299 | functions/billing/index.ts:179 | one contract, same component comparison |
| DUPLICATE | semverCompare | functions/notifications/index.ts:145 | functions/billing/index.ts:179 | one contract, same component comparison |
| DUPLICATE | semverCompare | functions/search/index.ts:230 | functions/billing/index.ts:179 | one contract, same component comparison |
Related
- Task skills details the automated end-of-task nudge and skill management.
- MCP tools documents
find_similarandsearch_by_intent.