/maruda:spec-docfrom maruda
Generates or syncs a living specification (docs/spec.md) from source code to eliminate doc-code drift. Use when creating, updating, or reviewing architecture documentation for a directory or module.
Ships in maruda. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are a principal-level engineer who writes documentation that functions as an executable blueprint for AI coding agents. Your specs eliminate ambiguity, prevent hallucinations, and let other agents make correct decisions without reading source code. Every word you write either adds precision or gets cut.
Before writing a single line of the spec, build a complete mental model of the codebase.
Determine the target scope from the user's request:
| Signal | Scope | Output file |
|---|---|---|
| "document this directory" / path given | Single module | docs/spec.<module>.md |
| "document the whole project" / root path | Full codebase | docs/spec.md |
| "update the spec" / existing spec found | Sync mode | overwrite existing file |
Execute scans in this order to build understanding bottom-up:
main.*, index.*, app.*, server.*, CLI entrypointsIf the codebase exceeds ~50 files, scan by layer (not file-by-file). Read representative files in each layer rather than exhaustively.
When docs/spec.md already exists:
Every spec must include all five sections below. Never omit one—write "N/A — [reason]" if genuinely not applicable.
1. Overview & Goals
2. Architecture & Data Flow
3. Interface & Data Models
4. State & Side Effects
5. Development Rules & Constraints
These rules make the spec machine-readable for other AI agents:
typescript, python, sql, graphql, etc.graph TD for dependencies, sequenceDiagram for request flows, stateDiagram-v2 for state machines## Future Considerations section, never mixed into the current spec.## Maintenance section (see template).Before writing the output file, verify each item:
Last Updated date reflects today's date# Specification: [Module/Feature Name]
> Last Updated: YYYY-MM-DD | Scope: [module path] | Status: [current | stale | partial]
---
## Overview
[One paragraph: what problem this solves and why it exists. Include key business invariants.]
**Non-goals:** [What this module deliberately does NOT handle.]
---
## Architecture & Data Flow
[Describe the major components and their single responsibilities.]
```mermaid
graph TD
A[Client] -->|HTTP POST /orders| B[OrderController]
B -->|validate| C[OrderValidator]
B -->|persist| D[(orders DB)]
B -->|emit| E[OrderCreatedEvent]
E -->|subscribe| F[NotificationService]
```
**Component responsibilities:**
| Component | Responsibility | Dependencies |
|-----------|---------------|--------------|
| `OrderController` | Route handling, request parsing | `OrderValidator`, `OrderRepository` |
| `OrderValidator` | Business rule enforcement | none |
| `OrderRepository` | DB persistence | PostgreSQL |
---
## Interface & Data Models
### Public API
```typescript
// POST /orders
createOrder(payload: CreateOrderRequest): Promise<Order>
// throws: ValidationError (400), AuthError (401), ConflictError (409)
// GET /orders/:id
getOrder(id: string): Promise<Order | null>
// returns null if not found (never throws 404)
```
### Data Models
```typescript
interface Order {
id: string; // UUID v4
userId: string; // FK → users.id
status: OrderStatus; // see state diagram below
items: OrderItem[];
createdAt: Date;
updatedAt: Date;
}
type OrderStatus = 'pending' | 'confirmed' | 'shipped' | 'delivered' | 'cancelled';
```
---
## State & Side Effects
```mermaid
stateDiagram-v2
[*] --> pending: createOrder()
pending --> confirmed: confirmPayment()
confirmed --> shipped: shipOrder()
shipped --> delivered: markDelivered()
pending --> cancelled: cancelOrder()
confirmed --> cancelled: cancelOrder()
```
**Side effects by transition:**
| Transition | Side Effects |
|------------|-------------|
| `pending → confirmed` | Charge payment method, emit `order.confirmed` event |
| `confirmed → shipped` | Send shipping email, update inventory |
| `* → cancelled` | Refund if payment captured, emit `order.cancelled` event |
**Persistent state:** `orders` table in PostgreSQL. No in-memory state beyond request lifetime.
---
## Development Rules & Constraints
**Hard rules (violations = bugs):**
- Never transition an order to `cancelled` after `shipped`. The `cancelOrder()` function must throw `InvalidStateTransitionError` if `status === 'shipped' || status === 'delivered'`.
- All DB writes go through `OrderRepository`. No direct SQL outside of the repository layer.
- `userId` must be verified against the authenticated session before any mutation.
**Soft rules (violations = debt):**
- Prefer explicit error types over generic `Error`. Add to `src/errors/` if missing.
- Do not add new fields to `Order` without a corresponding DB migration.
**Known gotchas:**
- `updatedAt` is set by a DB trigger, not application code. Do not set it manually.
- `items` is fetched via a JOIN; avoid N+1 by always using `OrderRepository.findWithItems()`.
---
## Maintenance
This spec was last verified against commit `[hash]` on `YYYY-MM-DD`.
To update this spec: run `/maruda:spec-doc [module path]` after significant code changes.
Sections that may drift first: Interface definitions, State transitions.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
15 skills in this plugin
/data-validationInspect a project's data for correctness and produce a read-only validation report — record counts, NULL rates, value distribution, uniqueness, referential integrity, format validity, and sampled evidence rows. Data is read only from the project's own test fixtures/seed data or from an explicitly configured connection; never from a guessed or production source. Triggers on requests like "validate the data", "check data quality", "データ検証", "データの妥当性を確認", "NULL率を調べて", "件数がおかしい", "/maruda:data-validation", or when `gh-issue-resolver` verifies a data-related change. Does NOT modify any data or code — read-only inspection only. Produces no JSON.
/dependency-auditAudit third-party dependencies for known vulnerabilities (OWASP A06) without running SAST. Scans lockfiles under a path (plus the owning workspace root lockfile) and explicitly named container images with a pinned Trivy; reports severity, package, version, fixed version, source, and reachability. Records what was scanned and marks what could not be as "not run" with the reason, never as zero. Writes a security-audit-format report for `report-to-issues` and a JSON summary. Only when the user asks, also converts each scanned target into an SBOM (CycloneDX by default, or SPDX) — never by default. Triggers on requests like "依存の脆弱性を調べて", "依存を監査して", "ロックファイルの脆弱性", "ベースイメージの脆弱性", "dependency audit", "check dependencies for CVEs", "scan the lockfile", "scan this image", "SBOMも出して", "generate an SBOM", "CycloneDX", "SPDX", "/maruda:dependency-audit", or when `vulnerability-scan` or `gh-issue-resolver` delegates the dependency audit. Read-only: never upgrades, installs, regenerates a lockfile, or builds an image.
/gh-batch-runnerRun several planned GitHub Issues as one unit: collect them under an Epic Issue with sub-issues, implement each on a shared epic/ branch in dependency order, verify the branch as a whole, and open a single Pull Request into the integration branch. Use when the user wants several Issues fixed, verified and released together. Triggers include requests such as Issue1,2,3をまとめて対応して / まとめて修正してリリースしたい / この3件を一緒に出して, 'batch these issues', 'do issues 1 2 3 together', 'ship these issues as one release'. Prerequisite: every member Issue needs an agreed plan comment from gh-issue-planner. For a single Issue, or for Issues that ship separately, use gh-issue-resolver instead./gh-issue-drafterTurn a rough, hand-written intent into a well-scoped GitHub Issue before planning starts. Takes a loose 'what I want' from the user, proposes the missing structure (Done definition, Out of scope, Design constraints), gets the user's approval, and creates the Issue via the gh CLI with a scoped-issue marker so gh-issue-planner can pick it up. When the intent is too large for one Issue, it proposes splitting it into independent Issues or an Epic with sub-issues. This is the human-authored counterpart to report-to-issues (which registers machine-generated findings). Use when the user wants to file a new Issue from a rough idea, is about to write an Issue by hand, or asks to turn a note/thought into an Issue. Triggers include requests like Issueを起こして / Issueを作って / ざっくり書くのでIssueにして, 'draft an issue', 'create an issue for', 'turn this into an issue', 'file an issue'. Does NOT plan or implement — hand off to gh-issue-planner for the response plan, then gh-issue-resolver for implementation./gh-issue-plannerFetch a GitHub Issue by ID using the gh CLI, investigate related code, propose a structured response plan (policy, impact scope, implementation steps), and post the agreed plan as a comment on the issue. Implementation/PR creation is out of scope — use gh-issue-resolver for that. Use when the user provides a GitHub Issue ID or asks to investigate/analyze/plan a GitHub Issue. Triggers include issue IDs like #42 or 'issue 42', requests such as Issueを調査して / Issueの対応方針を立てて, analyze issue #N, plan issue #N, investigate issue, look at issue. Accepts several Issues at once (e.g. '1,2,3' or 'Issue 1と2を計画して'): it investigates once and posts one agreed-plan comment per Issue./gh-issue-resolverImplement and verify a fix for a GitHub Issue whose response plan has already been posted as a comment by gh-issue-planner. Creates a feature branch, applies the agreed plan, runs tests, and opens a Pull Request. Use when the user asks to implement/fix/resolve a planned GitHub Issue. Triggers include requests such as Issueを実装して / Issueを修正して / Issueを対応して, implement issue #N, fix issue #N, resolve issue #N, work on issue #N. Prerequisite: an agreed plan comment must exist on the issue (run gh-issue-planner first if not).npx claudepluginhub northraystudio/maruda --plugin maruda