optimize
Use this skill when the user's app feels slow, the codebase feels bloated, or after significant development work. Also use when the user says 'my app is slow,' 'clean up my code,' 'reduce bundle size,' 'my hosting bill is too high,' or 'everything feels sluggish.' Optimizes across four dimensions: Speed (page load, API response), Code (unused files, dead code), Database (orphaned data, schema hygiene), and Dependencies (package bloat, bundle size).
What this skill does
# Optimize Reduce waste and improve efficiency. **Only optimize after you have real users and real problems** — premature optimization is the most common waste of founder time. **This skill is for making existing things faster and leaner.** For building features, use **build**. For fixing bugs, use **debug**. For monitoring performance in production, use **monitor**. For database schema design, use **database**. ## Workflow ``` Optimize your app: - [ ] Measure first — get actual numbers (page load, API speed, bundle size) - [ ] Speed — fix the slowest page or API endpoint - [ ] Dependencies — update packages, remove unused ones - [ ] Database — clean orphaned data, optimize slow queries - [ ] Code — remove dead code and unused files - [ ] Re-measure — verify improvements with numbers ``` ## When to Optimize (and When NOT To) **Don't optimize when:** - Building your MVP - Fewer than ~100 active users - Everything works fine - You haven't measured the problem **Optimize when:** - Users complain about slowness (Speed) - Bundle size warnings or security alerts appear (Dependencies) - App noticeably slower than when you launched (Speed/Database) - You're paying for hosting you shouldn't need (Speed/Database) **Rule:** Make it work → get users → measure → THEN make it lean. --- ## Priority Order When multiple things need work: 1. **Speed** — Users feel this immediately. Slow = churn. 2. **Dependencies** — Security vulnerabilities are urgent. Bundle bloat affects speed. 3. **Database** — Affects long-term performance and hosting costs. 4. **Code** — Affects maintainability. Lowest user impact. --- ## Speed Optimization ### Targets | Metric | Good | Bad | |--------|------|-----| | Page load | < 3s | > 5s | | API response | < 500ms | > 1s | | Time to interactive | < 5s | > 8s | ### Step 1: Measure **Claude Code** (can measure directly): ``` Audit app performance: - Measure page load times for the 3 most important pages - Log API response times for the 5 most-used endpoints - Identify the slowest database queries - Check total bundle size Report findings with specific numbers. ``` **Lovable / Replit / Cursor** (measure manually first): 1. Open your app in Chrome → Right-click → Inspect → Network tab → Reload 2. Note the "Load" time at the bottom — that's your page load time 3. Click a button that calls your API — note the request time in Network tab 4. Then paste findings into chat: ``` My app's performance numbers: - Homepage loads in [X] seconds - [Main feature] API takes [X] seconds - [Other page] loads in [X] seconds What's slow and how do I fix it? ``` ### Step 2: Fix **Tell AI:** ``` Optimize these performance issues: [paste audit findings] Apply fixes in this order: 1. Add caching for slow API calls 2. Add database indexes for slow queries 3. Optimize and lazy-load images 4. Code split large bundles Run build and tests after each fix. ``` ### Step 3: Prevent **Tell AI:** ``` Add performance monitoring: - Log API calls > 500ms - Log database queries > 100ms - Alert if page load > 3s ``` See [PERFORMANCE-CHECKS.md](PERFORMANCE-CHECKS.md) for detailed testing methods. --- ## Dependencies Optimization The most relevant optimization at any stage — even pre-launch. ### Signs You Need This - Security vulnerability warnings when you run `npm install` - Bundle size > 500KB - "What does this package do?" ### Audit **Tell AI:** ``` Audit dependencies: - List packages not imported anywhere in code - List packages with security vulnerabilities - Analyze bundle size by package - Find packages with lighter alternatives Report: package name, size impact, and recommendation. ``` ### Fix **Tell AI:** ``` Clean up dependencies: [paste audit findings] Steps: - Remove unused packages from package.json - Update packages with security vulnerabilities - Replace heavy packages with lighter alternatives After changes: delete node_modules, fresh npm install, run build and tests. ``` **Common replacements:** | Heavy | Light Alternative | |-------|-------------------| | moment.js | date-fns or dayjs | | lodash (full) | lodash-es (tree-shakeable) | | axios | fetch (built-in) | ### Prevent **Tell AI:** ``` Set up dependency hygiene: - Add npm audit to CI pipeline - Configure Dependabot for automatic security updates ``` See [DEPENDENCIES.md](DEPENDENCIES.md) for detailed patterns. --- ## Database Optimization **When this matters:** After months of real usage, when queries slow down or hosting costs climb. ### Signs You Need This - Pages that were fast are now slow - Database hosting costs increasing - Queries timing out under load ### Audit and Fix **Tell AI:** ``` Audit database for optimization opportunities: - Find missing indexes on frequently queried columns - Find slow queries (> 100ms) - Find orphaned records (foreign keys pointing to deleted rows) - Find tables with no recent reads/writes For each issue, apply the fix: - Add indexes for slow queries - Set up ON DELETE CASCADE for dependent records - Create cleanup job for orphaned/soft-deleted records (> 90 days) Always backup before making schema changes. ``` --- ## Code Cleanup **When this matters:** After your codebase has grown significantly through AI-assisted iteration. Multiple rounds of "build feature, rebuild feature" leave dead code. ### Signs You Need This - Files you don't recognize - Components that aren't used anywhere - "I'm afraid to delete this" ### Audit and Fix **Tell AI:** ``` Audit codebase for unused code: - Find components not imported anywhere - Find functions never called - Find commented-out code blocks For each: verify nothing references it, then remove it. For duplicate/similar code, use **dry** — it covers deduplication across UI, database, and logic. Run build and tests after cleanup. ``` **Safety rule:** If unsure, comment out first and test. Delete after confirming nothing breaks. --- ## Common Mistakes | Mistake | Fix | |---------|-----| | Optimizing before measuring | AUDIT first, always | | Optimizing during MVP | Ship first, optimize when users complain | | Updating all packages at once | Update one at a time, test each | | Deleting code without verifying | Check imports/references before removing | | Dropping database columns in production | Test migrations on staging first | --- ## Success Looks Like After optimization, you should see: - Pages load < 3 seconds - Zero security vulnerabilities in dependencies - No obviously unused packages - Database queries respond < 100ms - Automated checks catch future regressions --- ## Related Skills - **monitor** — Track performance in production after optimizing - **debug** — Fix broken things (optimize fixes slow things) - **deploy** — Hosting configuration affects performance - **database** — Schema design and query optimization - **dry** — Find and eliminate code duplication across UI, database, and logic - **build** — Feature development (optimize after building, not during)
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.