write-discoverable-code
Skill1 starsChanged 36 days agoMITView on GitHub
Write and review source code with distinctive names and precise public APIs so coding agents can find it efficiently across text search, repo maps, and semantic retrieval. Do NOT load for Markdown corpora, wikis, or docs sites that navigate via explicit indexes and wikilinks. Do NOT load for prompt/skill authoring — use `create-skill` or `skill-tune`. Use when writing, reviewing, or refactoring code in a repository; picking names for functions/files/types/directories; tightening type annotations; or drafting an AGENTS.md/CLAUDE.md for a code repo. Triggers: 'write this code', 'review this code', 'refactor this file', 'name this function/file/type', 'is this agent-navigable', 'grep-friendly', 'discoverable code'.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- thoriqakbar0/skillstheir own version, first seen Aug 19, 2026
- modem-dev/skillstheir own version, first seen Jul 20, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- modem-dev/skills★ 53same name
- thoriqakbar0/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- 60-30-10Skill
- buildSkill
- explainerSkill
- explainSkill
- icm-architectSkill
- karpathy-guidelinesSkill
- skill-tuneSkill
- swarmSkill
- weekly-signal-diff-aiSkill
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Do NOT load for Markdown wikis, documentation sites, or prose corpora whose navigation is explicit (index files, wikilinks, routed …
- Distinctive: line 25
Decide: if that's enough context; if not, search again with a better query
- Very specific: line 28
Every input you as the code author control feeds step 1: the names on your files, functions, types, and directories.
- Distinctive: line 69
Search often lands on the definition.
- Distinctive: line 88
Write the one-line "why" comment on the definition.
- Very specific: line 92
Run the automated checks first: scripts/check-discoverable-code.sh <target-dir>.
- Distinctive: line 98
When a module is unusually large or search-hostile—for example, it contains many nested definitions under one wrapper—review it for …
- Distinctive: line 103
Update AGENTS.md to point at the new layout.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Write Discoverable Code
When to Use This Skill
Load when writing, generating, reviewing, or refactoring source code — new files, PR review, renames, type tightening, monolith refactors, or AGENTS.md authoring for a code repo.
Do NOT load for Markdown wikis, documentation sites, or prose corpora whose navigation is explicit (index files, wikilinks, routed AGENTS.md); they solve discoverability without grep. Do NOT load for prompt/skill authoring — use create-skill or skill-tune.
The Core Mental Model
Many coding-agent workflows lean on plain-text search (grep/ripgrep) as a first pass. Others supplement it with repo maps, language servers, or semantic retrieval. Names that are useful search terms remain useful across these retrieval methods.
A common navigation loop:
- Search the repo with
rgfor a symbol or filename - Read a window around the best hit
- Decide if that's enough context; if not, search again with a better query
- Edit
Every input you as the code author control feeds step 1: the names on your files, functions, types, and directories. Filenames are search terms too (rg --files), so a session-broker/ directory is a hit before the agent opens anything.
The single lever: make the words in your code good search terms.
The Rules (in order of payoff)
1. Names must be distinctive
Generic names return hundreds of unrelated hits and burn thousands of tokens as the agent reads windows to disambiguate. Distinctive names resolve in one hop.
Evaluate names against the target repository: a name is too generic when searching it produces many unrelated hits. Do not use a fixed hit count or global deny list in place of that judgment.
Examples of generic names and worked bad→good alternatives live in references/banned-names.json. Treat them as review prompts, not an automatic deny list: inspect the target repository's actual search results and conventions.
This is the highest-leverage rule. Everything else in this skill is a distant second.
2. Types tell the agent how to use code without opening it
A precise signature often answers the agent's first question without a file read:
// Good — agent may never need to open the body
function enrich(user: User): EnrichedUser
// Bad — agent must read the implementation to learn what `data` is
function enrich(data)On public APIs, avoid any / as any / Object / Function (TypeScript); bare Any, untyped **kwargs, untyped *args (Python); and interface{} (Go). These often conceal the same usage information as an untyped signature. Judge local implementation trade-offs separately from public interfaces.
Branded types / newtypes for identifiers that share a primitive shape (OrgId and UserId instead of two strings) can turn argument swaps into compile errors. Consider them when a function takes:
- two parameters of type
stringthat represent different identifiers - two parameters of type
numberthat represent different quantities (retry count, timeout ms) - a token, key, secret, or URL as bare
string - a currency amount as bare
number
Type names are search terms too. OrgId grep-resolves cleanly; Result, Data, Config do not. Compiler errors are the fastest feedback loop the agent has — a typed API is worth more than any comment.
3. Put the comment on the definition
Search often lands on the definition. Put the one-line comment that explains the why the code cannot say itself directly above that definition. Skip decorative headers and README-style prose; keep critical context close to the definition.
4. Small rules that add up
- One spelling per concept.
orgIdandorganizationIdsplit searches. Pick one and use it everywhere. Same for import aliases. - Unique names pierce barrel files.
export *re-exports erase names, so a call site importing from@modem/commongives the agent no path to the definition — but a distinctive symbol name lands there directly. - Name tests after the source they cover.
stripe.test.ts↔stripe.ts.test_stripe.py↔stripe.py. - Mark legacy paths
@deprecated(or the language equivalent). Better yet, delete them. - Write an
AGENTS.md/CLAUDE.mdin the repo root. Record naming conventions, source layout, script entry points. Template inreferences/agents-md-stanza.md.
Why This Matters (the evidence)
The cited experiments found large retrieval and cost gains from more discoverable code in many configurations, especially where names were less distinctive. Results varied by model and harness; treat them as directional evidence, not a universal benchmark.
Workflow: Writing New Code
- Say in one specific sentence what the file/function/type does.
- Turn the nouns in that sentence into the name.
hmac-payload-signer.tscame from "signs notification payloads with HMAC." - Type every public signature. Consider a branded type / newtype when a bare
stringornumbercould be confused with another primitive-shaped value. - Write the one-line "why" comment on the definition.
Workflow: Reviewing Existing Code
- Run the automated checks first:
scripts/check-discoverable-code.sh <target-dir>. It enforces unmarked legacy paths whose names contain a whole legacy component and surfaces TypeScript/Python type signals for public-API review. - Then run the checklist in
references/checklist.mdagainst the file or PR for the expert-checkable items (name distinctiveness, one-spelling-per-concept, test naming, comment-on-definition, branded-type opportunities, and public-API scope). - For each failing item, propose the specific rename or annotation — do not just flag it.
Workflow: Refactoring a Monolith
When a module is unusually large or search-hostile—for example, it contains many nested definitions under one wrapper—review it for independently named concepts. Do not make architectural changes unless the task asks for them:
- Identify the distinct concepts inside (Odysseus's
email_routes.pycontained SMTP settings, message rendering, folder fallbacks, delivery history). - Split into concept-named modules, one file per concept. Filenames become search terms.
- Preserve behavior mechanically — run existing tests before and after.
- Update
AGENTS.mdto point at the new layout.
What This Skill Does NOT Cover
- Retrieval strategy (embeddings, repo maps, LSP-backed tools). This skill keeps source text useful to the retrieval methods a repository already uses.
- Architecture (module boundaries, service splits, framework choice). Upstream of naming.
References and Scripts
references/banned-names.json— advisory examples of generic file and symbol names, with bad→good alternatives.references/checklist.md— the pre-commit / pre-PR checklist for expert-checkable items.references/agents-md-stanza.md— drop-in AGENTS.md template for new code repos.scripts/check-discoverable-code.sh— ripgrep-backed legacy-marker enforcement plus advisory TypeScript/Python public-API review signals. Requiresrg.
Owner: Matt Weigand. Last reviewed: 2026-08-10. Source: Modem — How coding agents read your code (2026-07-20). Re-review when coding-agent retrieval strategies materially shift, when Modem publishes Part 2 with new evidence, or when the advisory name examples need a language-specific refresh.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

