SkilVaultSign inStart free

Catalogue / codebase-example-scout

codebase-example-scout

Older skill: source not recordedSignedFinds the strongest existing implementations of a requested feature or design pattern in a repository and distils them into an implementation guide with file paths, line numbers, conventions, pitfalls and test patterns. Queries the sourceatlas pattern lookup first and falls back to built-in code sea…
---
name: codebase-example-scout
description: >
  Finds the strongest existing implementations of a requested feature or
  design pattern in a repository and distils them into an implementation
  guide with file paths, line numbers, conventions, pitfalls and test
  patterns. Queries the sourceatlas pattern lookup first and falls back to
  built-in code search only when that tool is unavailable or returns nothing
  usable. Use when the user asks how to implement something the way this
  project already does it, where a feature lives, or wants working examples
  before writing similar code. Not for designing features with no precedent
  in the repo, general code review, bug hunting or security audits.
license: MIT
---

Codebase Example Scout

Purpose

The user wants to build something the way this repository already builds it. Your job is to locate the best real precedents and reduce them to a recipe the user can follow: which files to copy from, in what order to build, which unwritten rules apply, which traps are hiding in the code, and which test to model theirs on. Every claim you deliver must be traceable to a file and a line range; a guide built on guesswork is worse than no guide.

When to engage

Typical requests that should activate this skill:

  • "How does this repo send transactional email?"
  • "Where are the GraphQL resolvers defined?"
  • "Show me a migration that adds an index."
  • "I need a background job that follows our queue conventions."

Skip it when the user wants functionality with no precedent in the codebase, a code review, or an architectural opinion.

Step 1 — Decide what you are hunting for

Restate the request in one sentence that names the pattern kind, for example "a POST endpoint that accepts JSON, validates it and returns 201". If two readings are plausible, ask the user which one they mean before searching; the wrong reading wastes the lookup and every step after it. Then pick a short pattern label of two or three words, such as "api endpoint" or "file upload", to query with — the catalogue below lists proven labels.

Step 2 — Query the pattern index

The primary route is the sourceatlas lookup. Invoke it as /sourceatlas:pattern "<pattern>", passing exactly one quoted pattern name, for instance /sourceatlas:pattern "authentication". The command is a read-only search — it modifies nothing in the repository — and it answers with the best example files for the pattern, each with exact line numbers, plus an implementation guide for that pattern.

Treat its ranking as your starting shortlist and its included guide as a draft, not finished output. Indices can lag recent commits, so confirm in Step 4 that the cited locations still say what the guide claims before you pass them on. If the lookup returns nothing, or nothing close to what was asked, do not paper over the gap with guesses — note what happened and move to the fallback.

Step 3 — Fall back to local search when needed

Use this route only when the lookup cannot be run or its answer misses the request, and state in your final report which case occurred.

  1. Scan the top-level layout for naming signals — folders such as handlers, services, jobs, routes — so your terms match the project's own vocabulary rather than generic ones.
  2. Run several keyword passes: domain nouns ("invoice", "upload"), framework terms ("middleware", "decorator"), and structural suffixes ("Controller", "Repository", spec and test markers). Include test files in every pass; tests reveal the intended way to call the code.
  3. Rank the hits yourself: prefer files with accompanying tests, recently touched files, files referenced from the README or docs, and the closest shape match. Keep the top two or three and skim the rest only to confirm they are variants of one idea.

Step 4 — Verify before you trust anything

Read each shortlisted file end to end, whichever route produced it. Record exact paths and line ranges for the parts that matter: registration or wiring, core logic, error paths, and the matching test. Never cite a line you have not read yourself.

Step 5 — Distil the recipe

Convert the verified exemplars into:

  • an ordered implementation flow — the steps a new file of this kind goes through from registration to behaviour;
  • a conventions list — naming, file placement, error style, how configuration is read — each item traceable to a file and line range;
  • observed pitfalls — TODOs, commented workarounds, deprecated imports, ordering constraints;
  • a testing pattern — where the analogous test lives and how it is structured.

Pattern catalogue

| User asks about | Label to pass to the lookup | Fallback search seeds | Worth recording | | --- | --- | --- | --- | | HTTP endpoints | api endpoint | router registrations, HTTP verbs, handler and controller files | where routes are declared, URL style, response envelope | | Auth and permissions | authentication | guard, session, token, policy, middleware names | where the check runs, failure behaviour such as redirect versus status code | | Database queries | database query | table names, query builder calls, migration files | where queries live, transaction boundaries, schema-change process | | Background jobs | background job | queue, worker, cron, scheduler terms | enqueue API, retry rules, idempotency guards | | File uploads | file upload | multipart, storage client, content-type checks | size and type limits, storage backend, cleanup routine | | Error handling | error handling | custom error classes, status codes, logging calls | error response shape, log levels, where errors are caught | | Validation | validation | validator library names, schema definitions, parse calls | validation location, shape of the failure payload | | Testing | unit test | test framework imports, fixture helpers | test directory, file naming, setup helpers |

Worked example

The user asks, "Add an endpoint that streams a monthly invoice summary as CSV."

  1. You restate it as "a GET endpoint returning a CSV download" and choose the label "api endpoint".
  2. You run /sourceatlas:pattern "api endpoint". It ranks app/api/reports_export.rb lines 40–96 first and includes a draft guide.
  3. You read that file end to end, confirm the route wiring in config/routes.rb lines 18–24, and note the permission guard at line 52 plus a comment at line 71 warning that exports must stream or large responses buffer in memory. You also read spec/requests/reports_export_spec.rb, which stubs the upstream billing call.
  4. Your guide says: register the route under the same versioned scope, wrap the handler in the shared export presenter, apply the same scope check, and model the new spec on the file above — and it flags the streaming pitfall verbatim from the comment.

Had the lookup failed with "command unavailable" instead, you would have run the fallback passes on "export", "csv" and the framework's streaming helper, kept the two handlers that have specs, and stated in the report that the exemplars came from local search rather than the index.

Report shape

Deliver five blocks: exemplars (two or three files with paths and line ranges, one sentence each on why they were chosen), implementation flow (numbered steps), conventions (bullets, each traceable to a file and lines), pitfalls, and testing pattern. Mention the route you used — index or fallback — and why.

Boundaries

  • This skill is strictly read-only. Do not create, edit or delete files, and do not run anything that changes repository state.
  • Never state a convention you cannot point to in at least one real file. If the repository holds no example of the requested pattern, say so plainly and suggest confirming the approach with the user instead of inventing house rules.
  • When shortlisted examples disagree — one uses raw queries, another an ORM — surface the split and identify which appears to be the newer direction; do not silently pick one.
  • Quote only short excerpts of a few lines; summarise the rest and cite file and line numbers.
  • This skill produces a guide only; it does not cover writing, reviewing or committing the new implementation itself.

Provenance

Adapted from the MIT-licensed pattern-finder skill by Justin Lee. The MIT notice committed with this package governs the reused workflow.