simplify-rust-code
ALWAYS invoke this skill when simplifying Rust implementation while preserving behavior.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 1
- Forks
- 1
01 前言 Front Matter
- name
- simplify-rust-code
- description
- ALWAYS invoke this skill when simplifying Rust implementation while preserving behavior.
- allowed-tools
- Read, Glob, Grep, Edit, {{! tool('use_skill') !}}, Bash(git status:*), Bash(git rev-parse:*), Bash(git diff:*)
- argument-hint
- <HEAD|base...head>
03 SKILL.md 正文
{!% require_skill 'rust:rust-test-standards' %!}
<objective> Simpler Rust implementation with unchanged behavior and ownership semantics, accompanied by a scope and verification report. </objective>
<constraints>
- MUST preserve public behavior, dependency-injection seams, error wrapping, and typed errors.
- MUST preserve ownership transfers, lifetime and trait bounds, exhaustive handling, and unsafe/FFI invariants; never add clones merely to simplify borrowing.
- NEVER modify tests, test infrastructure, specs, or generated files; simplify only implementation already changed in the selected scope.
- NEVER change behavior to enable a simplification, add dependencies, or weaken coverage and validation requirements.
- NEVER commit, publish, or launch another subagent as part of simplification.
- Product verification commands outside this skill's narrow Git preapprovals use the harness's normal per-call approval path. Resolve the exact product command, honor existing operator authorization, and request any missing permission before execution; denied or unavailable permission returns
blocked. Never substitute a command to avoid approval.
</constraints>
<workflow>
- Require
$ARGUMENTSto beHEADor an explicit committed three-dot range. For absent or invalid input, returnblockedbefore mutation. Read the product's {{! file('root_guide') !}} and invoke/understandwhen its foundation marker is absent. - Invoke
/scope-changesetwith the supplied target and consume itsCOMMITTED_CHANGESET_SCOPEmarker. The provider executes its own committed-scope command; do not import its Python API or invent a resolver command. Require the resolved head to equal the checkout's fullHEADand the worktree to be clean. Record both endpoint identities and the complete changed-path set. A scope-resolution failure returnsblockedwith its diagnostic. - Select changed, present Rust implementation files, excluding generated extents and test/evidence files using the product's declarations and
/rust-test-standards. Derive their governing nodes through spec-linked evidence and invoke/contextualizeon their lowest common ancestor before reading implementation. After context loading, require the same fullHEADand a clean worktree again; otherwise returnblockedwith the changed subject. If no implementation qualifies, returnunchangedwith the empty scope. Missing governance returnsblocked. - Inspect the selected implementation and the evidence covering its behavior. Apply
/rust-test-standardsto coverage and test quality. Missing or inadequate behavioral coverage returnsblockedwith the affected file or function and evidence gap; do not create tests to bypass this condition. - Resolve the baseline test command from the product guide and the inspected evidence. Use existing evidence; if correct work requires changed behavior or changed evidence, return
blockedbefore editing. - Run the product's required baseline tests and record actual exit codes. A failed or unavailable baseline returns
blockedwithout edits. Identify only changes whose behavioral equivalence can be explained from the code and evidence; when none improves clarity safely, returnunchangedwith the reason. - Use skill
rust:author-rust-codewith the governing node, selected files, and the behavior-preserving simplification requirement. Follow its complete discovery, standards, and validation contract while preserving the evidence. Retain the exact patch owned by this invocation. Require the same tests afterward and every format, lint, and validation check required byrust:author-rust-code, using product commands and preserving process exit codes. Collect those results once; never mask a failing process through output truncation or a pipeline. - Compare the resulting diff with the recorded scope and baseline. Confirm tests, evidence, seams, and ownership contracts remain unchanged. Follow
<recovery>on any failed check or uncertain equivalence, then return<result>.
</workflow>
<coding_result>
Use skill rust:author-rust-code and request its completion report with changed paths, the behavior preserved by each edit, the evidence used, executed commands and exit codes, and unresolved constraints. Execute that composed workflow in this session.
Before Step 8, require every report component and compare it against the retained diff and captured command results. Every changed path must belong to the selected scope, every reported successful check must have a zero exit code, and every omitted required check or unresolved constraint must be identified. A missing report component or contradiction returns failed through the recovery procedure; never infer completion from a generic success statement.
Merge the validated report into the final JSON: retained paths into changed_paths, each edit and its equivalence explanation into changes, inspected tests and covered behavior into evidence, actual command observations into verification, and remaining constraints into blockers. Preserve this skill's before/after/recovery phases and its stricter behavior-preservation boundaries.
</coding_result>
<recovery>
On a post-edit verification failure, reverse only this invocation's patch and run the affected check against the restored content. Never reset or restore a whole file over another writer's changes. If concurrent edits prevent safe reversal, leave them intact and report the exact collision and remaining patch. Return failed, retaining the original command, exit code, diagnostic, and recovery outcome even when restoration succeeds.
If a required skill, product command, decision, or permission is unavailable, report blocked with the exact prerequisite and next required action. After edits, first apply the same recovery rule. Never install dependencies or invent a replacement verification command.
</recovery>
<result>
Return one JSON object with these fields:
status:simplified,unchanged,blocked, orfailed;reason: the outcome explanation.target: the supplied target unchanged;baseandhead: full resolved commit identities, or null when resolution failed.scope: selected implementation paths;changed_paths: paths still changed by this invocation.changes: each applied simplification's path, reason, and behavioral-equivalence explanation.evidence: inspected test paths and the behavior each covers.verification: executed commands withphase(before,after, orrecovery),command, and actualexit_code. List every required but unexecuted check inblockers.blockers: exact prerequisites, evidence gaps, failing diagnostics, or uncertainty; empty on success.recovery: an object withstatus(not-needed,reverted, orconflict) anddetails.
simplified requires a nonempty retained patch, sufficient unchanged evidence, and all required checks passing. unchanged requires no retained patch and a reason explaining why the scope was empty or no safe improvement was found. Never represent an unexecuted check as passing or a simplification report as an independent audit approval.
</result>
<failure_modes>
A library reference was treated as an executable capability. Claude instructed the simplifier to use resolve_committed_scope even though the provider exposed only an importable API. The workflow had no shipped command to execute. Invoke /scope-changeset with the target and consume the marker its own command establishes; never invent an import script during simplification.
</failure_modes>
<success_criteria>
- Every retained edit belongs to the resolved Rust implementation scope and improves clarity without changing behavior, error contracts, seams, or ownership semantics.
- Unchanged behavioral tests pass before and after edits, and the complete
rust:author-rust-codevalidation requirements pass. - The report accounts for every retained edit, executed check, unexecuted required check, and recovery action.
- A blocked prerequisite causes no retained edit unless a reported concurrent-write collision prevents safe recovery.
</success_criteria>
04 同仓库更多 Skills
plugin
暂无简介
sanitize-powerpoint
ALWAYS invoke this skill when sanitizing, cleaning up, auditing, or aligning a PowerPoint (.pptx) deck — slide-master and layout structure, layout type attributes, stray fonts, non-theme colors, or layout naming. NEVER hand-edit pptx XML without this skill.
draw-excalidraw
ALWAYS invoke this skill when creating Excalidraw diagrams, visualizing workflows, architectures, or concepts. NEVER generate Excalidraw JSON without this skill.
typescript-test-standards
TypeScript test standards enforced across all skills. Loaded by other skills, not invoked directly.
typescript-code-standards
TypeScript code standards enforced across all skills. Loaded by other skills, not invoked directly.
typescript-architecture-standards
TypeScript ADR conventions enforced across architect and auditor skills. Loaded by other skills, not invoked directly.