Skip to content
Back to skills

Write Code

ASecurity

Edit source code for the current task. Delegates editing and lint/typecheck/self-repair to a subagent.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 7, 2026
developmentjavascripttypescriptpythongojavashellbashnodenodejs

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 25, 2026

npx -y skills add nirecom/agents --skill write-code --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Write Code?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Write Code
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nirecom-write-code/badge)](https://www.skillsdirectory.com/skills/nirecom-write-code)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: write-code
description: Edit source code for the current task. Delegates editing and lint/typecheck/self-repair to a subagent.
model: sonnet
user-invocable: false
---

Edit source code for the current task.

## Procedure

WCD-0. Read the session facts once, before the pre-launch steps that consume them: `node "$AGENTS_MAIN_ROOT/bin/workflow/read-session-facts" --session "$SESSION_ID"`
   - `PLANS_DIR=` (substitute for every `<PLANS_DIR>` below) and `GATE_CONFIRM_CODE=` (the WCD-2 gate: `ON`/`OFF`/`ERROR`).
   - If the command exits non-zero, or `PLANS_DIR=NONE`, stop — do not proceed with any step that uses `<PLANS_DIR>`; report via /supervisor-report; never construct a path like `NONE/<session-id>-...`.
When a hook blocks a sanctioned command, a fallback path is taken, or any unexpected outcome occurs, report via /supervisor-report (trigger conditions: rules/supervisor-reporting.md).
Read `rules/ops.md` before any destructive or system-state-changing command (including inside WCD-4 self-repair) — on-demand-only, never auto-injected; it owns the recovery-options-first decision path.

WCD-1. Read `rules/core-principles.md`, `rules/coding.md` and `rules/architecture-principles.md` (the latter two are on-demand-only: not auto-injected, so this Read is the only way they arrive), and the target files identified from the plan.

WCD-2. **CONFIRM_CODE gate** — enumerate planned edits (one line per file: path + change intent).
   - Write every file you plan to edit, one path per line (repo-relative, nothing else on the line), to `<PLANS_DIR>/<session-id>-write-code-files.txt` with the Write tool.
   - Keep that list complete: it is the sole input of the S1b and S4 signals judged in WCD-3.
   - Then branch on `GATE_CONFIRM_CODE` from WCD-0 — `OFF`: proceed to WCD-3; `ON` or `ERROR`: present the planned edits via `AskUserQuestion` (`metadata.source=write-code.edit-plan-approve`) and wait for approval before continuing.

WCD-3. Always follow `skills/_shared/jev-two-stage-judge.md` with point=`complexity-judge` stage=`write-code` (S1b and S4 come only from the WCD-2 list, so no stored evaluation is reused); use its `model=` and `SIGNALS_CSV` — never judge the level inline.
   Emit in Claude text output (NOT Bash echo): `> Model selected: **<model alias>** (signals: [comma-separated triggered signal IDs, or "none"])`
WCD-3a. Emit `echo "<<WORKFLOW_MARK_STEP_write_code_in_progress>>"` via Bash immediately before the WCD-4 subagent launch.

WCD-4. **Launch subagent** (`Agent` tool, `mode: "default"`, `model: <model alias from WCD-3>` — the model alias, never the level `high` / `low`) with a prompt containing:
   - Target files and planned edit summary from WCD-2.
   - A-layer language essence block (see below).
   - Directive: "Read `rules/coding.md` (the hub — on-demand-only, so it does not reach you otherwise) and `rules/coding/<lang>.md` for each language present, before the first Edit."
   - Directive: "Read `rules/architecture-principles.md` before adding or changing a guard, gate, or check — on-demand-only, so it does not reach you otherwise."
   - Directive: "Read `rules/shell-commands.md` before the first Bash command, or before writing a file — general-purpose dispatch does not inherit auto-injected rules."
   - The canonical line of the `rules/shell-commands.md` Subagent Dispatch Prompts section, verbatim as a standalone line, with `<AGENTS_MAIN_ROOT>` replaced by the literal absolute path.
   - Directive: "Read `rules/user-escalation.md` before any system-state-changing command — general-purpose dispatch does not inherit auto-injected rules."
   - Directive: "Read `rules/ops.md` before any destructive or system-state-changing command inside self-repair — general-purpose dispatch does not inherit auto-injected rules; on-demand-only, so it does not reach you otherwise."
   - (Optional) Follow `skills/_shared/nfr-severity-calibration.md` to obtain the PROJECT NFR block and use it as an implementation constraint when relevant.
   - Lint/typecheck recipe table (see below).
   - Self-repair cap: 3 iterations; if still failing after 3, surface tool output verbatim.
   - Lint-tool absence policy: when a tool is unavailable, skip that check AND emit `<tool> not found — check skipped` in the final summary. Never omit this notice.
   - Scope-expansion policy: if editing reveals additional files not in the original list need changes, include them in the final summary with a reason. Do NOT prompt mid-edit; do NOT silently expand scope.
   - Prohibitions: no diffs shown in the conversation; no mid-edit confirmation prompts.
WCD-5. Parse the subagent summary. Surface tool output on failure. Collect all `check skipped` notes and scope-expansion notes.

WCD-5a. Run `skills/write-code/scripts/self-check-siblings.sh "<what changed>" "<why>"` — CPR-E2C sibling-sweep reminder.
WCD-5b. Run `skills/write-code/scripts/detect-contract-pins.sh <edited-files>` — flag edited files with no matching test; fold into WCD-6.

WCD-6. Present the final edited file list + skipped-check notes + scope-expansion notes to the user — gated by **CONFIRM_CODE gate (post-action review)**:
   Gate check: apply skills/_shared/confirm-plan.md CPA-3 — run next-step --gate and follow GATE_ACTION.
   - `GATE_ACTION=proceed`: skip WCD-6; proceed (no user wait).
   - `GATE_ACTION=ask`: present the file list and notes; record each per `skills/_shared/handoff-record.md` (`--step write_code`; `--class E --key write-code:checks-skipped` / `--class D --key write-code:scope-expansion`).

WCD-7. Stage the implementation files so the write_code snapshot sees them: `node "$AGENTS_MAIN_ROOT/bin/stage-review-scope-files.js" --worktree "<cwd>" -- <WCD-5 edited files>`
   - Exit non-zero: stop — do not emit the completion sentinel; report via /supervisor-report.

## A-layer language essence (complement of B-layer — zero overlap with `rules/coding/*.md`)

- **Python:** read `rules/coding/python.md` before the first Python Edit. All Python invariants (including modern type syntax) are owned by the B-layer.
- **Node/JavaScript:** read `rules/coding/nodejs.md` before the first JS Edit. All Node invariants (including module-system guidance) are owned by the B-layer.
- **TypeScript** (B-layer in `rules/coding/nodejs.md`; items below are writing-moment additions not in B-layer): discriminated union over loose interface; explicit return types on exported functions.
- **PowerShell** (no B-layer file): approved verbs; `$ErrorActionPreference = 'Stop'`; `Set-StrictMode -Version Latest`; full cmdlet names; `$env:VAR` for env vars.
- **Bash** (no B-layer file): `set -euo pipefail`; `[[ ]]` over `[ ]`; quote variable expansions; `$(...)` over backticks; `${var:?error}` for required vars.
- **JSON** (no B-layer file): double-quoted keys/strings; no trailing commas; no comments; 2-space indent.
- **YAML** (no B-layer file): 2-space indent; no tabs; quote ambiguous scalars; block style for multi-line strings.

When a new standalone B-layer file is added for a language that currently has only A-layer content (PowerShell, Bash, JSON, YAML), that language's entry collapses to a bare read-directive. Test `p` in `tests/skills/feature-write-code-skill-static.sh` enforces SSOT non-duplication for module-system guidance tokens at CI.

## Lint/typecheck recipes

| Language | Command |
|---|---|
| Python | `uv run ruff check <file>` |
| JavaScript | `node "$AGENTS_MAIN_ROOT/bin/run-eslint" <file>` |
| TypeScript | `node "$AGENTS_MAIN_ROOT/bin/run-eslint" <file>` + `npx tsc --noEmit` |
| PowerShell | `pwsh -NoProfile -Command Invoke-ScriptAnalyzer -Path <file>` |
| Bash | `shellcheck <file>` |
| JSON | `node -e "JSON.parse(require('fs').readFileSync('<file>','utf8'))"` |
| YAML | `uv run python -c "import yaml,sys;yaml.safe_load(open(sys.argv[1]))" <file>` |

Each is best-effort: if the tool or config is absent, skip AND emit `<tool> not found — check skipped`.

## Rules

- Mode-orthogonal: behavior is identical regardless of worktree mode. Do not show diffs in the conversation.
- Never edit test files — `/write-tests` owns them.
- Follow `skills/_shared/combined-glossary.md` (writer directives); put this same line in the implementing subagent's prompt.
- Subagent self-repair cap: 3 iterations.
- Report observations via /supervisor-report (trigger conditions: rules/supervisor-reporting.md).

## Completion

Emit `echo "<<WORKFLOW_MARK_STEP_write_code_complete>>"` via Bash after WCD-7 exits 0; skip it when the subagent failed or the WCD-6 review was rejected — fix the work and re-run WCD-4 first.
Then run `node "$AGENTS_MAIN_ROOT/bin/workflow/next-step" --session "$SESSION_ID"` and follow its ACTION — it routes to /review-tests when write_code changed the review scope.
When /review-tests is reopened and the user decides to stop, emit WORKFLOW_REVIEW_TESTS_WARNINGS_ACCEPTED (procedure: skills/review-tests/SKILL.md).
Never emit WORKFLOW_REVIEW_TESTS_COMPLETE manually.

Files in this skill

  • SKILL.md8.7 KB
  • scripts/detect-contract-pins.sh2.1 KB
  • scripts/self-check-siblings.sh1.4 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.