// 61 tips tagged "performance"
When a page takes five seconds to load or an API endpoint times out under load, tell Claude which route is slow and it traces the entire code path — controller, services, queries, loops — identifying N+1 queries, redundant computations, missing indexes, and cacheable operations, then fixes each bottleneck.
When Claude starts referencing files you've since deleted, remembering old code you've already changed, or getting confused by contradictory instructions from a long session — type /clear to wipe the slate clean. Unlike /compact which preserves context, /clear gives you a true fresh start without restarting the CLI.
Not every task needs deep reasoning. Type /fast to switch Claude Code into fast mode — same model, faster output — for quick edits, simple questions, and routine changes. Toggle it off when you need Claude to think harder on complex problems.
Long sessions eat through your context window as conversation history piles up. Type /compact to summarize the conversation so far and reclaim space — keeping Claude's understanding of what you're working on while freeing up room for more work.
Type /cost at any point to see how many tokens you've used in the current session, how much it's costing, and which operations are consuming the most context — so you can make informed decisions about when to /compact, /clear, or switch models.
Pass --model when starting Claude Code to choose exactly which model you want — opus for complex architecture work, sonnet for everyday coding, haiku for quick lookups — without changing your default settings or switching after the session starts.
When a specific query is slow, run EXPLAIN on it and paste the execution plan into Claude — it reads the plan, spots full table scans, bad join orders, and missing indexes, then rewrites the query and suggests schema changes to make it fast.
Type /fast to switch Claude Code into faster output mode — same model, faster generation. Perfect for quick lookups, simple edits, and rapid-fire questions where you don't need Claude to think as deeply before responding.
When you've finished one task and want to start a completely different one, run /clear to reset the conversation — Claude forgets the previous context so stale decisions, old file reads, and irrelevant discussion don't pollute your next task.
When your Claude Code session gets long and responses slow down, run /compact to summarize the conversation history and free up context window space — keeping your session alive without losing important context.
Tell Claude to read your queries, ORM calls, and WHERE clauses, then suggest which database indexes to add — it identifies missing indexes that would speed up slow queries, flags redundant indexes wasting write performance, and generates the migration to add them.
Tell Claude to read your backend code and find performance problems — O(n²) loops hidden in simple-looking functions, N+1 database queries, redundant API calls, missing pagination, and expensive operations inside request handlers that should be queued.