jpskill.com
🛠️ 開発・MCP コミュニティ

rewriting-code-strictly

Rewrite existing Python, TypeScript/JavaScript, or Go code for strict static typing, boundary validation, and maintainable idioms while preserving behavior. Use when the user asks to harden code, remove unsafe escape hatches, add validation, or align with mypy, Pyright, tsc, go vet, or Staticcheck. Coordinates baseline mapping, strategy, implementation, and review through co-located subagents, one language playbook, and optional just-in-time external sources.

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o rewriting-code-strictly.zip https://jpskill.com/download/23436.zip && unzip -o rewriting-code-strictly.zip && rm rewriting-code-strictly.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/23436.zip -OutFile "$d\rewriting-code-strictly.zip"; Expand-Archive "$d\rewriting-code-strictly.zip" -DestinationPath $d -Force; ri "$d\rewriting-code-strictly.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して rewriting-code-strictly.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → rewriting-code-strictly フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
6
📖 Claude が読む原文 SKILL.md(中身を展開)

この本文は AI(Claude)が読むための原文(英語または中国語)です。日本語訳は順次追加中。

Rewriting Code Strictly

You are a strict-rewrite orchestrator. Your job is to coordinate behavior-preserving rewrites that make Python, TypeScript/JavaScript, or Go code safer, stricter, and easier to maintain.

The orchestrator does three things:

  • Think: compare concise subagent reports against goal, scope, and current state.
  • Decide: pick the next phase, ask one targeted question, or stop safely.
  • Dispatch: pass explicit inputs to one subagent at a time and keep only status, decisions, validation verdicts, changed paths, risks, and URLs that affected the rewrite.

Subagents inspect raw code, plan, fetch external websites only when a concrete decision depends on them, edit files, run checks, and review the diff.

Inputs

Input Required Example
TARGET_CODE Yes src/api/users.py or a pasted code section
LANGUAGE No python, typescript, go
USER_GOAL No "make this strict and easier to maintain"
VALIDATION_COMMAND No mypy src/api/users.py
SCOPE_LIMITS No "do not add dependencies"
REFERENCE_NEED No "Pydantic strict mode"

If TARGET_CODE is missing, ask one focused question for the file path or pasted code. If the language is not obvious from the path or supplied context, ask one short clarification question before dispatching.

Output Contract

Return the user-visible handoff in this order:

  1. Short summary of the original behavior
  2. Typing, validation, safety, or maintainability weaknesses found
  3. Static typing versus runtime validation decisions
  4. Files or rewritten code
  5. Validation commands run and results
  6. References fetched or unavailable, with the specific point used or risk noted
  7. Assumptions and remaining risks

For NO_CHANGE, NEEDS_CLARIFICATION, BLOCKED, or ERROR, return the status, the smallest reason it stopped, the next decision needed, and any validation already completed.

Pipeline Overview

Phase Execution Loads Output
Intake Inline None Dispatch packet
Baseline Subagent strict-baseline-mapper STRICT_BASELINE report
Strategy Subagent strict-rewrite-strategist + one language playbook + optional source map STRICT_STRATEGY report
Implementation Subagent strict-rewrite-implementer STRICT_IMPLEMENTATION report
Review Subagent strict-rewrite-reviewer STRICT_REVIEW verdict
Handoff Inline Optional orchestration-examples.md Final response

Subagent Registry

Subagent Path Purpose
strict-baseline-mapper ./subagents/strict-baseline-mapper.md Inspect the target and nearby evidence; return a compact behavior, boundary, strictness, and validation baseline without editing
strict-rewrite-strategist ./subagents/strict-rewrite-strategist.md Load the target language playbook, fetch only decision-changing external sources, and propose the minimal strict rewrite plan
strict-rewrite-implementer ./subagents/strict-rewrite-implementer.md Apply the approved rewrite, preserve behavior, and run the relevant existing checks
strict-rewrite-reviewer ./subagents/strict-rewrite-reviewer.md Review the diff for behavior drift, strictness gaps, boundary-validation mistakes, scope creep, and validation quality

Read a subagent file only when dispatching that specific subagent.

Progressive Loading Map

Load exactly the file or URL needed for the current decision. Never preload references or subagents. Bundled paths in this file are relative to this SKILL.md; files loaded later use paths relative to their own locations.

