Always-on security rules for source and configuration files in every language — secrets, input handling, access control, sessions and tokens, data protection, dependencies, and when to stop and ask a person.
What it isAlways-on coding rules. GitHub Copilot applies them to files matching **/*.{ts,tsx,js,jsx,mjs,cjs,cs,java,kt,py,go,rb,php,rs,sql,cls,trigger,apex,yml,yaml,json,tf,bicep,sh,ps1,Dockerfile}; the Claude Code version is a path-scoped rule generated from the same file. Why use instructions →
Install
This repository (recommended)
Adds .github/instructions/secure-coding.instructions.md — commit it so everyone's Copilot follows the same rules.
Nothing to invoke — edit a matching file and Copilot picks the rules up. Adjust applyTo if your repository layout differs.
This repository (recommended)
Adds .claude/rules/secure-coding.md — commit it. Claude loads it when it reads a matching file.
npx -y github:AGCO-Global/org-skills add instructions secure-coding --tool claude
Just for me, every repository
Save it in your user profile instead.
npx -y github:AGCO-Global/org-skills add instructions secure-coding --tool claude --user
Use it
Nothing to invoke. Adjust the paths globs if your repository layout differs.
Commands run in your repository folder and need Node.js 20+. They use your normal git sign-in to GitHub, so they work while the repository is private. Run npx -y github:AGCO-Global/org-skills list to see everything available.
Settings
name: "Secure coding"
description: "Always-on security rules for source and configuration files in every language — secrets, input handling, access control, sessions and tokens, data protection, dependencies, and when to stop and ask a person."
applyTo: "**/*.{ts,tsx,js,jsx,mjs,cjs,cs,java,kt,py,go,rb,php,rs,sql,cls,trigger,apex,yml,yaml,json,tf,bicep,sh,ps1,Dockerfile}"
Instructions Copilot follows
Secure coding rules
These apply to every language and stack. When a rule conflicts with a quick fix, keep the rule. Browser-specific rules live in frontend-security.instructions.md.
Secrets
Never write secrets, passwords, API keys, tokens, connection strings or private keys into code, config, tests, samples or comments. Anything committed is permanently exposed, including in history.
Read secrets at runtime from the organisation's secret store (Azure Key Vault, or pipeline secret variables backed by it), never from a file in the repository.
Prefer managed identities or workload identity over stored credentials — there is no secret to leak or rotate.
Use obvious placeholders in examples (<your-api-key>) and keep .env and local secret files in .gitignore.
A secret that was ever committed is leaked: rotate it first, then remove it from history.
A client bundle cannot hold a secret at all. If a browser or mobile app needs the capability, proxy the call through a backend.
Input and output
Treat all input as untrusted: request bodies, headers, query strings, files, queue messages, environment variables and third-party responses.
Validate at the boundary with allow-lists for type, length, range and format, and reject unknown fields on sensitive objects.
Use parameterised queries or the ORM. Never concatenate input into SQL, shell commands, LDAP filters, file paths or template expressions.
Encode output for its context (HTML, attribute, URL, JavaScript) and never render untrusted HTML without a maintained sanitiser.
Fetch user-supplied URLs only against a host allow-list, blocking private and cloud-metadata IP ranges, with a timeout and no redirect following. Prevents SSRF.
Never deserialise untrusted data into arbitrary types.
Validate uploads by content type, size and extension on the server, store them outside the web root, and never execute or include them.
Access control
Authenticate and authorise every endpoint, handler, job and admin path; deny by default.
Check object-level ownership (id together with the user or tenant), not just the role. Prevents IDOR.
Enforce authorisation on the server; client-side checks are for user experience only.
Grant least privilege to service accounts, pipeline service connections, database users and cloud roles; no shared admin accounts.
Sessions, tokens and crypto
Set session cookies HttpOnly; Secure; SameSite=Lax (or Strict) and require a CSRF token on every state-changing request that authenticates by cookie.
Validate a JWT fully before trusting it: signature against the expected key, plus exp, nbf, aud and iss. Never decode-without-verify on a trust path.
Rate-limit and lock out authentication, password-reset, token and one-time-code endpoints; without it, credential stuffing is free.
Generate tokens, ids and nonces with a cryptographically secure random source (crypto.randomUUID, RandomNumberGenerator, secrets), never Math.random or a seeded PRNG.
Hash passwords with Argon2id, bcrypt or scrypt (PBKDF2 where FIPS compliance requires it). Use vetted crypto libraries; never roll your own.
Data and logging
Never log passwords, tokens, secrets, full card numbers or personal data (names, email addresses, postal addresses, national or government ID numbers). Log opaque identifiers instead.
Return generic error messages with a correlation id; keep stack traces, SQL and internal paths in server logs only.
Encrypt data in transit (TLS) and at rest, using platform-managed keys where the platform offers them.
Collect and retain only the personal data the feature needs.
Dependencies and builds
Add dependencies only when needed, from official registries, with versions pinned by a committed lockfile.
Check new packages for maintenance, licence and known vulnerabilities; fix high and critical findings before merging.
Do not disable security checks, TLS validation, linters or scanners to make a build pass — no --no-verify, and no suppressed audit finding without a ticket recording the decision.
When to ask a person
Stop and ask a reviewer before changing authentication, authorisation, cryptography, secret handling, payment flows or personal-data processing.
Ask before adding a new external service, widening network or firewall access, or granting new permissions.
Say so clearly when you are unsure whether code is safe, or when a request would weaken an existing control, and route it to the team's security contact rather than guessing.
Go deeper: backend-code-review, frontend-code-review and api-design for the review checklists, plus the stack's development skill for the code you are changing.
---
name: "Secure coding"
description: "Always-on security rules for source and configuration files in every language — secrets, input handling, access control, sessions and tokens, data protection, dependencies, and when to stop and ask a person."
applyTo: "**/*.{ts,tsx,js,jsx,mjs,cjs,cs,java,kt,py,go,rb,php,rs,sql,cls,trigger,apex,yml,yaml,json,tf,bicep,sh,ps1,Dockerfile}"
---
# Secure coding rules
These apply to every language and stack. When a rule conflicts with a quick fix, keep the rule. Browser-specific rules live in `frontend-security.instructions.md`.
## Secrets
- Never write secrets, passwords, API keys, tokens, connection strings or private keys into code, config, tests, samples or comments. Anything committed is permanently exposed, including in history.
- Read secrets at runtime from the organisation's secret store (Azure Key Vault, or pipeline secret variables backed by it), never from a file in the repository.
- Prefer managed identities or workload identity over stored credentials — there is no secret to leak or rotate.
- Use obvious placeholders in examples (`<your-api-key>`) and keep `.env` and local secret files in `.gitignore`.
- A secret that was ever committed is leaked: rotate it first, then remove it from history.
- A client bundle cannot hold a secret at all. If a browser or mobile app needs the capability, proxy the call through a backend.
## Input and output
- Treat all input as untrusted: request bodies, headers, query strings, files, queue messages, environment variables and third-party responses.
- Validate at the boundary with allow-lists for type, length, range and format, and reject unknown fields on sensitive objects.
- Use parameterised queries or the ORM. Never concatenate input into SQL, shell commands, LDAP filters, file paths or template expressions.
- Encode output for its context (HTML, attribute, URL, JavaScript) and never render untrusted HTML without a maintained sanitiser.
- Fetch user-supplied URLs only against a host allow-list, blocking private and cloud-metadata IP ranges, with a timeout and no redirect following. Prevents SSRF.
- Never deserialise untrusted data into arbitrary types.
- Validate uploads by content type, size and extension on the server, store them outside the web root, and never execute or include them.
## Access control
- Authenticate and authorise every endpoint, handler, job and admin path; deny by default.
- Check object-level ownership (`id` together with the user or tenant), not just the role. Prevents IDOR.
- Enforce authorisation on the server; client-side checks are for user experience only.
- Grant least privilege to service accounts, pipeline service connections, database users and cloud roles; no shared admin accounts.
## Sessions, tokens and crypto
- Set session cookies `HttpOnly; Secure; SameSite=Lax` (or `Strict`) and require a CSRF token on every state-changing request that authenticates by cookie.
- Validate a JWT fully before trusting it: signature against the expected key, plus `exp`, `nbf`, `aud` and `iss`. Never decode-without-verify on a trust path.
- Rate-limit and lock out authentication, password-reset, token and one-time-code endpoints; without it, credential stuffing is free.
- Generate tokens, ids and nonces with a cryptographically secure random source (`crypto.randomUUID`, `RandomNumberGenerator`, `secrets`), never `Math.random` or a seeded PRNG.
- Hash passwords with Argon2id, bcrypt or scrypt (PBKDF2 where FIPS compliance requires it). Use vetted crypto libraries; never roll your own.
## Data and logging
- Never log passwords, tokens, secrets, full card numbers or personal data (names, email addresses, postal addresses, national or government ID numbers). Log opaque identifiers instead.
- Return generic error messages with a correlation id; keep stack traces, SQL and internal paths in server logs only.
- Encrypt data in transit (TLS) and at rest, using platform-managed keys where the platform offers them.
- Collect and retain only the personal data the feature needs.
## Dependencies and builds
- Add dependencies only when needed, from official registries, with versions pinned by a committed lockfile.
- Check new packages for maintenance, licence and known vulnerabilities; fix high and critical findings before merging.
- Do not disable security checks, TLS validation, linters or scanners to make a build pass — no `--no-verify`, and no suppressed audit finding without a ticket recording the decision.
## When to ask a person
- Stop and ask a reviewer before changing authentication, authorisation, cryptography, secret handling, payment flows or personal-data processing.
- Ask before adding a new external service, widening network or firewall access, or granting new permissions.
- Say so clearly when you are unsure whether code is safe, or when a request would weaken an existing control, and route it to the team's security contact rather than guessing.
Go deeper: `backend-code-review`, `frontend-code-review` and `api-design` for the review checklists, plus the stack's development skill for the code you are changing.
---
paths:
- "**/*.{ts"
- "tsx"
- "js"
- "jsx"
- "mjs"
- "cjs"
- "cs"
- "java"
- "kt"
- "py"
- "go"
- "rb"
- "php"
- "rs"
- "sql"
- "cls"
- "trigger"
- "apex"
- "yml"
- "yaml"
- "json"
- "tf"
- "bicep"
- "sh"
- "ps1"
- "Dockerfile}"
---
<!-- Secure coding — generated from instructions/general/secure-coding.instructions.md for Claude Code. Edit that file, not this one. -->
# Secure coding rules
These apply to every language and stack. When a rule conflicts with a quick fix, keep the rule. Browser-specific rules live in `frontend-security.instructions.md`.
## Secrets
- Never write secrets, passwords, API keys, tokens, connection strings or private keys into code, config, tests, samples or comments. Anything committed is permanently exposed, including in history.
- Read secrets at runtime from the organisation's secret store (Azure Key Vault, or pipeline secret variables backed by it), never from a file in the repository.
- Prefer managed identities or workload identity over stored credentials — there is no secret to leak or rotate.
- Use obvious placeholders in examples (`<your-api-key>`) and keep `.env` and local secret files in `.gitignore`.
- A secret that was ever committed is leaked: rotate it first, then remove it from history.
- A client bundle cannot hold a secret at all. If a browser or mobile app needs the capability, proxy the call through a backend.
## Input and output
- Treat all input as untrusted: request bodies, headers, query strings, files, queue messages, environment variables and third-party responses.
- Validate at the boundary with allow-lists for type, length, range and format, and reject unknown fields on sensitive objects.
- Use parameterised queries or the ORM. Never concatenate input into SQL, shell commands, LDAP filters, file paths or template expressions.
- Encode output for its context (HTML, attribute, URL, JavaScript) and never render untrusted HTML without a maintained sanitiser.
- Fetch user-supplied URLs only against a host allow-list, blocking private and cloud-metadata IP ranges, with a timeout and no redirect following. Prevents SSRF.
- Never deserialise untrusted data into arbitrary types.
- Validate uploads by content type, size and extension on the server, store them outside the web root, and never execute or include them.
## Access control
- Authenticate and authorise every endpoint, handler, job and admin path; deny by default.
- Check object-level ownership (`id` together with the user or tenant), not just the role. Prevents IDOR.
- Enforce authorisation on the server; client-side checks are for user experience only.
- Grant least privilege to service accounts, pipeline service connections, database users and cloud roles; no shared admin accounts.
## Sessions, tokens and crypto
- Set session cookies `HttpOnly; Secure; SameSite=Lax` (or `Strict`) and require a CSRF token on every state-changing request that authenticates by cookie.
- Validate a JWT fully before trusting it: signature against the expected key, plus `exp`, `nbf`, `aud` and `iss`. Never decode-without-verify on a trust path.
- Rate-limit and lock out authentication, password-reset, token and one-time-code endpoints; without it, credential stuffing is free.
- Generate tokens, ids and nonces with a cryptographically secure random source (`crypto.randomUUID`, `RandomNumberGenerator`, `secrets`), never `Math.random` or a seeded PRNG.
- Hash passwords with Argon2id, bcrypt or scrypt (PBKDF2 where FIPS compliance requires it). Use vetted crypto libraries; never roll your own.
## Data and logging
- Never log passwords, tokens, secrets, full card numbers or personal data (names, email addresses, postal addresses, national or government ID numbers). Log opaque identifiers instead.
- Return generic error messages with a correlation id; keep stack traces, SQL and internal paths in server logs only.
- Encrypt data in transit (TLS) and at rest, using platform-managed keys where the platform offers them.
- Collect and retain only the personal data the feature needs.
## Dependencies and builds
- Add dependencies only when needed, from official registries, with versions pinned by a committed lockfile.
- Check new packages for maintenance, licence and known vulnerabilities; fix high and critical findings before merging.
- Do not disable security checks, TLS validation, linters or scanners to make a build pass — no `--no-verify`, and no suppressed audit finding without a ticket recording the decision.
## When to ask a person
- Stop and ask a reviewer before changing authentication, authorisation, cryptography, secret handling, payment flows or personal-data processing.
- Ask before adding a new external service, widening network or firewall access, or granting new permissions.
- Say so clearly when you are unsure whether code is safe, or when a request would weaken an existing control, and route it to the team's security contact rather than guessing.
Go deeper: `backend-code-review`, `frontend-code-review` and `api-design` for the review checklists, plus the stack's development skill for the code you are changing.