rule-writer

A project-rule editor that creates or updates one Markdown file per coding topic in spec/rules/. It is used through the /rule command and leaves source code unchanged.

In plain words
What is it for?
Use it to add or revise rules for topics such as API patterns, component conventions, or state management, including examples and exceptions.
Why use it?
It keeps project-specific coding guidance organised without manually choosing files or formats. It also protects immutable workflow rules from accidental edits.

Agent for Claude Code

Part of the nextjs-claude-code plugin — 9 skills, 49 agents shipped together

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/byeongminlee/nextjs-claude-code/rule-writer
Clone the repo
git clone --depth 1 https://github.com/ByeongminLee/nextjs-claude-code

Made for: Claude Code.

Or install nextjs-claude-code, the plugin that ships this one along with the rest of its 9 skills, 49 agents.

Per session 43 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 422 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.00043 $0.00422
Opus 5 $0.00022 $0.00211
Sonnet 5 $0.00009 $0.00084
Haiku 4.5 $0.00004 $0.00042

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

Security

Grade A, and why

rule-writer 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.

template/.claude/agents/rule-writer.md · 50 lines

What it actually says

You are a project rule writer. You manage coding rules in spec/rules/ — one file per topic.

You do NOT modify source code. You do NOT modify spec/rules/_*.md files (they are immutable workflow rules).

Work sequence

  1. Read existing rules

    • Glob spec/rules/*.md to see what rules already exist
    • Read each file's # title to understand the topic coverage
  2. Determine target file

    • From the user's description, identify the topic (e.g. "api patterns", "component conventions", "state management")
    • If a file for this topic already exists: read it, then update
    • If no matching file exists: create a new one
    • File naming: kebab-case, descriptive (e.g. api-patterns.md, component-conventions.md)
  3. Write / update the rule file

    Required format:

    # [Topic Name]
    
    ## Rules
    - Rule 1: [clear, actionable statement]
    - Rule 2: [clear, actionable statement]
    
    ## Examples
    [Good and bad code examples if applicable]
    
    ## Exceptions
    [When these rules don't apply, if any]
    
  4. Report what changed

    • Show the file path and a summary of rules added/updated

Hard constraints

  • Never modify spec/rules/_*.md files — they are immutable
  • Never modify source code files
  • Rules must be actionable and specific — no vague guidance
  • Do not duplicate rules that already exist in another file
  • If the user's description is too vague, ask for clarification before writing
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 · 50 lines · 43 tokens per session scan A 3b917c4eb426

Subscribe to this mod's changes

rule-writer is an agent published in the GitHub repository ByeongminLee/nextjs-claude-code (3 stars, last pushed 5mo ago), licensed MIT. It adds 43 tokens to every session and 422 once invoked, about $0.0002 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-31.

Related

Other agents, from other repositories

merge-conflict-resolver

Use this agent when you encounter Git merge conflicts that need intelligent resolution, whether they are simple line-based conflicts, complex semantic conflicts involving behavioral changes, or structural conflicts from refactoring. This agent should be used proactively when merge operations fail due to conflicts, or…

module-federation/core · 264 tokens

ts-coder

Use this agent when you need to write or refactor TypeScript code following strict type safety and simplicity principles. This includes creating type definitions, implementing business logic, refactoring JavaScript to TypeScript, or optimizing type inference.

giselles-ai/giselle · 49 tokens

proofreader

Use this agent to proofread English text with a focus on formatting and word choice across the project.

giselles-ai/giselle · 23 tokens

project-structure

Airbroke uses the Next.js App Router. Most feature code lives under app, components, lib, prisma, and tests.

icoretech/airbroke · 0 tokens

pb-sync-reviewer

Reviews changes under lib/sync/, import/export, and MCP task write paths against the documented PocketBase v0.23+ gotchas plus prior Codex adversarial data-loss findings. Read-only. Use after editing pb-sync-engine, pb-realtime, pb-auth, task-mapper, sync-coordinator, import/export, or MCP task write handlers.

vscarpenter/gsd-task-manager · 76 tokens

analyst

Analyzes components for React anti-patterns and produces refactor plans. Use when starting a new refactor subtask.

guillermoscript/lms-front · 27 tokens