Tips & Tricks (अपडेट: 1/6/2026)

Claude Code Speed Optimization: धीमे session को diagnose करके काम तेज करें

/usage, /context, /compact, CLAUDE.md और scoped prompts से Claude Code को व्यावहारिक रूप से तेज करें।

Claude Code Speed Optimization: धीमे session को diagnose करके काम तेज करें

Claude Code धीमा लगे तो सबसे पहले model को दोष देना जरूरी नहीं है। अक्सर असली कारण बड़ा conversation history, बहुत wide file search, raw test logs, या बहुत खुला prompt होता है। इस site में भी article writing, translation, build, deploy और debugging एक ही session में रखने से response भारी हो गया था। बेहतर workflow यह रहा: /usage और /context देखें, फिर clear instruction के साथ /compact करें। यह guide beginners के लिए है। इसमें diagnosis, scoped prompt, छोटा CLAUDE.md, subagent delegation और common failure cases को practical तरीके से समझाया गया है।

Tuning से पहले diagnose करें

सबसे पहले /usage चलाएं। API users को session tokens और local estimated cost दिखती है; subscribers को plan usage और attribution दिखता है। इसे final bill नहीं, operational meter मानें। फिर /context देखें। इससे पता चलता है कि context history, memory, MCP, tools या rules में कहां खर्च हो रहा है। अगर बोझ permanent instructions का है, model बदलने से फर्क कम होगा। /compact history summarize करता है, लेकिन instruction दें कि क्या बचाना है: changed files, failed tests, decisions और open questions। इससे session हल्का भी रहता है और continuity भी बनी रहती है।

# Run these inside Claude Code before changing the workflow
/usage
/context
/compact Preserve changed files, test failures, decisions, and open questions

तेज default workflow बनाएं

मेरा loop है: heavy task से पहले /usage और /context, natural break पर /compact, और unrelated task पर /clear। Clear करना कमजोरी नहीं, stale context से बचने का सस्ता तरीका है। दूसरा habit है scope छोटा करना। पहले बताएं कौनसे files पढ़ने हैं, कौनसा test चलाना है, कौनसे folders ignore करने हैं और final evidence क्या चाहिए। तीसरा habit है CLAUDE.md को छोटा रखना। Official memory docs के अनुसार इसमें वही facts रखें जो हर session में चाहिए; बाकी rules या skills में रखें।

claude -p "Fix only the null-check bug in src/api/auth.ts.
Read src/api/auth.ts and tests/auth.test.ts first.
Do not scan node_modules, dist, coverage, or unrelated feature folders.
Return the changed files, commands run, and remaining risks."

CLAUDE.md में सिर्फ हमेशा जरूरी facts रखें

यह example जानबूझकर छोटा है। यह Claude को repository का stable map देता है, memory को permanent documentation dump नहीं बनाता।

# CLAUDE.md

## Project commands
- Build: npm run build
- Test: npm run test
- Type check: npm run typecheck

## Fast navigation
- API code: src/api/
- UI components: src/components/
- Tests: tests/

## Do not read unless explicitly requested
- node_modules/
- dist/
- coverage/
- .wrangler/

## Compact instructions
When compacting, preserve changed files, failing tests, decisions, credentials policy, and next actions.

छोटे benchmark से measure करें

सिर्फ feeling से optimize न करें। वही task wide prompt और scoped prompt से चलाएं, फिर time, read files और evidence quality compare करें।

$runs = @(
  @{ Name = "wide"; Prompt = "Find and fix the auth bug in this project" },
  @{ Name = "scoped"; Prompt = "Fix the null-check bug in src/api/auth.ts only" }
)

foreach ($run in $runs) {
  $elapsed = Measure-Command { claude -p $run.Prompt }
  [pscustomobject]@{
    Name = $run.Name
    Seconds = [math]::Round($elapsed.TotalSeconds, 1)
  }
}

तीन practical use cases

छोटा bug fix

Target file, failing test और acceptance condition दें। Claude कम files पढ़ेगा और जल्दी fix देगा।

बड़ा refactor

Investigation, patch, test और review अलग रखें। हर phase के बाद decisions और risks बचाकर compact करें।

Content pipeline

Translation और repeated checks subagents को दें। Main session में decisions और final verification रखें।

बचने लायक failure cases

  • बिना instruction के /compact चलाने से failing command या design reason summary में खो सकता है।
  • CLAUDE.md में सब कुछ डालना permanent tax है। पुराने incidents और rare playbooks हर बार पढ़े जाते हैं।
  • Speed के लिए verification हटाना गलत है। Logs filter करें, पर failing lines और expected result रखें।

Official docs checked

इस rewrite में क्या verify किया

यह rewrite Claude Code Costs, Monitoring और Memory docs देखकर किया गया है। अब focus /usage, /context, /compact और CLAUDE.md पर है।

अगला step

अगर team Claude Code तेज करना चाहती है तो पहले बड़ा model या automation न बढ़ाएं। पहले prompt shape, memory file और verification receipt standardize करें।

#claude-code #performance #optimization #prompt-engineering #productivity
मुफ़्त

मुफ़्त PDF: Claude Code cheatsheet

Email डालें और commands, review habits तथा safe workflow वाली एक-page PDF पाएँ.

हम आपका data सुरक्षित रखते हैं और spam नहीं भेजते.

Masa

लेखक के बारे में

Masa

Claude Code workflow और team adoption पर काम करने वाला engineer.