skills/code-optimizer/SKILL.md
Analyze code for performance bottlenecks, memory leaks, and algorithmic inefficiencies. Use when asked to optimize, find bottlenecks, or improve efficiency. Don't use for bug-hunting code review, security audits, or refactoring without a perf goal.
npx skillsauth add luongnv89/skills code-optimizerInstall 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.
Analyze code for performance issues following this priority order:
Before creating/updating/deleting files in an existing repository, sync the current branch with remote:
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin
git pull --rebase origin "$branch"
If the working tree is not clean, stash first, sync, then restore:
git stash push -u -m "pre-sync"
branch="$(git rev-parse --abbrev-ref HEAD)"
git fetch origin && git pull --rebase origin "$branch"
git stash pop
If origin is missing, pull is unavailable, or rebase/stash conflicts occur, stop and ask the user before continuing.
Before making any changes:
feat/, feature/, etc.)feat/optimize-<target>
feat/optimize-api-handlersFor each issue found:
### [Severity] Issue Title
**Location**: file:line_number
**Category**: Performance | Memory | Algorithm | Caching | Concurrency
**Problem**: Brief explanation of the issue
**Impact**: Why this matters (performance cost, resource usage, etc.)
**Fix**:
[Code example showing the optimized version]
After completing each major step, output a status report in this format:
◆ [Step Name] ([step N of M] — [context])
··································································
[Check 1]: √ pass
[Check 2]: √ pass (note if relevant)
[Check 3]: × fail — [reason]
[Check 4]: √ pass
[Criteria]: √ N/M met
____________________________
Result: PASS | FAIL | PARTIAL
Adapt the check names to match what the step actually validates. Use √ for pass, × for fail, and — to add brief context. The "Criteria" line summarizes how many acceptance criteria were met. The "Result" line gives the overall verdict.
Phase: Prerequisites — checks: Branch setup, Naming convention detected, Feature branch created
Phase: Analysis — checks: Issue detection, Priority categories covered, Impact estimated, Findings sorted by severity
Phase: Apply Fixes — checks: Fix application, User approval obtained, Existing tests run, No regressions introduced, Critical issues resolved, Warnings documented
Read references/language-checks.md for the detected language's specific checks (covers JavaScript/TypeScript, Python, Go, Rust, Java, and general cross-language patterns) — load only the section matching the target code's language.
A run is acceptable only when all of the following are verifiable:
Location, Category, Problem, Impact, and Fix — verify by checking the rendered template fields are non-empty.Edit/Write tool call.git rev-parse --abbrev-ref HEAD matching feat/* or repo equivalent.Result: PASS | FAIL | PARTIAL — assert the block is present in the transcript.Given a Node.js file src/api/handlers.js with an N+1 query in listUsers(), the skill should emit:
◆ Analysis (step 1 of 3 — src/api/handlers.js)
··································································
Issue detection: √ pass (3 issues found)
Priority categories: √ pass (Performance, Caching covered)
Impact estimated: √ pass
Findings sorted: √ pass
Criteria: 4/4 met
____________________________
Result: PASS
### [Critical] N+1 query in listUsers
**Location**: src/api/handlers.js:42
**Category**: Performance
**Problem**: `users.forEach(u => db.query(...))` issues one query per user.
**Impact**: For 1000 users, ~1000 round-trips (~2000ms) → 1 batched query (~50ms). 40x speedup.
**Fix**:
\`\`\`js
const ids = users.map(u => u.id);
const rows = await db.query('SELECT * FROM orders WHERE user_id = ANY($1)', [ids]);
\`\`\`
Expected result: a markdown report with one block per issue, sorted Critical → Low, followed by a phase completion report. See docs/README.md for a longer end-to-end example.
perf, py-spy, Chrome DevTools) — do NOT invent low-severity findings to fill the report.git checkout -- <file> after git diff confirms the scope and the user confirms the revert; never force-push, and back up the diff with git stash before discarding so work is recoverable.origin or rebase fails: stop and ask the user to confirm before any recovery; run git status and git stash --dry-run-style inspection first, take a backup branch (git branch backup/pre-recovery), and never run destructive reset --hard or rm without explicit confirmation.development
Scan a live site with isitagentready.com, then approve each step: triage the 0-5 agent-readiness score, write agent-ready-plan.md, file issues via /plan-to-issues. Don't use for applying llms.txt/SEO fixes (seo-ai-optimizer) or app-store ASO.
development
Review a product codebase and landing page against 32 viral principles and produce a Virality Score plus ranked fixes. Use to audit virality or prioritize growth. Don't use for SEO, ASO, copywriting, or code review.
development
Generate a Technical Architecture Document (TAD) from a PRD. Use when asked to design system architecture or define how a product is built. Updates tad.md and reports GitHub links. Don't use for PRD authoring, sprint tasks, or code implementation.
development
Check product and brand names for conflicts across trademarks, domains, social handles, and package registries. Returns a risk level and Proceed/Modify/Abandon recommendation. Skip for name brainstorming, logo design, or trademark filings.