# Writing Secure Code — Client, Server & Browser Boundary

> Writes code that is secure by construction: injection-proof queries, safe rendering, sessions, CSRF/CORS/CSP and authZ.

Writing Secure Code — Client, Server & Browser Boundary is a free AI agent skill on Agensi by Cristhian Zanforlin Lousa, in Security. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Cristhian Zanforlin Lousa](https://www.agensi.io/creators/cristhian-zanforlin-lousa)
- Category: [Security](https://www.agensi.io/skills/security)
- Version: 1.1
- Last updated: 2026-11-25
- Security: scan passed (2026-11-25); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/writing-secure-code-client-server-browser-boundary
- Tags: security, code-review, secure-coding, appsec, owasp, xss, csrf, injection

## About this skill

**Writing Secure Code** is the build-time security skill: it shapes code while it is being written, so the defect never lands. It works with any language, framework or architecture (monolith, microservices, serverless, SPA, mobile or desktop). Library names in the rules are only examples of "your stack's equivalent".

**Problems it solves**
- String-built SQL and document-store filters that an attacker can restructure.
- `innerHTML` and framework raw-HTML escape hatches fed with user data.
- Tokens in `localStorage`, missing `SameSite`, reflected CORS origins.
- Queries not scoped by owner (BOLA/IDOR), and `403` responses that confirm an object exists.
- Open redirects that pass a "starts with `/`" check.
- SSRF through decimal or IPv4-mapped IPv6 addresses.
- Fast password hashes, and JWTs decoded but never verified.

**How it works.** Five invariants underlie every rule: data never becomes code; the server decides; validate early, encode late, sanitize only rich content; secrets stay server-side; fail closed. The workflow has four steps:

1. Name every trust boundary the change crosses.
2. Implement the rule for each crossing from the authoritative source, and test any library- or browser-specific behavior against your own version.
3. Write the abuse test next to the happy-path test.
4. Run a scope audit: fix defects in the lines you change, and report the rest.

It also sets defaults for when the project hasn't decided: `__Host-` session cookies, backend-for-frontend for OAuth, Argon2id, and a strict nonce-based CSP.

**References**
- `client.md`: every client, XSS sinks, frames and messages, mobile.
- `browser-boundary.md`: cookies, CSRF, CORS, CSP, headers.
- `server.md`: injection, authentication, tokens, authorization, SSRF, files and parsers, secrets, crypto, logging.
- `supply-chain.md`: dependencies and CI.
- `sources.md`: authorities, test-backed observations, and advice it rejects.

**When it triggers.** Whenever code touches user input, rendering, auth, cookies, permissions, queries, outbound URLs, uploads, secrets or a new dependency, even if nobody says "security".

Free and MIT-licensed. Part of the claude-skills-czl collection.

**Source on GitHub:** [this skill](https://github.com/Cristhianzl/claude-skills-czl/tree/main/configs/agnostic/skills/writing-secure-code) · [full repository](https://github.com/Cristhianzl/claude-skills-czl)

## Requires

- Git

## Known limitations

Language- and framework-agnostic rules, so library-specific behavior is checked by running small scripts against your versions. Abuse tests need your project's test runner. Risky rollouts (CSP, rate limits, cookies, row-level policies) follow the bundled report-only-first protocol.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Writing Secure Code — Client, Server & Browser Boundary skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### Does it work outside Claude Code?

Yes. It is a SKILL.md with Markdown references, and any compatible agent can use it. It was built and tested mainly on Claude Code.

### Does it change my code or run anything?

Yes. It writes the secure implementation and abuse tests for the change you're making, and runs your tests. It fixes security defects only in the lines you're changing and reports the others, instead of rewriting neighboring code.

### How is it different from security-review?

This skill is for writing code. `security-review` audits code that already exists, `threat-modeling` decides what to protect before building, and `reviewing-code` checks a diff against the same rules.

### How is it triggered?

Automatically when code touches user input, rendering, login, sessions, cookies, CORS/CSP, permissions, queries, outbound URLs, uploads, secrets, passwords or a new dependency. You can also ask for it directly ("secure this", "is this safe").

### How do I install it?

Unzip it into `~/.claude/skills/` to use it in every project, or into a project's `.claude/skills/` to use it in that repo only. Keep the folder named `writing-secure-code/` with its `shared/` folder inside.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
