Claude Code Context Management: /context, /compact, CLAUDE.md और Obsidian का सही उपयोग
Claude Code sessions को focused रखने के लिए /context, /compact, memory, CLAUDE.md और notes workflow.
Claude Code में लंबी sessions अक्सर इसलिए कमजोर होती हैं क्योंकि पुराने logs, file reads और temporary decisions context भर देते हैं। Context management का मतलब है कि अभी क्या चाहिए और क्या notes में रह सकता है।
/context current usage दिखाता है, /compact conversation summarize करता है, /clear fresh start देता है, और /memory loaded files दिखाता है.
Practical aim है main session focused रहे और long research, raw notes, old logs active window से बाहर रहें.
Think of the context window as the working desk
Context window में history, file reads, tool output, CLAUDE.md, auto memory, rules और skills आते हैं. Window भरने पर important constraints old output से compete करते हैं.
| What enters context | Why it gets heavy | Practical response |
|---|---|---|
| Conversation | Long discussion and side quests | Cut by task boundary |
| Files | Reading huge files whole | Search first, then read narrow ranges |
| Tool output | Long logs and repeated failures | Summarize into a note |
| Memory | Oversized CLAUDE.md | Move details to rules or docs |
Use /context, /compact, /clear, and /memory differently
/context usage दिखाता है. /compact summary बनाकर continue करता है. /clear real task boundary पर fresh start देता है. /memory CLAUDE.md और auto memory दिखाता है.
/context all
/compact focus on files changed, failing tests, and next command
/clear
/memory
Set a context budget before the task
Task start पर objective, scope, out-of-scope, done criteria और verification commands दें. Whole repo पढ़वाने से पहले rg और selected files use करें.
# narrow discovery before asking Claude to read files
rg -n "getUserById|User not found|auth middleware" src tests
git diff --stat
npm test -- --runInBand
Copy-paste runbook for long work
यह runbook refactor, security fix, long article और conversion experiment में काम आता है. Session छोटा रहता है और receipt बचती है.
## Task brief
- Objective:
- In scope:
- Out of scope:
- Files likely involved:
- Done when:
- Verification commands:
## Handoff receipt
- Changed files:
- Commands run:
- Result:
- Remaining risk:
- Next best action:
What survives compaction
/compact के बाद root CLAUDE.md और auto memory वापस आते हैं. Nested CLAUDE.md और path-scoped rules matching file पढ़ने पर लौटते हैं.
# CLAUDE.md
## Compact Instructions
- Keep the current business objective and monetization hypothesis.
- Keep changed files, verification commands, deploy state, and blockers.
- Drop raw logs unless a line explains the root cause.
- If article work is in progress, preserve slug, locale list, and quality gaps.
Three use cases: code, content, conversion
- Large refactor में broad research subagent या separate session को दें.
- Publishing में raw research Obsidian, editorial rules CLAUDE.md और final MDX repo में रखें.
- Conversion में metric, hypothesis, change और verification result को small ticket रखें.
Common failures and fixes
- /compact full transcript backup नहीं है; durable constraints files में रखें.
- Massive discovery के बाद पहले short note बनाएं, फिर implement करें.
- Auto memory shared team docs नहीं है. Shared rules committed CLAUDE.md में रखें.
How Obsidian fits in
This workflow works with CLAUDE.md best practices, token optimization, prompt engineering, and Obsidian workflow. Team setup can start from consultation page.
| Place | Best information |
|---|---|
| CLAUDE.md | Short rules needed every session |
| Obsidian | Long research, hypotheses, article ideas |
| MDX / docs | Published content, specs, handoff notes |
| Auto memory | Local preferences and repeated learnings |
What was verified
Article को official context window, commands और memory docs के आधार पर update किया गया. Official references: context window, commands, memory, and common workflows.
मुफ़्त PDF: Claude Code cheatsheet
Email डालें और commands, review habits तथा safe workflow वाली एक-page PDF पाएँ.
हम आपका data सुरक्षित रखते हैं और spam नहीं भेजते.
लेखक के बारे में
Masa
Claude Code workflow और team adoption पर काम करने वाला engineer.
संबंधित लेख
Claude Code Permission Receipt Pattern: scope, proof और rollback लिखना
Claude Code के लिए permission receipt: allowed actions, approval boundary, verification commands, rollback note और revenue CTA checks।
Claude Code और Codex के लिए सुरक्षित Agent Harness: permissions, verification और rollback
Claude Code और Codex agents के लिए सुरक्षित harness: permissions, plan, verification और rollback.
Claude Code Subagents गाइड: article और code work को सुरक्षित तरीके से delegate करें
Claude Code subagents से article और code work बांटें: delegation rules, prompts, pitfalls, checklist और examples.