api-endpoint
Skill44 starsChanged 7 days agoMITView on GitHub
Rules for HTTP API endpoints. Use when adding or changing any endpoint (route, request or response shape, status codes), especially login and ones that read or change other users' data.
5 other projects use a version of this.
Adopted by
Most recently taken up by
- Univers42/harness42their own version, first seen Nov 1, 2026
- nrjdalal/inscopetheir own version, first seen Oct 13, 2026
- nrjdalal/zerostartertheir own version, first seen Oct 8, 2026
- Univers42/claude-deal-with-the-deviltheir own version, first seen Oct 4, 2026
- tadoEng/web-startertheir own version, first seen Aug 11, 2026
Used with
Projects with it also use doc-sync.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
JetBrainsSkilldoc-sync
Keeps IdeaVim documentation in sync with code changes. Use this skill when you need to verify documentation accuracy after code changes, or when checking if documentation (in doc/, README.md, CONTRIBUTING.md) matches the current codebase. The skill can work bidirectionally - from docs to code verification, or from code changes to documentation updates.
Also in 4 projects that use this
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- nrjdalal/zerostarter★ 65same name
- Univers42/claude-deal-with-the-devil★ 4same name
- Univers42/harness42★ 4same name
- nrjdalal/inscope★ 3same name
- tadoEng/web-starter★ 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 repository3 other files it gives its agents.
- dist/AGENTS.mdAGENTS.md
- data-integritySkill
- db-migrationSkill
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 65
Use the repo's auth, error format and database access.
- Distinctive: line 66
Add tests with the repo's test setup: the happy path, someone else's resource, and bad input.
- Distinctive: line 72
API docs or collection: not set.
- Distinctive: line 73
Error format: not set.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
API endpoint
Examples are TypeScript with pg. The rules apply to any stack.
Anything that changes money, stock or balances, or calls a payment provider or email: also follow the
data-integrity skill (transactions, locks, idempotency).
1. Check who may call it, not just that they're logged in
Why: a logged-in user who changes the id in the URL reads or edits someone else's data (IDOR).
// Bad: any logged-in user can read any invoice
const { rows } = await pool.query("select * from invoices where id = $1", [id]);
// Good: scope the query to the caller; someone else's invoice looks the same as a missing one
const { rows } = await pool.query("select * from invoices where id = $1 and account_id = $2", [id, user.accountId]);
if (rows.length === 0) return sendError(res, 404, "not_found", "Invoice not found");Admins or other roles get access through an explicit role check, never by skipping the filter.
2. Bad input is a 4xx, never a 500
Why: a 500 on bad input hides real errors in the noise. Bad values that slip through (negative amounts, fractions) corrupt data.
- Validate the body and path params at the edge: types, integers where money and quantities are counted,
ranges (
quantity >= 1,amountCents > 0), required fields, ids that aren't numbers. - Handle what a request can legally contain but your code doesn't expect, like the same item listed twice. Merge the duplicates or reject them with a 400, but don't let the request crash into a 500.
- Map expected database errors: unique violation (
23505) → 409, foreign key violation (23503) → 404 or 400.
3. Limit how often anyone can try: login, codes, anything that sends or costs
Why: without a limit, a script guesses passwords or one-time codes until one works, or sends thousands of emails and SMS on your bill.
// Bad: counts a failure only after checking it; 50 parallel guesses all see "0 failures so far"
if (failures.get(email) >= 10) return sendError(res, 429, ...);
if (!(await verifyPassword(password, hash))) failures.set(email, failures.get(email) + 1);
// Good: count the try first, in one atomic statement, in storage every server shares
const { rows: [c] } = await pool.query(
`insert into attempts (key, n, since) values ($1, 1, now())
on conflict (key) do update set n = attempts.n + 1 returning n`, [`login:${email.toLowerCase()}`]);
if (c.n > 10) return sendError(res, 429, "too_many_attempts", "Try again later");- Key the limit on the account (and on the IP, with a looser limit), and make the window expire.
- Once the limit is hit, refuse even the right password until the window ends.
- An unknown account and a wrong password get the same response, so nobody can find out which accounts exist.
- In-memory counters only work with one server. Use the database or Redis.
4. Use what the repo already has, and test it
Why: a second auth check, error format or DB helper drifts from the first, and reviewers have to catch it.
- Use the repo's auth, error format and database access. Errors never return a bare string or a stack trace.
- Add tests with the repo's test setup: the happy path, someone else's resource, and bad input.
Make it yours
Your team's choices. A line that says "not set" means: follow what the repo already does.
- API docs or collection: not set.
- Error format: not set.
- Someone else's resource: 404, so nobody learns it exists.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

