Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
b-mendoza avatar

Rewriting Code Strictly

  • 35 installs
  • 1 repo stars
  • Updated August 5, 2026
  • b-mendoza/agent-skills

rewriting-code-strictly is a Claude Code skill that rewrites Python, TypeScript, or Go code for strict static typing and boundary validation while preserving behavior.

About

This skill rewrites existing Python, TypeScript/JavaScript, or Go code to be strictly typed, boundary-validated, and more maintainable while preserving behavior. It coordinates a baseline map, a strategy, an approved implementation, and a review, fetching a language playbook just in time. A developer uses it to harden code, remove unsafe escape hatches, add validation, or align with mypy, tsc, or go vet. It records static-typing versus runtime-validation decisions and the validation commands it ran.

  • Rewrites Python, TypeScript/JavaScript, or Go code for strict static typing and boundary validation
  • Removes unsafe escape hatches and aligns with mypy, Pyright, tsc, go vet, or Staticcheck
  • Coordinates baseline mapping, strategy, approved implementation, and review while preserving behavior

Rewriting Code Strictly by the numbers

  • 35 all-time installs (skills.sh)
  • Ranked #637 of 1,352 Code Review & Quality skills by installs in the Skillselion catalog
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
At a glance

rewriting-code-strictly capabilities & compatibility

Capabilities
refactoring code · review pull request
Use cases
refactoring · code review
From the docs

What rewriting-code-strictly says it does

Rewrite existing Python, TypeScript/JavaScript, or Go code for strict static typing, boundary validation, and maintainable idioms while preserving behavior.
SKILL.md
You are a strict-rewrite orchestrator.
SKILL.md
npx skills add https://github.com/b-mendoza/agent-skills --skill rewriting-code-strictly

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs35
repo stars1
Last updatedAugust 5, 2026
Repositoryb-mendoza/agent-skills

What it does

Harden Python, TypeScript, or Go code with strict typing and boundary validation while preserving behavior.

Who is it for?

Behavior-preserving strict rewrites of Python, TypeScript/JavaScript, or Go with type-checker validation

Skip if: Changing behavior or refactoring code that does not need stricter typing or validation

When should I use this skill?

You want to harden code, remove unsafe escape hatches, add validation, or align with mypy, tsc, or go vet.

What you get

A behavior-preserving strict rewrite aligned with the language's type checker plus validation evidence.

By the numbers

  • 4 subagents in the registry
  • supports 3 languages (Python, TypeScript/JavaScript, Go)
  • 5 gate checkpoints in the output contract

Files

SKILL.mdMarkdownGitHub ↗

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 and the source is approved, edit files, run approved or project-authorized checks, and review the diff.

Inputs

InputRequiredExample
TARGET_CODEYessrc/api/users.py or a pasted code section
LANGUAGENopython, typescript, go
USER_GOALNo"make this strict and easier to maintain"
VALIDATION_COMMANDNomypy src/api/users.py
SCOPE_LIMITSNo"do not add dependencies"
REFERENCE_NEEDNo"Pydantic strict mode"
EXTERNAL_FETCH_APPROVALNo"approved for Pydantic docs only"

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 8. Gate evidence for G_STRICT_STRATEGY_APPROVAL, G_MUTATION_SCOPE, G_IMPLEMENTATION_VALIDATION, G_STRICT_REVIEW_PASS, and G_FINAL_HANDOFF_EVIDENCE

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

PhaseExecutionLoadsOutput
IntakeInlinepersonality.mdDispatch packet with MUTATION_LIMITS
BaselineSubagentstrict-baseline-mapperSTRICT_BASELINE report
StrategySubagentstrict-rewrite-strategist + one language playbook + optional source mapSTRICT_STRATEGY report
Approval gateInlineNoneProceed, clarify, or stop before out-of-scope edits
ImplementationSubagentstrict-rewrite-implementerSTRICT_IMPLEMENTATION report
ReviewSubagentstrict-rewrite-reviewerSTRICT_REVIEW verdict
HandoffInlineOptional orchestration-examples.mdFinal response

Subagent Registry