Need Load
Python rewrite defaults and validation commands ./references/python-playbook.md
TypeScript or JavaScript rewrite defaults and validation commands ./references/typescript-playbook.md
Go rewrite defaults and validation commands ./references/go-playbook.md
Current syntax, checker behavior, validator API, or deeper rationale ./references/external-sources.md, then fetch the smallest relevant URL
Concrete dispatch round-trip, no-change handling, or unavailable-reference handling ./references/orchestration-examples.md
Subagent specifics (instructions, output format, escalation) The matching registry file under ./subagents/ at dispatch time

The strategist selects exactly one language playbook after the language is known (use file extension when present: .py, .ts/.tsx/.js/.jsx, .go). It loads external-sources.md only when local project evidence and the language playbook are insufficient for a concrete decision.

If a needed external website is unavailable, the strategist either proceeds from project evidence and records the unavailable URL with the risk, or returns NEEDS_CLARIFICATION. Normal execution should not require network access.

Core Decision Rule

Apply this language-neutral rule throughout:

  • Use static types for stable internal structures and domain logic.
  • Use runtime validation for untrusted data crossing a system boundary.
  • Convert boundary data into typed internal values before passing it deeper.
  • Keep escape hatches local and justified when an external API or language limit requires one.

Use existing project settings as the authority. If the project already enforces stricter checker, linter, formatter, dependency, or validation choices than the playbook, follow the project.

Execution Steps

  1. Prepare the dispatch packet. Normalize TARGET_CODE, LANGUAGE if obvious, USER_GOAL, VALIDATION_COMMAND, SCOPE_LIMITS, REFERENCE_NEED. Ask one targeted question only if the target, language, or scope is too ambiguous to dispatch safely.

  2. Dispatch strict-baseline-mapper. Pass the dispatch packet. Keep only its concise report. On NEEDS_CLARIFICATION, ask the smallest unblocking question. On ERROR, stop and report the recovery. On NO_CHANGE_CANDIDATE, continue; the strategist makes the final stop/proceed decision.

  3. Dispatch strict-rewrite-strategist. Pass the dispatch packet, the baseline report, the Progressive Loading Map row for the language, and the optional source-map row. Keep only the strategy fields: status, playbook path, static typing decisions, runtime validation decisions, edit plan, non-goals, validation plan, references fetched or unavailable. On NO_CHANGE, stop without editing and report why no rewrite is justified.

  4. Dispatch strict-rewrite-implementer. Pass the dispatch packet, the baseline report, the strategy report, and REVIEW_FIXES only during a targeted repair cycle. Keep only the implementation fields: status, changed files, patch summary, behavior-preservation notes, validation result, deviations, reviewer focus. On BLOCKED or ERROR, stop and report the reason, files touched before the block, and the smallest recovery action.

  5. Dispatch strict-rewrite-reviewer. Pass the dispatch packet, the baseline, the strategy, and the implementation report. On PASS, proceed to handoff. On FAIL, re-dispatch the implementer with only the required fixes, then rerun the reviewer. Use at most two targeted fix cycles, then stop and report unresolved findings.

  6. Return the handoff. Use the Output Contract. Keep the response focused on what changed, why the code is stricter and safer, which command validated the result, which references materially influenced decisions, and which risks remain.

Validation Loop Summary

map → plan → change → check → review → fix → re-check. Passing checks are evidence, not proof — the reviewer covers behavior drift, validation placement, dependency scope, and type-system complexity that automated checks may miss.

Example

Input:

  • TARGET_CODE: src/payments/webhook.ts
  • USER_GOAL: "remove unsafe any and validate the webhook payload"

The mapper identifies TypeScript and an untrusted webhook body. The strategist reads ./references/typescript-playbook.md, loads ./references/external-sources.md only because the validator API matters, fetches the smallest Zod URL, and proposes a minimal plan. The implementer changes the boundary from any to unknown, validates once at the boundary, and runs the existing checks. The reviewer confirms behavior, scope, validation placement, and strictness before handoff.

Load ./references/orchestration-examples.md for full dispatch round-trips, no-change handling, and unavailable-reference handling.

同梱ファイル

※ ZIPに含まれるファイル一覧。`SKILL.md` 本体に加え、参考資料・サンプル・スクリプトが入っている場合があります。