Code Standards

A set of English-language coding standards for clean code, safe changes, refactoring, and testing.

In plain words
What is it for?
Use it for implementation planning, code reviews, refactoring, regression tests, error handling, logging, and changes involving callers, configuration, or external systems.
Why use it?
It gives developers rules for understanding a codebase before editing it, comparing options, validating inputs, limiting complexity, and testing changes.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/jsk9999/ai-nexus/code-standards
Clone the repo
git clone --depth 1 https://github.com/JSK9999/ai-nexus
Per session 16 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 759 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00016 $0.00759
Opus 5 $0.00008 $0.00380
Sonnet 5 $0.00003 $0.00152
Haiku 4.5 $0.00002 $0.00076

Measured 2d ago against content hash 7eb17b955a13, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

Code Standards scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

config/agents/code-standards.md · 82 lines

What it actually says

AGENTS.md

Problem Definition → Small Safe Changes → Change Review → Refactoring — Repeat this loop.

Mandatory Rules

Read related files from start to finish, including call/reference paths, before changing anything.
Keep work, commits, and PRs small.
Record assumptions in Issues/PRs/ADRs.
Validate all inputs and encode/normalize outputs.
Avoid premature abstraction and use intention-revealing names.
Compare at least two alternatives before deciding.

Mindset

Think like a senior engineer.
Don't jump to conclusions or rush into assumptions.
Always evaluate multiple approaches, write one line each for pros/cons/risks, then choose the simplest solution.

Code & File Reference Rules

Read files thoroughly from start to finish (no partial reading).
Before changing code, find and read definitions, references, call sites, related tests, docs/config/flags.
Don't change code without reading the entire file.
Before modifying symbols, use global search to understand pre/post conditions and document impact in 1-3 lines.

Required Coding Rules

Write Problem 1-Pager before coding: Background / Problem / Goals / Non-Goals / Constraints.
Follow limits: File ≤ 300 LOC, Function ≤ 50 LOC, Parameters ≤ 5, Cyclomatic Complexity ≤ 10. Split/refactor if exceeded.
Prefer explicit code; prohibit hidden "magic".
Follow DRY but avoid premature abstraction.
Isolate side effects (I/O, network, global state) to boundary layers.
Handle only specific exceptions and provide clear messages to users.
Use structured logging and don't record sensitive data (propagate request/correlation IDs when possible).
Consider timezones and DST.

Testing Rules

Add new tests for new code; bug fixes must include regression tests (write to fail first).
Tests should be deterministic and independent; replace external systems with fakes/contract tests.
E2E tests must include ≥1 success path and ≥1 failure path.
Proactively assess risks from concurrency/locks/retries (duplicates, deadlocks, etc.).

ABSOLUTE Security Rules

NEVER: Leave secrets (passwords/API keys/tokens) in code/logs/tickets/environment variables/.env files.
NEVER: Log sensitive data (PII/credit cards/SSN) in logs.
NEVER: Leave SQL injection, XSS, CSRF vulnerabilities.
ALWAYS: Validate, normalize, and encode all inputs; use parameterized queries.
ALWAYS: Use HTTPS/TLS and apply principle of least privilege.
ALWAYS: Apply authentication/authorization to all endpoints.
ALWAYS: Set security headers (CSP, HSTS, X-Frame-Options).
ALWAYS: Regularly scan and update dependency vulnerabilities.
Stop work immediately and request review upon security violations.

Clean Code Rules

Use intention-revealing names.
Each function does one thing.
Isolate side effects to boundary layers.
Prefer guard clauses.
Always symbolize constants (no hardcoding).
Structure code as Input → Processing → Return.
Report failures with specific errors/messages.
Make tests work as usage examples and include boundary/failure cases.
Never add useless emojis.

Anti-Pattern Rules

Don't modify code without reading full context.
Don't expose secrets.
Don't ignore failures or warnings.
Don't introduce unfounded optimizations or abstractions.
Don't abuse broad exceptions.
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 82 lines · 16 tokens per session scan A 7eb17b955a13

Subscribe to this mod's changes

Code Standards is an agent published in the GitHub repository JSK9999/ai-nexus (18 stars, last pushed 5mo ago), licensed Apache-2.0. It adds 16 tokens to every session and 759 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.