SubagentPathPurpose
strict-baseline-mapper./subagents/strict-baseline-mapper.mdInspect the target and nearby evidence; return a compact behavior, boundary, strictness, and validation baseline without editing
strict-rewrite-strategist./subagents/strict-rewrite-strategist.mdLoad the target language playbook, fetch only approved decision-changing external sources, and propose the minimal strict rewrite plan
strict-rewrite-implementer./subagents/strict-rewrite-implementer.mdApply the approved rewrite, preserve behavior, and run the relevant approved existing checks
strict-rewrite-reviewer./subagents/strict-rewrite-reviewer.mdReview 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.

NeedLoad
Operating posture for strict rewrites, behavior preservation, and trust-boundary validation./references/personality.md
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 approved relevant URL
Concrete dispatch round-trip, no-change handling, or unavailable-reference handling./references/orchestration-examples.md
Visual workflow audit or explanation./flow-diagram.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.

When dispatching a subagent, pass the package-root-relative reference path from this map and the resolved language from the baseline if the user did not supply LANGUAGE. Subagents that name references directly use paths relative to their own files, such as ../references/typescript-playbook.md.

External websites are optional. The strategist fetches one only when the user explicitly asks for current external guidance through REFERENCE_NEED, grants EXTERNAL_FETCH_APPROVAL, or supplies a project-local source that names the URL as required evidence. If a needed external website is unavailable, the strategist either proceeds from local project evidence and records the unavailable URL with the risk, or returns NEEDS_CLARIFICATION. Normal execution should not require network access.

Default Mutation Limits

Derive MUTATION_LIMITS during intake and pass them to every subagent that plans, edits, or reviews mutations. Unless the user explicitly expands scope via SCOPE_LIMITS, use these defaults:

  • Write only inside TARGET_CODE and files directly required by compilation, typing, imports, or tests for that target.
  • Preserve observable behavior, public contracts, dependency choices, project settings, and unrelated worktree changes.
  • Out of scope: files unrelated to the approved strategy, new dependencies, broad formatting or cleanup, public API changes, private configuration, generated artifacts, and repository-level tooling unless explicitly approved.
  • During reviewer repair cycles, change only reviewer-named files and fixes that remain inside the original strategy and MUTATION_LIMITS.

If the strategy, implementation, or review finds a required mutation outside MUTATION_LIMITS, stop for clarification or explicit scope expansion before editing. Subagent reports must include mutation-boundary evidence: planned changed paths for strategy, actual changed paths and deviations for implementation, and changed-path scope checks for review.

Critical Output Gates

These named gates protect outputs that later phases or the final handoff rely on:

GateCritical outputEvidence required
G_STRICT_STRATEGY_APPROVALStrategy is safe to implement or correctly stops as no-change/clarificationStrategy status, non-goals, approval-triggering items, and validation plan
G_MUTATION_SCOPEPlanned and actual writes stay inside MUTATION_LIMITSMutation limits, planned changed paths, actual changed paths, and any explicit scope expansion
G_IMPLEMENTATION_VALIDATIONImplementation records validation evidence or warning evidenceCommands run, result, unavailable or unapproved validation notes, and deviations
G_STRICT_REVIEW_PASSIndependent review accepts behavior, strictness, boundary validation, scope, and validation qualitySTRICT_REVIEW: PASS or blocked findings after bounded repair cycles
G_FINAL_HANDOFF_EVIDENCEUser handoff names the evidence behind the resultGate verdicts, changed files or code, validation, references, assumptions, and residual risks

Run gate checks inline after the producing phase. Final handoffs must include compact gate evidence for every gate that ran, including warnings or blocked reasons.

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, and EXTERNAL_FETCH_APPROVAL. Load ./references/personality.md for the operating posture. Derive MUTATION_LIMITS once from TARGET_CODE, direct compilation consequences, and any explicit SCOPE_LIMITS expansion. Ask one targeted question only if the target, language, scope, or mutation boundary is too ambiguous to dispatch safely.

