dotfiles/dot_config/opencode/skills/ce-simplify-code/SKILL.md
Simplify and refine recently changed code for clarity, reuse, quality, and efficiency while preserving behavior.
npx skillsauth add pkking/dotfiles ce-simplify-codeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are an engineer that is an expert at simplifying code with a specific focus on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying project-specific best practices to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions.
Review the changed code for reuse, quality, and efficiency. Fix any issues found. Then verify behavior is preserved by running the project's test suite.
Resolve the simplification scope in this order:
git diff origin/main... or against the configured upstream). This covers the common case of "simplify everything I've added on this feature branch before opening a PR." If the branch has no upstream or base ref, fall back to staged + unstaged changes (git diff HEAD).If none of the above produces a non-empty scope, stop and ask the user what to simplify rather than guessing.
Spawn the three reviewer agents below in a single message via the platform's subagent dispatch primitive — Agent/Task in Claude Code, spawn_agent in Codex, subagent in Pi via the pi-subagents extension. Pass each agent the full diff (or the resolved file set) so it has the complete context.
Model selection. Use the platform's mid-tier model for these reviewers: model: "sonnet" in Claude Code, the equivalent mid-tier on Codex (gpt-5.4-mini as of April 2026) via spawn_agent, the equivalent on Pi via subagent from the pi-subagents extension. On platforms where the model-override parameter is unavailable or the model name is unrecognized, omit the override — a working pass on the parent model beats a broken dispatch.
Permission mode. Omit the mode parameter on the dispatch call so the user's configured permission settings apply.
For each change:
Review the same changes for hacky patterns:
a ? x : b ? y : ...), nested if/else, or nested switch 3+ levels deep — flatten with early returns, guard clauses, a lookup table, or an if/else-if cascadeno-unused-vars / unused-imports, knip, ruff F401, tsc --noEmit --noUnusedLocals, golangci-lint unused, etc.). Otherwise prefer a structural search like ast-grep over plain text grep — grep produces false positives from string literals, comments, and substring matches in unrelated identifiers. Account for re-exports (export * from, barrel files), dynamic imports (import(), require(), template-string imports), and framework-specific exports (Next.js page exports, React Server Components, decorators). False positives here are higher-cost than missed catches; if uncertain, skip.Review the same changes for efficiency:
Wait for all three agents to complete. Aggregate their findings and fix each issue directly. If a finding is a false positive or not worth addressing, note it and move on. Do not argue with the finding or raise questions to the user, just skip it.
The premise of this skill is that simplification preserves exact functionality. After applying fixes:
Run typecheck and lint over the full project. They are usually fast and catch the most common simplification regressions — broken imports, unused exports, dropped type narrowings, dead code other modules still reference.
Run tests:
Surface any failure clearly with the failing check name and the relevant output. Do not relax assertions, weaken type signatures, or skip tests to make checks pass — that defeats the "preserves functionality" guarantee. Either fix the underlying break introduced by simplification, or revert the specific change that caused the regression.
If no test suite, lint, or typecheck is configured, state that explicitly in the summary; do not silently skip verification.
Briefly summarize what was good vs improved and fixed, including which checks were run and their results. If there were no findings to act on, confirm the code didn't require any changes.
testing
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
data-ai
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
development
Run the full autonomous engineering pipeline end-to-end (plan, work, code review, test, commit, push, open PR, watch CI, fix CI failures until green). Use only when the user explicitly requests hands-off execution of a software task and provides a feature description; do not auto-route casual conversation here.
development
Create an isolated git worktree for parallel feature work or PR review. Use when starting work that should not disturb the current checkout, or when `ce-work` or `ce-code-review` offers a worktree option.