Skip to content

nekocode/prompt-to-code-skill

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prompt-to-code

English | 中文

An Agent Skill that compiles the rules governing your coding agent — declared ones (CLAUDE.md, AGENTS.md, style guides) and ones revealed in conversation history — into deterministic enforcement written into your project's own toolchain: lint rules, pre-commit entries, slash commands, each shipped with a native test.

A remembered rule is a suggestion; a compiled check is a wall.

Why

Coding agents don't get better at collaborating over time: a preference stated in one session is violated in the next. Memory gives the agent access to a rule, but not compliance with it. Every time you repeat an instruction or correct the same mistake, you are paying interest on a rule that was never compiled. prompt-to-code moves rules from fluid prompts into solid code, so a correction made once never needs to be restated.

How it works

One stateless pipeline. Two intakes, one shared backend. All artifacts land in your project's native locations, under version control.

INTAKE    declared rules (CLAUDE.md/AGENTS.md, default)
          revealed rules (conversation history, opt-in — always asks first)
            ▼
SIGNAL    is it a durable rule? (correction > repetition > one-off)
            ▼
CLASSIFY  Tier A: native linter can check it        → lint rule
          Tier B: a deterministic tool can extract  → ast-grep/semgrep/gitleaks/script
          Tier C: irreducible judgment              → stays a prompt, honestly
            ▼
COMPILE   dedupe against existing config · pick backend on the reliability
          ladder (reuse > generate > toolbelt > script) · generate rule + a
          native test (≥1 pass, ≥1 fail) · self-test before writing
            ▼
EMIT      write into native locations, wire into real config
          (never auto-commits — the working-tree diff is the deliverable)
            ▼
ENFORCE   pre-commit (primary wall — git-native, host-agnostic)
          · CI if you already have it · failing checks re-prompt the agent

Key properties

  • The skill is a compiler, not a runtime. Everything it writes — rules, tests, hook wiring, even the engines (as your dev dependencies) — lives in your project and survives uninstalling the skill. That is the acid test.
  • Zero state. No registry, no config, no .prompt-to-code/ directory. The truth is the generated code and its git history. Re-runs stay safe via semantic dedup against your current config.
  • Honest about limits. Judgment rules ("keep functions cohesive") are never faked as brittle regex proxies — they stay prompts.
  • Every check ships with a native test (≥1 pass, ≥1 fail), placed with your other tests. It validates the rule at generation time and detects environment drift (linter upgrades, rule renames) forever after.
  • Guardrails are code, not model discipline. emit.py deterministically refuses writes outside the project root, silent overwrites, and any content matching a secret pattern. Conversation text is redacted at the intake boundary before anything else sees it.
  • Asks before the three decisions that are yours: introducing a new tool dependency, resolving conflicts with human-set config, and appending mined Tier C rules to CLAUDE.md (append-only, never edits existing lines).

Install

Via marketplace:

/plugin marketplace add nekocode/prompt-to-code-skill
/plugin install prompt-to-code

Local development / dog-fooding (no install needed):

cd /path/to/prompt-to-code-skill
claude --plugin-dir .

Compatibility

Requirement Version Notes
python3 ≥ 3.9 Standard library only, zero third-party deps. Works with the python3 preinstalled on stock macOS. On < 3.11 (no tomllib), pyproject.toml detection falls back to a header-only scan — same results for stack detection
git any modern release The generated artifacts rely on git for review/rollback; the scripts themselves never touch it
Claude Code any Plugin format. Other agent hosts can consume the generated enforcement (it's ordinary project code) — only the /prompt-to-code entry point is Claude-Code-specific

Use

Run the slash command in any project:

/prompt-to-code                          # default: compile declared rules (CLAUDE.md, AGENTS.md, ...)
/prompt-to-code also enforce "no print in src/"   # extra rules for this run
/prompt-to-code history only             # scope adjustments
/prompt-to-code warn severity for everything      # target constraints

The optional arguments refine a single run — extra rules to compile, scope ("only Python", "skip history"), or target constraints ("as pre-commit only"). Invariants always hold: it never auto-commits, never silently overwrites, asks before scanning history or adding a tool dependency.

Review the resulting diff like any other change. Maintenance is just editing code: downgrade a rule to warn by changing its severity value, delete a rule by deleting the code, ask "why does this exist?" via git blame.

Steady state: just re-run /prompt-to-code every once in a while. Semantic dedup against your current config makes re-runs safe — already-enforced intents are skipped, only new rules land.

Repository layout

.claude-plugin/       plugin + marketplace manifests
commands/
  prompt-to-code.md     the /prompt-to-code slash command (entry point)
skills/prompt-to-code/
  SKILL.md              the workflow (<200 lines)
  references/           judgment criteria the agent loads on demand
    taxonomy.md           signal detection + Tier A/B/C + severity/scope
    target-routing.md     picking the convergence target + enforcement layers
    check-patterns.md     per-backend "rule + native test" pair guidance
  scripts/              deterministic steps only — no LLM calls, stdlib only
    intake.py             declared-file scan (default) / history scan (opt-in), redacts
    detect_stack.py       detects your linters/toolbelt/hooks on the spot, never persisted
    emit.py               manifest-driven writes with hard guardrails (opt-in rule/test contract)
    selftest.py           runs a check's native test, reports pass/fail by exit code
    redact.py             shared secret redaction
  assets/patterns/      copyable rule+test templates per backend
tests/                full test suite for the scripts (100% coverage enforced)

Development

uv sync          # dev deps: pytest, pytest-cov, ruff
uv run pytest    # 99 tests, coverage gate at 100%
uv run ruff check skills tests
uv run ruff format skills tests

After editing commands/ or SKILL.md, run /reload-plugins inside the session for a hot reload. The runtime scripts stay standard-library-only by design; dev dependencies never ship with the plugin.

License

MIT. See .claude-plugin/plugin.json.

About

Compile CLAUDE.md rules and chat corrections into deterministic lint/hook/pre-commit enforcement.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors