refine-spec

refine-spec is a skill for Claude Code from kotaroyamame/formal-agent-contracts. It costs 90 tokens per session (6,171 once invoked), scanned A, original, MIT.

A specification-refinement guide helps turn an initial software specification into a confirmed description of what the system should do. VDM-SL is a formal language for describing software behavior precisely.

In plain words
What is it for?
It is for reviewing a provisional specification through questions, classifying findings, confirming requirements, and producing a structured findings report.
Why use it?
It helps uncover unstated assumptions, missing requirements, and differences between existing code and the user's intended behavior.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: positional $N argument.

Part of the formal-agent-contracts plugin — 15 skills shipped together

Good fit It is for reviewing a provisional specification through questions, classifying findings, confirming requirements, and producing a structured findings report.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kotaroyamame/formal-agent-contracts/refine-spec
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.

Any agent
npx skills add kotaroyamame/formal-agent-contracts --skill refine-spec
Clone the repo
git clone --depth 1 https://github.com/kotaroyamame/formal-agent-contracts

Made for: Claude Code.

Or install formal-agent-contracts, the plugin that ships this one along with the rest of its 15 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for refine-spec

README.md
[![agentmods](https://agentmods.dev/badge/skills/kotaroyamame/formal-agent-contracts/refine-spec/github.svg)](https://agentmods.dev/skills/kotaroyamame/formal-agent-contracts/refine-spec)
Your own site
<a href="https://agentmods.dev/skills/kotaroyamame/formal-agent-contracts/refine-spec"><img src="https://agentmods.dev/badge/skills/kotaroyamame/formal-agent-contracts/refine-spec/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for refine-spec

Your own site · 80×15
<a href="https://agentmods.dev/skills/kotaroyamame/formal-agent-contracts/refine-spec"><img src="https://agentmods.dev/badge/skills/kotaroyamame/formal-agent-contracts/refine-spec.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 90 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,171 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00090 $0.06171
Opus 5 $0.00045 $0.03086
Sonnet 5 $0.00018 $0.01234
Haiku 4.5 $0.00009 $0.00617

Measured 11d ago against content hash f73455b46e24, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

refine-spec 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 11d 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.

skills/refine-spec/SKILL.md · 928 lines

How it starts

The opening of the file, as written. The whole thing — 928 lines — stays where its author put it; the contents beside it link to each section on GitHub.

refine-spec: Specification Refinement Through Dialogue

Core Philosophy

The provisional specification is NOT the true specification. The true specification lives in the user's mind—as intentions, assumptions, and constraints they've never fully articulated. This skill surfaces it through structured dialogue.

Key insight: Every difference between code behavior and user intent is a "Finding"—the most valuable output of this process. We're not validating the provisional spec; we're using it as a scaffold to uncover what was actually intended.


Workflow Overview

Provisional Spec (from extract-spec)
    ↓
[STEP 1] Translate to natural language
    ↓
[STEP 2] Structured dialogue by category
    ├─ A: Questions (code seems wrong)
    ├─ B: Implicit specs (inferred from tests)
    ├─ C: Missing specs (no code exists)
    └─ D: Provisional confirmations (routine items)
    ↓
[STEP 3] Classify each dialogue result as Finding
    ↓
[STEP 4] Generate confirmed spec from Findings
    ↓
[STEP 5] Check convergence (all tagged items resolved)
    ↓
[STEP 6] Generate Findings Report (structured output)

STEP 1: Natural Language Translation

Purpose

Transform VDM-SL abstractions into plain language the user can evaluate without training in formal methods.

Process

  1. Extract elements from provisional spec:

    • State space (data structures, invariants)
    • Operations (pre/post conditions, behavior)
    • Rules and constraints
    • Implicit assumptions from tests/comments
  2. Translate each element into plain English + Japanese:

    • Avoid formal syntax; use concrete examples
    • Group related items logically
    • Include type information but keep language accessible
  3. Tag each item with confidence and source:

    [PROVISIONAL] {confidence: high|medium|low} {source: code|tests|comments}
    
    Example:
    [PROVISIONAL] {confidence: high} {source: code}
    When a customer requests a refund, their account balance increases by the refund amount.
    

Read the full file on GitHub · 928 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 11d ago First seen · 928 lines · 90 tokens per session scan A f73455b46e24

Subscribe to this mod's changes

refine-spec is a skill published in the GitHub repository kotaroyamame/formal-agent-contracts (1 stars, last pushed 2mo ago), licensed MIT. It adds 90 tokens to every session and 6,171 once invoked, about $0.0005 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.