Agent skill

polish-code

Stage, format, lint, test, simplify, review, smoke test, and re-run itself until stable. Use when the user asks to "polish code", "refine code", "iterate on code quality", "simplify and review loop", "clean up, test, and review loop", or "run the polish loop".

Stars 261
Forks 21

Install this agent skill to your Project

npx add-skill https://github.com/tobihagemann/turbo/tree/main/skills/polish-code

SKILL.md

Polish Code

Task Tracking

At the start of every invocation (including re-runs from Step 8), use TaskCreate to create a task for each step:

  1. Run /stage skill
  2. Deterministic cleanup
  3. Run /simplify-code skill
  4. Run /review-code skill
  5. Run /evaluate-findings skill
  6. Run /apply-findings skill
  7. Run /smoke-test skill
  8. Re-run /polish-code skill if changed

Step 1: Run /stage Skill

Run the /stage skill.

Step 2: Deterministic Cleanup

Run the project's formatter first, then the linter. Fix any lint errors or warnings that the formatter did not resolve. If the project has a combined format+lint script, use that.

Run the project's test suite to confirm nothing is broken. If tests fail, run the /investigate skill to diagnose the root cause, apply the suggested fix, and re-run tests. If investigation cannot identify a root cause, stop and report with investigation findings.

Stage all changes made in this step before continuing.

Step 3: Run /simplify-code Skill

Run the /simplify-code skill. The diff command is git diff --cached.

Stage all changes made in this step before continuing.

Step 4: Run /review-code Skill

Run the /review-code skill. The diff command is git diff --cached.

Always run this step even if Step 3 made no changes.

Step 5: Run /evaluate-findings Skill

Run the /evaluate-findings skill on the results from Steps 3 and 4.

If zero actionable findings survive evaluation, skip to Step 7.

Step 6: Run /apply-findings Skill

Run the /apply-findings skill on the evaluated results.

Stage all changes made in this step before continuing.

Step 7: Run /smoke-test Skill

Run the /smoke-test skill to produce the smoke test plan. Delegate test execution to a subagent using the Agent tool (model: "opus", do not set run_in_background). Pass the plan and the diff command (git diff --cached) to the subagent.

If any test fails, fix the issues and stage the fixes.

Step 8: Re-run /polish-code Skill if Changed

Check whether any file was edited during Steps 3-7. Any edit counts, regardless of how small or mechanical it seems.

If changes were made, classify what Steps 3-7 edited:

  • Structural edits (fixed bugs, new or removed functions, changed function signatures, moved code between files, changed control flow, added or removed dependencies, corrected a stale or wrong comment that was itself a documentation bug) — run /polish-code again using the Skill tool. Scope the diff command to only the files modified in the previous iteration: use git diff --cached -- <file1> <file2> ... as the diff command for /simplify-code and /review-code. Smoke test scope remains unchanged (full feature scope, not file-narrowed). If the round contains both structural and in-place edits, treat it as structural and re-run automatically.
  • In-place edits only (renamed local variables without changing behavior, reformatted, adjusted whitespace, edited neutral comments) — output a summary of what changed, then use AskUserQuestion to ask whether to run one more round or stop here. Do not silently continue or silently stop.

If this is iteration 3 and changes were still made, the hard cap is reached. This replaces the classification gate above. Output a summary of what is still changing and whether it is structural or in-place. Then use AskUserQuestion to offer three options: continue for another iteration, stop here and accept the current state, or escalate to /consult-oracle for a different perspective on the remaining issues.

The re-invocation is a full, fresh run of this skill. Every step (1-8) executes with its own task tracking and skill invocations. "Scoped to modified files" only affects the diff command passed to /simplify-code and /review-code. It does not affect which steps run or whether skills are invoked.

Check your task list for remaining tasks and proceed.

Rules

  • Every step must run in every iteration. Each step uses distinct agents with non-overlapping review criteria. /simplify-code and /review-code have different focus areas. /evaluate-findings is a judgment gate that must run before /apply-findings.
  • Each step must invoke its designated skill via the Skill tool, not be replaced by inline reasoning or agent calls.
  • Re-invocations from Step 8 are full runs with fresh task tracking and complete skill invocations.

Expand your agent's capabilities with these related and highly-rated skills.

tobihagemann/turbo

review-api-usage

Check API, library, and framework usage in code against official documentation and installed skill knowledge. Flags deprecated APIs, incorrect method signatures, wrong parameter types, version-incompatible patterns, and best-practice violations. Use when the user asks to "review API usage", "check API usage", "verify against docs", "check library usage", "validate API calls", "check against documentation", or "check for deprecated APIs".

261 21
Explore
tobihagemann/turbo

resolve-pr-comments

Evaluate, fix, answer, and reply to GitHub pull request review comments. Handles both change requests (fix or skip) and reviewer questions (explain using reasoning recalled from past Claude Code transcripts). Use when the user asks to "resolve PR comments", "fix review comments", "address PR feedback", "handle review comments", "address review feedback", "respond to PR comments", "answer review questions", or "address code review".

261 21
Explore
tobihagemann/turbo

consult-codex

Multi-turn consultation with Codex CLI for second opinions, brainstorming, or collaborative problem-solving. Use when the user asks to "consult codex", "ask codex", "get codex's opinion", "brainstorm with codex", "discuss with codex", or "chat with codex".

261 21
Explore
tobihagemann/turbo

review-tooling

Detect what dev tooling infrastructure a project has and flag gaps across linters, formatters, pre-commit hooks, test runners, and CI/CD pipelines. Returns structured findings without applying changes. Use when the user asks to "review tooling", "check project tooling", "what tooling is missing", "review dev infrastructure", or "tooling audit".

261 21
Explore
tobihagemann/turbo

create-changelog

Create a CHANGELOG.md following keepachangelog.com conventions with version history backfilled from GitHub releases or git tags. Use when the user asks to "create a changelog", "add a changelog", "initialize changelog", "start a changelog", "set up changelog", "generate changelog", or "backfill changelog".

261 21
Explore
tobihagemann/turbo

update-changelog

Update the Unreleased section of CHANGELOG.md based on current changes. No-op if CHANGELOG.md does not exist. Use when the user asks to "update changelog", "add to changelog", "update the changelog", "changelog entry", "add changelog entry", or "log this change".

261 21
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results