api-security-best-practices
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
Skill by sickn33
Chalk Labs
Need help deploying api-security-best-practices?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/sickn33-api-security-best-practices
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, backend, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/api-security-best-practices
What's inside
- Skill name
api-security-best-practices- Description
- Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
- License
- MIT
- Instructions
- 209 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# API Security Best Practices
Review the request boundary from caller identity through authorization, validated
input, storage and observable response. Preserve the application's actual identity
provider and data model rather than introducing a second authentication system.
## When to Use
Use when adding a protected endpoint, reviewing object access, replacing permissive
request parsing, or investigating an API abuse path. For a concrete defect, start
with the failing route and its callers; do not deploy unrelated security infrastructure.
## Inputs and prerequisites
Record the routes, caller/tenant model, identity provider, token contract, runtime and
locked dependency versions, database schema, proxy topology and authorized test scope.
Use synthetic identities in a test environment. Existing task authorization carries
forward; production scans, account writes and message sends need their own authority.
The Node examples below are integration sketches for Express, jsonwebtoken and Zod;
application/database adapters are deliberately named rather than presented as a full
runnable service. Confirm APIs against the installed versions before integrating.
## 1. Authenticate the exact token contract
Prefer the established provider/session middleware. When the service owns an HMAC
JWT contract, require a strong server-owned key, a fixed algorithm, exact issuer and
audience, and required runtime claims. Do not infer permissions from a decoded token
before signature verification. Never accept a caller-selected verification algorithm.
```javascript
const jwt = require('jsonwebtoken');
// Illustrative first-party access-token contract; not a third-party OAuth adapter.
const ACCESS_POLICY = {
algorithms: ['HS256'], issuer: 'example-auth', audience: 'example-api'
};
function verifyAccessToken(token, signingKey) {
const claims = jwt.verify(token, signingKey, ACCESS_POLICY);
if (!claims || typeof claims !== 'object' ||
typeof claims.sub !== 'string' || !claims.sub ||
typeof claims.tenantId !== 'string' || !claims.tenantId ||
!Number.isSafeInteger(claims.exp) || !Number.isSafeInteger(claims.iat) ||
claims.exp <= claims.iat) {
throw new Error('Invalid access claims');
}
return { subject: claims.sub, tenantId: claims.tenantId };
}
function readBearer(header) {
if (typeof header !== 'string' || header.length > 8192) return null;
const match = /^Bearer ([A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+)$/i.exec(header);
return match ? match[1] : null;
}
```
Issue access tokens with the same issuer/audience/algorithm and a short application-
approved expiration. Handle verification failure as a generic 401 without echoing the
token or exception. Expiration alone does not revoke a token; define revocation or
short-lived sessions according to the actual threat model. A service using asymmetric
provider keys needs the provider's discovery/JWKS validation and key-rotation policy,
not this HMAC example. Never reuse an access token as a refresh token.
### Refresh sessions
Use the provider's supported session flow or a server-side opaque refresh design:
store only a digest, expiry, user/session family and revocation state. In one atomic
transaction consume the old active token and create the replacement. Concurrent reuse
must not issue two successors; defined reuse handling revokes the affected family.
Check current user status and permissions when issuing new access tokens. Bind refresh
to the intended client/session and protect cookie-based requests against CSRF. Do not
log tokens, store them plaintext in a database, or return a refresh token through a URL.
Test simultaneous refresh, expiry, replay, revocation and transaction failure before
calling the flow complete. No database transaction adapter is bundled here.
## 2. Authorize the resource and operation
Authentication identifies the caller; authorization decides the exact operation on
an object and tenant. A role name does not automatically grant cross-tenant access.
Apply the owner/tenant predicate in the database mutation to avoid a check-then-write
race, and allowlist writable properties. Use 404/403 consistently with the product's
resource-disclosure policy.
```javascript
// Prisma-style sketch; id and tenant types must match your actual schema.
async function deleteOwnedPost(prisma, postId, principal) {
const result = await prisma.post.deleteMany({
where: { id: postId, userId: principal.subject, tenantId: principal.tenantId }
});
return result.count === 1;
}
```
An administrator path needs an explicit separate policy and audit event; do not add
an implicit admin bypass to every owner check. Test a valid user accessing another
user's object, the same ID in another tenant, deleted memberships and bulk endpoints.
## 3. Parse once, then use the validated value
Reject partial numeric parses (`12abc` is not ID 12), unsafe integers, unexpected
properties and oversized requests. Use parameterized database queries. An ORM does
not provide business authorization or make unsafe raw SQL safe.
```javascript
function parsePositiveId(raw) {
if (typeof raw !== 'string' || !/^[1-9][0-9]{0,15}$/.test(raw)) return null;
const value = Number(raw);
return Number.isSafeInteger(value) && value > 0 ? value : null;
}
const { z } = require('zod');
const profileUpdate = z.object({
displayName: z.string().trim().min(1).max(100)
}).strict();
function validateBody(schema) {
return (req, res, next) => {
const parsed = schema.safeParse(req.body);
if (!parsed.success) {
return res.status(400).json({ error: 'Invalid request' });
}
req.validatedBody = parsed.data; // Defaults/transforms must reach the handler.From sickn33/agentic-awesome-skills, MIT.
More from sickn33/agentic-awesome-skills
- 0.881score
asset-inventory
devops-skills
Maintain IT asset inventory and configuration management database.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.881score
arm-templates
devops-skills
Deploy Azure resources with ARM templates and Bicep.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.881score
access-review
devops-skills
Conduct periodic access reviews and certifications.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.878score
ai-coding-agent-guardrails
devops-skills
Secure AI coding agents (Claude Code, Cursor, Codex, Copilot) with permission boundaries, secret protection, code review gates, and safe sandbox…
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.878score
agents-generator
OJPalenzuela
Generate project-specific AGENTS.md and companion rules by analyzing a codebase.
SkillAFreshness: A★ 48.4KClaude Code - 0.876score
aws-lambda
devops-skills
Build and deploy serverless functions on AWS Lambda.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
aws-s3
devops-skills
Configure S3 buckets, policies, and lifecycle rules.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
aws-iam
devops-skills
Manage IAM users, roles, and policies.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
aws-rds
devops-skills
Provision and manage RDS databases.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
azure-aks
devops-skills
Deploy and manage Azure Kubernetes Service clusters.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
aws-vpc
devops-skills
Design and implement VPCs and networking.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.876score
aws-ecs-fargate
devops-skills
Deploy containers on ECS and Fargate.
SkillAFreshness: A★ 48.4KClaude Code +9
Signals
- Stars
- 48,428
- Forks
- 7,039
- Open issues
- 0
- Last commit (this folder)
- Sep 5, 2026 (1 month ago)
- Last release
- Oct 24, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Website
- aaskills.tech/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.334score
api-security-best-practices
Narendarcodes
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillBFreshness: B★ 4Claude Code +9 - 0.329score
api-security-best-practices
dushyantkhosla
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillAFreshness: AClaude Code +9 - 0.307score
api-security-best-practices
denycode-dev
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillBFreshness: BClaude Code +9 - 0.286score
api-security-best-practices
alexander-kastil
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 19Claude Code +9 - 0.283score
api-security-best-practices
roadsidedev
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 20Claude Code +9 - 0.281score
api-security-best-practices
LeoYeAI
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillCFreshness: C★ 2.2KClaude Code +9 - 0.278score
api-security-best-practices
jiho00seo-dev
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 10Claude Code +9 - 0.278score
api-security-best-practices
mupengi-bot
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 10Claude Code +9 - 0.268score
api-security-best-practices
AxelMrak
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 5Claude Code +9 - 0.249score
api-security-best-practices
danstrem2
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 1Claude Code +9 - 0.235score
api-security-best-practices
renatosouzar8
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: DClaude Code +9 - 0.229score
api-security-best-practices
agent-skills-hub
Implement secure API design patterns including authentication, authorization, input validation, rate limiting, and protection against common API vulnerabilities
SkillDFreshness: D★ 123Claude Code +9
More from sickn33
- 0.665score
agentphone
sickn33
Build AI phone agents with AgentPhone API.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.665score
ai-seo
sickn33
Optimize content for AI search and LLM citations across AI Overviews, ChatGPT, Perplexity, Claude, Gemini, and similar systems.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.665score
agent-evaluation
sickn33
Evaluate agent behavior with versioned cases and explicit verifiers.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.665score
agent-memory-systems
sickn33
Design tenant-scoped memory, retrieval and retention for agents.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.665score
add-app-clip
sickn33
Add an iOS App Clip target to an Expo app.
SkillAFreshness: A★ 48.4KClaude Code +9 - 0.665score
angular-best-practices
sickn33
Angular performance optimization and best practices guide.
SkillAFreshness: A★ 48.4KClaude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get api-security-best-practices running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
api-security-best-practices skill. Agent Mart. https://agentmart.dev/skills/sickn33-api-security-best-practices (last updated 2026-10-24)