Advanced (Diperbarui: 1/6/2026)

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.

Manajemen konteks Claude Code: /context, /compact, CLAUDE.md, dan Obsidian

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 contextWhy it gets heavyPractical response
ConversationLong discussion and side questsCut by task boundary
FilesReading huge files wholeSearch first, then read narrow ranges
Tool outputLong logs and repeated failuresSummarize into a note
MemoryOversized CLAUDE.mdMove 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

  1. Untuk refactor besar, delegasikan research luas ke subagent atau sesi terpisah.
  2. Untuk publishing, raw research di Obsidian, editorial rules di CLAUDE.md, final MDX di repo.
  3. Untuk conversion, simpan metric, hypothesis, change, dan verification result sebagai ticket kecil.

Common failures and fixes

  1. /compact bukan backup transcript penuh; constraint tahan lama masuk ke file.
  2. Setelah discovery besar, kompres dulu menjadi catatan pendek.
  3. 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.

PlaceBest information
CLAUDE.mdShort rules needed every session
ObsidianLong research, hypotheses, article ideas
MDX / docsPublished content, specs, handoff notes
Auto memoryLocal 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.

#claude-code #manajemen konteks #optimasi token #produktivitas
Gratis

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.

Masa

Tentang penulis

Masa

Engineer yang berfokus pada workflow Claude Code praktis dan adopsi tim.