Home › Security › Secure coding AGENTS.md

Secure coding AGENTS.md

AGENTS.md security baseline for AI agents in any web stack: secrets, injection, auth checks, dependencies, and logging.

AGENTS.mdSecurity

How to use

Save this as AGENTS.md in your repository root, commit it, and your agent will pick it up automatically. Edit the commands to match your project.

AGENTS.mdDownload  
# AGENTS.md: Security baseline

Apply these to every change, in any language.

## Secrets
- Never hard-code or print keys, tokens, or passwords. Read them from env/secret manager. Add new names to `.env.example` with fake values.
- If you find a committed secret, stop and report it; don't just delete the line (it's in git history and must be rotated).

## Input and output
- Validate all external input (body, query, headers, files, webhooks) with a schema at the boundary.
- SQL only via parameterized queries/ORM. Shell commands only via argument arrays, never string concatenation with user input.
- Encode output for its context; don't bypass the framework's escaping (`dangerouslySetInnerHTML`, `|safe`, `v-html`, `html_safe`) with user data.
- Uploads: check type and size, store outside the web root with random names.
- Fetching user-supplied URLs needs an allowlist (SSRF).

## Access control
- Check authorization on the server for every request and every object (`resource.owner_id == user.id`), not just in the UI.
- Deny by default; new routes require auth unless explicitly public.
- Webhooks verify signatures; sessions/cookies use `HttpOnly`, `Secure`, `SameSite`.

## Dependencies
- Add packages only when necessary; check they're maintained and correctly named (typosquatting). Run the ecosystem audit (`npm audit`, `pip-audit`, `cargo audit`, `govulncheck`).

## Logging
- Log security events (login, permission denied) without tokens, passwords or full PII.

## Report
End with a short "Security notes" section listing anything risky you noticed but didn't change.

More: all Security rules · all AGENTS.md rules

Related rules

API route security .claude/rules file

A path-scoped Claude Code rules file for API routes and handlers: auth, ownership checks, validation, and safe errors.

Claude Code (CLAUDE.md)Security

Security auditor subagent (Claude Code)

A read-only Claude Code subagent that audits changes or a module for common web security vulnerabilities.

Claude Code (CLAUDE.md)Security

Security review prompt file (Copilot)

A Copilot prompt file (/security-review) that audits a file or the current diff for common vulnerabilities, read-only.

GitHub CopilotSecurity

Git commits & PRs AGENTS.md

AGENTS.md rules for how agents commit: Conventional Commits, atomic changes, safe git commands, and PR descriptions.

AGENTS.mdAgent workflows

Cypress end-to-end testing AGENTS.md

AGENTS.md for Cypress 15 E2E and component tests: selectors, cy.intercept, sessions, and flake-free waits.

AGENTS.mdTesting

Dependency upgrade workflow AGENTS.md

AGENTS.md workflow for upgrading dependencies and frameworks safely: one at a time, changelogs, codemods, and verification.

AGENTS.mdAgent workflows

Get new rules weekly

One email a week: fresh rule files, agent tips, and what's changing in Cursor, Claude Code and Copilot. Free, unsubscribe anytime.

Opens the Rulestack Newsletter on beehiiv in a new tab. Or subscribe directly on beehiiv.