Manajemen konteks Claude Code: /context, /compact, CLAUDE.md, dan Obsidian
Panduan praktis menjaga sesi Claude Code tetap fokus dengan /context, /compact, memory, dan catatan eksternal.
Banyak sesi Claude Code melemah karena log lama, hasil baca file, dan keputusan sementara memenuhi konteks. Manajemen konteks berarti memisahkan informasi yang dibutuhkan sekarang dari catatan jangka panjang.
/context menunjukkan penggunaan saat ini, /compact merangkum percakapan, /clear memulai baru, dan /memory mengecek file memory yang dimuat.
Tujuan praktisnya adalah menjaga sesi utama tetap fokus sementara research panjang, catatan mentah, dan log lama berada di luar window aktif.
Think of the context window as the working desk
Context window berisi history, file yang dibaca, output tool, CLAUDE.md, auto memory, rules, dan skills. Saat penuh, constraint penting bersaing dengan output lama.
| 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 menunjukkan usage. /compact merangkum dan lanjut. /clear cocok untuk batas tugas nyata. /memory menampilkan CLAUDE.md dan auto memory.
/context all
/compact focus on files changed, failing tests, and next command
/clear
/memory
Set a context budget before the task
Sebelum mulai, tulis objective, scope, out-of-scope, done criteria, dan command verifikasi. Jangan baca seluruh repo jika rg dan beberapa file cukup.
# 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 ini membantu refactor, security fix, artikel panjang, dan eksperimen conversion. Sesi tetap kecil dan ada 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
Setelah /compact, root CLAUDE.md dan auto memory kembali. File nested dan path-scoped rules kembali setelah file cocok dibaca.
# 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
- Untuk refactor besar, delegasikan research luas ke subagent atau sesi terpisah.
- Untuk publishing, raw research di Obsidian, editorial rules di CLAUDE.md, final MDX di repo.
- Untuk conversion, simpan metric, hypothesis, change, dan verification result sebagai ticket kecil.
Common failures and fixes
- /compact bukan backup transcript penuh; constraint tahan lama masuk ke file.
- Setelah discovery besar, kompres dulu menjadi catatan pendek.
- Auto memory bukan dokumentasi tim. Konvensi bersama masuk ke CLAUDE.md yang dicommit.
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
Artikel diperbarui berdasarkan docs resmi context window, commands, dan memory. Official references: context window, commands, memory, and common workflows.
PDF gratis: cheatsheet Claude Code
Masukkan email dan unduh satu halaman berisi command, kebiasaan review, dan workflow aman.
Kami menjaga datamu dan tidak mengirim spam.
Tentang penulis
Masa
Engineer yang berfokus pada workflow Claude Code praktis dan adopsi tim.
Artikel terkait
Permission receipt Claude Code: mencatat scope, bukti, dan rollback
Pola permission receipt untuk Claude Code: aksi yang diizinkan, batas approval, command verifikasi, rollback, dan cek CTA revenue.
Agent Harness Aman untuk Claude Code dan Codex: Permission, Verifikasi, dan Rollback
Rancang Agent Harness praktis untuk Claude Code dan Codex dengan policy, plan, verification, dan recovery layer.
Subagent Claude Code: panduan praktis untuk delegasi artikel dan kode
Panduan subagent Claude Code untuk membagi pekerjaan artikel dan kode: aturan delegasi, prompt, risiko, dan checklist.