2. Dispatch `strict-baseline-mapper`. Pass the dispatch packet. Keep only its concise report. Route only on STRICT_BASELINE: PASS | NO_CHANGE_CANDIDATE | NEEDS_CLARIFICATION | ERROR. On PASS, continue to strategy. On NO_CHANGE_CANDIDATE, record the evidence and continue; the strategist makes the final stop/proceed decision. On NEEDS_CLARIFICATION, ask the smallest unblocking question. On ERROR, stop and report the recovery.

3. Dispatch `strict-rewrite-strategist`. Pass the dispatch packet, MUTATION_LIMITS, the baseline report, the resolved language, the Progressive Loading Map row for that language, the optional source-map row, and external-fetch authorization status. Keep only the strategy fields: status, playbook path, static typing decisions, runtime validation decisions, edit plan, planned changed paths, non-goals, validation plan, references fetched or unavailable. Route only on STRICT_STRATEGY: PASS | NO_CHANGE | NEEDS_CLARIFICATION | ERROR. Check G_STRICT_STRATEGY_APPROVAL and G_MUTATION_SCOPE before implementation. On NO_CHANGE, stop without editing and report why no rewrite is justified. On NEEDS_CLARIFICATION, ask one strategy question for the missing decision, mutation-boundary expansion, external fetch approval, local source, or unavailable-source disposition.

4. Run the approval gate. If the strategy requires a new dependency, public API change, behavior change, broad scope expansion, external fetch not already approved, or execution of a validation command not supplied by the user or authorized by project evidence, ask one focused approval question with the target, reason, risk, reversibility, and safer local alternative. If no safe validation command exists, continue without running one and require the implementer to record warning evidence.

5. Dispatch `strict-rewrite-implementer`. Pass the dispatch packet, MUTATION_LIMITS, 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, mutation-boundary evidence, reviewer focus. Route only on STRICT_IMPLEMENTATION: PASS | PASS_WITH_WARNINGS | BLOCKED | ERROR. Check G_MUTATION_SCOPE and G_IMPLEMENTATION_VALIDATION before review. On PASS or PASS_WITH_WARNINGS, continue to review; warnings about missing, declined, unavailable, pre-existing-failing, or unapproved validation become reviewer evidence. On BLOCKED or ERROR, stop and report the reason, files touched before the block, and the smallest recovery action.

6. Dispatch `strict-rewrite-reviewer`. Pass the dispatch packet, MUTATION_LIMITS, the baseline, the strategy, and the implementation report. Route only on STRICT_REVIEW: PASS | FAIL | ERROR. Check G_STRICT_REVIEW_PASS and preserve review evidence for the final handoff. On PASS, proceed to handoff. On FAIL, re-dispatch the implementer only when the reviewer supplied actionable targeted fixes, and pass only those fixes within MUTATION_LIMITS. Use at most two targeted fix cycles, then stop as BLOCKED with unresolved findings, attempted repairs, and the safest next action. If the reviewer returns FAIL without actionable fixes, stop as BLOCKED.

7. Return the handoff. Use the Output Contract and include G_FINAL_HANDOFF_EVIDENCE with compact gate verdicts. 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 → approve → change/check → review → targeted fix → re-check. The implementer owns user-supplied or project-authorized validation execution and records unavailable, missing, declined, or unapproved validation as warning evidence. Passing checks are evidence, not proof; the reviewer covers behavior drift, validation placement, dependency scope, validation quality, 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"
  • REFERENCE_NEED: "current Zod safeParse behavior"

The mapper identifies TypeScript and an untrusted webhook body. The strategist receives the package-relative ./references/typescript-playbook.md row, loads the subagent-relative ../references/typescript-playbook.md, loads ../references/external-sources.md only because the validator API matters, fetches the smallest approved Zod URL, and proposes a minimal plan. The approval gate confirms no dependency or public API expansion is required. The implementer changes the boundary from any to unknown, validates once at the boundary, and runs user-supplied or project-authorized 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.

Related skills

FAQ

Which languages does it support?

Python, TypeScript/JavaScript, and Go, selecting one language playbook after the language is known.

Does the rewrite change behavior?

No. It coordinates behavior-preserving rewrites and reviews the diff for behavior drift before finishing.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.