code-optimize

Optimizes small-scope code for readability and performance while preserving external behavior.

1|Updated Sep 11, 2026
One-click install
npx skills add https://github.com/lldwb/lldwb-claude-skills --skill code-optimize-lldwb
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: code-optimize
Source: https://github.com/lldwb/lldwb-claude-skills/tree/main/skills/code-optimize
Command: npx skills add https://github.com/lldwb/lldwb-claude-skills --skill code-optimize-lldwb

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Small-scale code cleanup often drifts into unplanned refactors, hidden behavior changes, or scope creep. This Skill enforces a disciplined workflow for minor optimizations—deduplication, naming improvements, local performance tuning—so changes stay minimal, verifiable, and safe to commit. ## Core Features & Use Cases - Understand-before-change workflow: Reads project conventions (AGENTS.md) and related code first, then plans by optimization goal, approach, and affected files. - Minimal-change ladder: A stepwise checklist decides whether to write code at all—reuse existing implementations, standard library, or deletion before adding anything new. - Behavior-preservation verification: Compiles and runs unit tests (Maven examples included), with a checklist to confirm interfaces, UI interactions, and flows remain unchanged. - Boundary discipline: Real defects found during optimization are reported separately and handed to bug-fix rather than silently fixed; structural refactors route to the refactor skill. - Use Case: Ask to extract duplicated logic in a service class; the Skill plans the extraction, verifies no caller behavior changes, runs tests, and commits with a conventional Chinese commit message. ## Quick Start Ask the assistant to optimize this duplicated code and clean up the naming in the current module without changing any external behavior.

Frequently Asked Questions about code-optimize

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely refactor duplicated code without changing behavior?▼

Extract the repeated logic into a shared method or constant with differences parameterized, then verify all callers produce identical results. This Skill enforces compile and unit test verification plus a behavior-preservation checklist before any commit.

What is the difference between code optimization and refactoring?▼

Code optimization covers small-scope changes like deduplication, naming, and local performance within a file or module. Structural changes, layer redesign, or batch migrations requiring contracts and test baselines belong to a dedicated refactor workflow instead.

How to verify code optimization with Maven?▼

Run mvn compile -pl <module> -am for compilation and mvn test -Dmaven.test.skip=false -pl <module> -am -Dtest=<TestClass> -DfailIfNoTests=false for targeted tests. Both must pass before committing; unverified changes cannot be claimed as complete.

Should I fix bugs found during code optimization?▼

No. Fixing defects changes external behavior and exceeds the optimization scope. The correct approach is to report the defect separately with file location, symptom, and impact, then handle it through a dedicated bug-fix workflow.

When should I not use a small-scope optimization workflow?▼

Avoid it for structural refactors, new features, behavior changes, or pure comment updates. Those scenarios need their own workflows because they require different verification rigor, planning artifacts, or review processes.