secure-coding skill
Enforces security-conscious coding practices including input validation, injection prevention, and secrets management during code generation.
- GitHub stars
- 211
- Files
- 2
- Last commit
- Oct 24, 2026
- License
- MIT
- Allowed tools
- —
What does the secure-coding skill do?
secure-coding enforces security-conscious coding practices including input validation, injection prevention, and secrets management during code generation.
Summary generated from the skill's SKILL.md.
About the secure-coding skill
Applying security-conscious thinking during code generation is what this skill enables for developers. It focuses on maintaining a strong security posture by enforcing trust boundary awareness, input validation, and injection prevention. When an agent is tasked with handling user input, authentication, database queries, or external APIs, it should load this skill to ensure the resulting code adheres to safety standards like OWASP principles.
This skill is automatically integrated into code-generating molecules such as code-forge, refactor-safely, and bug-fix. It operates by running a self-validation checklist and an active anti-pattern scan to catch issues like hardcoded secrets, SQL string concatenation, and overly broad permissions. Unlike architecture or clean-code skills, this tool specifically governs the security of the code, such as ensuring error messages do not leak internal stack traces or file paths.
Developers can customize security standards through a .lattice/config.yaml file. This allows for overriding or overlaying default security documents and adapting error handling patterns to specific language idioms. The skill produces code that prioritizes defense-in-depth and least privilege authorization.
What an agent can do with it
- 1Secure code generationGenerate new code components that handle external user input while maintaining strict trust boundaries.
- 2Vulnerability scanningPerform a security review on existing code to identify potential injection or authorization flaws.
- 3Secrets management enforcementIdentify and remove hardcoded API keys or passwords from a codebase.
- 4Custom security standardsApply project-specific security rules by configuring a custom document in the repository root.
Written from the skill's SKILL.md. Every use case is checked against a quote from it.
How to install the secure-coding skill
Each command copies the skill folder into the client's skills directory. Restart the client or start a new session to load it.Install the secure-coding skill in Plugin
/plugin marketplace add techygarg/lattice /plugin install lattice@lattice
Install the secure-coding skill in Claude Code
~/.claude/skills/secure-coding/SKILL.md
$ npx degit techygarg/lattice/skills/secure-coding ~/.claude/skills/secure-codingInstall the secure-coding skill in Claude Code (project)
.claude/skills/secure-coding/SKILL.md
$ npx degit techygarg/lattice/skills/secure-coding .claude/skills/secure-codingInstall the secure-coding skill in Codex
~/.agents/skills/secure-coding/SKILL.md
$ npx degit techygarg/lattice/skills/secure-coding ~/.agents/skills/secure-codingInstall the secure-coding skill in Gemini CLI
~/.gemini/skills/secure-coding/SKILL.md
$ npx degit techygarg/lattice/skills/secure-coding ~/.gemini/skills/secure-codingInstall the secure-coding skill in Claude.ai
npx degit techygarg/lattice/skills/secure-coding secure-coding && zip -r secure-coding.zip secure-coding # claude.ai → Customize → Skills → + → Create skill → Upload a skill → secure-coding.zip
SKILL.md
View on GitHubSecure Coding
Config Resolution
Projects can customize this skill's standards. Resolution order:
- Read
.lattice/config.yamlin the repo root. - If found, check
paths.secure_codingfor a custom document path. - If a custom document exists at that path, read it and check its YAML frontmatter for
mode:mode: override: the custom document has full precedence. Use it instead of the embedded defaults. It must be comprehensive -- treat it as the sole reference.mode: overlay(or no mode field): read the embedded./references/defaults.mdfirst, then apply the custom document's sections on top. A custom section replaces the matching default section (matched by exact heading); new sections append after the defaults.
- If a custom path is configured but no document exists at it → tell the user which configured path is missing, then fall back to
./references/defaults.md. - If there is no config file or no
paths.secure_codingkey, read./references/defaults.md. - Language adaptation: if
paths.language_idiomsis set in the config and the document exists, read its "Error Handling" section and adapt §2 (Input Validation Patterns) error-message patterns to the language's idioms. Language idioms take precedence over the pseudocode defaults.
Self-Validation Checklist
STOP after generating each component. Verify ALL checks before proceeding. A check clearly fails → fix the code before presenting. A check is a judgment call with multiple valid approaches (see Ambiguity Signals) → flag it -- present options and reasoning rather than silently choosing.
- TRUST BOUNDARIES: Where does trusted code meet untrusted data? Are all boundaries explicitly identified?
- INPUT VALIDATION: Is every external input validated at the boundary with an allowlist before it reaches business logic?
- QUERY SAFETY: Are all database queries parameterized? Is any string concatenation used in query building?
- COMMAND SAFETY: Is there any shell/command execution? If so, is the input strictly allowlisted?
- SECRETS: Are there API keys, passwords, tokens, or connection strings in code? If so → move them to environment variables or a secret manager.
- OUTPUT ENCODING: Is output encoded appropriately for its render context (HTML, JSON, URL)?
- AUTHORIZATION: Is authorization verified at the service layer, not just the controller? Does every endpoint enforce least privilege?
- ERROR MESSAGES: Do error messages exposed to users avoid revealing internal detail (stack traces, SQL queries, file paths)?
- DEPENDENCIES: Is each new third-party package necessary? Are versions pinned or constrained? Is any known-vulnerable package being added?
All checks pass → state "Passes secure-coding. [next step]."
Active Anti-Pattern Scan
STOP: After verifying the checklist above, scan the output for each anti-pattern below. Any box you can check → fix before presenting the code.
- Trust All Input: no validation on request parameters; data flows straight into business logic → validate at the boundary with an allowlist.
- SQL String Concatenation: user input interpolated into a SQL query → use a parameterized query or ORM query builder.
- Hardcoded Secrets: API key, password, or token in source code → use an env var or secret manager.
- Missing Authorization: auth checked at login but not re-verified at the service or resource level → check at every layer.
- Overly Broad Permissions: admin access granted where read-only suffices → apply least privilege.
- Unvalidated Redirects: a user-controlled URL used in a redirect → allowlist permitted destinations.
- Verbose Error Messages: stack trace or SQL in an API response → return a generic message; log details server-side.
- Logging Sensitive Data: passwords, tokens, or PII in log files → log the event, not the value; mask sensitive fields.
Ambiguity Signals
Checks here often have multiple valid outcomes. When you encounter one, present the options rather than silently choosing. If framework:collaborative-judgment is loaded, use its presentation format.
- Trust Boundary Scope: an internal API behind a trusted gateway may or may not need full boundary validation.
- Error Message Detail: how much detail is "actionable but safe" depends on whether the consumer is a human user, a frontend client, or an internal service.
- Validation Depth: whether to re-validate at inner layers (defense-in-depth) or trust boundary validation alone.
- Auth vs Authz Failure Response: whether to return 401 (not authenticated) or 403 (not authorized) depends on whether the identity is known.
Core Principle
Govern the security posture of generated code -- trust boundaries, input validation, injection prevention, secrets, authorization.
Boundary with clean-code: clean-code governs error-message craft; this skill governs what error messages must not reveal (internal detail).
Boundary with architecture: architecture defines where checks live (service layer, not controller); this skill defines what to check (identity confirmed, permission granted, resource owned).
See ./references/defaults.md.
Files in this skill
2secure-coding skill questions
How do I install the secure-coding skill in Claude Code?
Run npx degit techygarg/lattice/skills/secure-coding ~/.claude/skills/secure-coding. Claude Code loads skills from ~/.claude/skills (all projects) or .claude/skills (one project) and uses a skill when its description matches the task.
Which clients can use the secure-coding skill?
Any client that reads the Agent Skills format: Claude Code, Codex, Gemini CLI and claude.ai (upload as a ZIP). Scripts in the skill run only where the client allows code execution.
What does the secure-coding skill cover?
It governs the security posture of generated code, focusing on trust boundaries, input validation, injection prevention, secrets management, and defense-in-depth authorization.
How can I customize the security standards for my project?
You can customize standards by creating a .lattice/config.yaml file in your repo root and specifying a custom document path under paths.secure_coding.