An Agent Skill that helps coding agents design, implement, and review secure web APIs in JavaScript and TypeScript. Its main focus is Next.js, Express, Node.js, PostgreSQL, and Zod. It's a defensive engineering skill: it prevents vulnerabilities while code is being written, finds security defects in existing code, makes minimal fixes, and proves them with tests.
Every API change has to answer five questions:
- Who is the caller, and how is their identity established?
- May the caller perform this operation?
- May the caller access this particular resource, and these specific fields?
- Can the request abuse resources, exploit an input, or violate a business invariant?
- How will the expected security behavior be verified?
Coding agents know the standard security advice. The failures happen in specific places:
- The agent confirms that an auth library is installed, but never checks whether the route it is editing calls it.
- It fetches
WHERE id = $1on a tenant-owned table and returns the row. - It passes
await req.json()intoprisma.user.update, sorolebecomes writable. - It treats
middleware.ts, a hidden button, or CORS as authorization. - It "verifies" a JWT with
jwt.decode. - It adds a second auth library next to a working one.
- It writes tests that only check that access is denied, or it claims an endpoint is secure because the tests pass.
This skill makes the agent read the repository's real security architecture first. The agent then traces each endpoint from the route to the SQL and applies only the controls that endpoint needs. Every finding is reported with evidence, severity, and confidence.
Analyze repository → API contract → Select risks → Trace implementation → Minimal fix → Verify
- Analyze the repository. The agent finds the identity mechanism, where authentication is enforced, the authorization model, tenancy, validation, data access, errors, rate limiting, and test helpers. It refers to environment variables by name only and never prints secret values. An optional read-only scanner,
scripts/scan_api_surface.py, lists entry points and pattern signals as leads. - Write the API contract for each endpoint: the caller, authorization at the function, object, and property levels, inputs, invariants, and limits. Sensitive operations also get a lightweight threat model.
- Select risks using the OWASP API Security Top 10 (2023) and the matching ASVS 5.0 chapters. The agent loads only the reference files that fit the endpoint.
- Trace the implementation. The agent checks mounting order, proxy and middleware matchers, helper calls, and
WHEREclauses, and covers every route that reaches the same data. Each issue is classified as Confirmed, Probable, or Needs Verification. - Fix minimally, using the existing patterns and libraries. Contract changes are called out. Nothing is weakened to make a test pass.
- Verify with tests for both allowed and forbidden access, written in the project's own framework. Each denial test asserts the status code, that no forbidden data was returned, and that nothing was changed. The agent also removes the control temporarily to confirm a test fails, then restores it. It reports exactly what ran and what is still unverified.
| Path | Purpose |
|---|---|
SKILL.md |
Workflow, routing table, rules, red flags (about 3k tokens) |
references/repository-analysis.md |
What to inspect, how to trace an endpoint, how to handle secrets, the security architecture profile |
references/threat-modeling.md |
API contract worksheet, lightweight threat model, how to select controls |
references/authorization.md |
BOLA/IDOR, BFLA, BOPLA (mass assignment and excessive exposure), multi-tenant isolation, where checks belong |
references/authentication.md |
Password storage (current OWASP parameters), login, sessions and cookies, CSRF, JWT verification, refresh tokens, password reset, machine-to-machine auth, secrets |
references/input-and-injection.md |
Zod at the boundary, SQL injection by PostgreSQL client, identifier allowlists, command and path injection, redirects, deserialization |
references/resource-and-business-logic.md |
Rate limits, bounded work, sensitive flows, state transitions, races, idempotency |
references/integrations.md |
SSRF, file uploads and downloads, webhooks, upstream responses |
references/configuration-and-errors.md |
Proxies, CORS, headers, limits, secrets, database privileges, errors, logging, inventory |
references/frameworks.md |
Next.js App Router, server actions, proxy and middleware, Pages Router, Express 4 vs 5 |
references/security-testing.md |
Test levels, the security test matrix, assertions, fixtures, patterns per stack |
references/findings-and-reporting.md |
Evidence levels, finding format, severity and confidence, remediation policy, report templates |
references/owasp-mapping.md |
API Top 10 and ASVS mapping, sources, verification dates |
examples/ |
Worked examples: BOLA in Express + pg, profile update in a Next.js route handler, webhook verification and idempotency |
scripts/scan_api_surface.py |
Read-only scanner for the API surface (standard library only, Python 3.9+) |
scripts/validate_skill.py |
Maintainer check for structure, links, evals, and hygiene |
tests/ |
Unit tests for the scanner (python -m unittest discover -s tests) |
evals/ |
7 behavioral evals with packed fixture repositories, plus 20 trigger queries |
python scripts/scan_api_surface.py /path/to/repo # human-readable
python scripts/scan_api_surface.py /path/to/repo --json # machine-readableIt reports:
- Security-relevant dependencies per
package.json. - Next.js route handlers, Pages Router API routes, server action modules, and the
middleware.ts/proxy.tsmatcher. - Express-style routes. Each route gets three flags: whether the file references anything auth-like, whether the route takes a resource ID, and whether it touches data access.
- Pattern signals, such as:
- SQL built from strings or untagged template literals
$queryRawUnsafejwt.decode- JWT verification without pinned options
- fast password hashes
- signatures compared with
=== - wildcard CORS
trust proxy: true- raw request bodies flowing into writes
- passthrough schemas
- error details in responses
- open redirects
- SSRF candidates
- shell execution
- file paths built from input
- sensitive logging
- hard-coded or default secrets
- cookie flags
- unbounded page sizes
- webhook handlers without raw-body or HMAC verification
- Environment variable names, including
NEXT_PUBLIC_*names that look secret. - Security markers in existing tests.
It never opens real .env files and redacts literals from snippets. Every signal is a lead to confirm by reading the code. A route without the auth-like flag may still be protected by global middleware.
This skill is responsible for API security analysis, design decisions, remediation, and the security test cases. It works on its own. It also composes with these skills, which were inspected locally while building it:
| Skill | Owns | How this skill cooperates |
|---|---|---|
stack-aware-development |
Stack detection, conventions, minimal-change workflow | Reuses its stack profile and adds a security architecture profile |
zod-schema-architect |
Schema design, placement, versions | This skill decides which fields each caller may write or read; the schema details go to that skill |
unit-test-architect |
Test stack detection, test quality, running tests | This skill supplies the security test matrix; that skill owns how the tests are written and run |
The skill never claims to invoke another skill unless the host has actually loaded it. When guidance conflicts, the repository's established pattern wins, unless that pattern is itself the vulnerability.
| Check | Status |
|---|---|
scripts/validate_skill.py (frontmatter, links, orphans, tables of contents, script mentions, evals, hygiene) |
Passes |
| Scanner unit tests (21 cases: routes, signals, redaction, env-name handling, test markers) | Pass. Removing the redaction made 2 tests fail. |
| Scanner on the 7 eval fixtures | Flags the planted jwt.decode, default secret, SHA-256 passwords, missing cookie flags, !== signature comparison, and non-raw-body webhook. No signals on the sound fixture (06). |
Agent Skills spec (skills-ref validate) |
In CI. Not yet run locally. |
CI (.github/workflows/validate.yml) |
Written. Not yet run on GitHub. |
With-skill vs. without-skill benchmark on evals/evals.json |
Not yet run |
Trigger accuracy (evals/trigger-evals.json) |
Not yet run |
Manual (Claude Code): copy or clone this directory to one of these locations. The directory name must be secure-api-architect.
~/.claude/skills/secure-api-architect/(personal).claude/skills/secure-api-architect/(project)
With the skills CLI, after publishing the repository to GitHub:
npx skills add <owner>/secure-api-architect- Unpack the fixture repositories outside the skill. Each one becomes its own git repository:
python evals/build_fixtures.py unpack /tmp/saa-evals
- Open a fixture, give the agent the matching
promptfromevals/evals.json, and grade its actions, diff, and report againstexpectationsandfailure_conditions. - To measure the skill's effect, run the same prompt in a second copy without the skill installed, and grade both runs blind.
- For trigger tuning, run the queries in
evals/trigger-evals.jsonand record which ones activate the skill.
Fixture repositories are packed into evals/fixtures.json rather than stored as files. Real package.json files or .ts sources inside an installed skill would become false stack signals, or test files, in the host project.
The baseline was verified against official sources on 2026-10-15:
- OWASP API Security Top 10 (2023 edition, still current)
- OWASP ASVS 5.0.0
- OWASP cheat sheets: REST, Authorization, Authentication, Password Storage, Session Management, JWT, CSRF, SSRF, File Upload, Mass Assignment, Forgot Password
- Next.js authentication and proxy documentation
- Anthropic's Agent Skills overview and best practices
URLs and notes are in references/owasp-mapping.md.
- Scope: dedicated guidance covers Next.js and Express on PostgreSQL. Fastify, NestJS, Hono, tRPC, and GraphQL get principles, not dedicated files.
- The scanner is a heuristic. It works line by line on JS/TS. It doesn't follow imports, resolve router mounting, or understand types. Its job is to speed up inspection, not replace it.
- Infrastructure controls are out of reach. Gateways, WAFs, egress firewalls, database grants, and IdP configuration can only be verified when their configuration is in the repository. Otherwise the skill reports them as "Needs Verification".
- Time-sensitive facts have a verification date. These include standard editions, password-hashing parameters, and framework behavior. Re-verify them before relying on them.