109개의 실습 프로젝트를 담은 AI 에이전트 설계 오픈소스 도서.
한국어는 runchr 제공 번역입니다. 원문 README는 English tool page.
context-mode
도구 출력을 샌드박싱하여 컨텍스트를 98% 절감하고, 세션 메모리를 지속하며, hooks를 통해 17개 플랫폼 전반에 라우팅을 강제하는 MCP 서버입니다.
- Transport
- stdio
- Package
- context-mode
- Version
- latest
- Website
- https://www.npmjs.com/package/context-mode
프로젝트 README (번역)
GitHub ↗Written by the project's own authors, not by runchr. Snapshot taken 2026-10-28.
Context Mode
컨텍스트 문제의 나머지 절반.
다음 팀들에서 사용 중
문제
모든 MCP 도구 호출은 원시 데이터를 컨텍스트 윈도우에 쏟아붓습니다. Playwright 스냅샷 하나에 56 KB. GitHub 이슈 20개에 59 KB. 액세스 로그 하나에 45 KB. 30분이 지나면 컨텍스트의 40%가 사라집니다. 그리고 에이전트가 공간을 확보하기 위해 대화를 압축(compact)할 때, 어떤 파일을 편집 중이었는지, 어떤 작업이 진행 중인지, 마지막으로 무엇을 요청했는지를 잊어버립니다. 게다가 에이전트는 군더더기, 인사말, 장황한 설명에 출력 토큰을 낭비하며 양쪽 모두에서 컨텍스트를 소모합니다.
Context Mode가 이를 해결하는 방법
Context Mode는 이 문제의 네 가지 측면을 모두 해결하는 MCP 서버입니다:
컨텍스트 절약 — 샌드박스 도구가 원시 데이터를 컨텍스트 윈도우 밖에 유지합니다. 315 KB가 5.4 KB가 됩니다. 98% 감소.
세션 연속성 — 모든 파일 편집, git 작업, 태스크, 오류, 사용자 결정이 SQLite에 추적됩니다. 대화가 압축될 때 context-mode는 이 데이터를 다시 컨텍스트에 쏟아붓지 않고, 이벤트를 FTS5에 인덱싱하고 BM25 검색을 통해 관련 있는 것만 검색합니다. 모델은 정확히 멈춘 지점에서 이어갑니다. --continue 를 사용하지 않으면 이전 세션 데이터는 즉시 삭제됩니다 — 새 세션은 깨끗한 출발을 의미합니다.
코드로 사고하기 — LLM은 분석을 계산하는 것이 아니라 프로그래밍해야 합니다. 함수를 세기 위해 50개 파일을 컨텍스트로 읽어들이는 대신, 에이전트는 카운팅을 수행하고 결과만 console.log() 하는 스크립트를 작성합니다. 스크립트 하나가 도구 호출 열 개를 대체하고 컨텍스트를 100배 절약합니다. 이는 지원되는 17개 클라이언트 전체와 OpenClaw 게이트웨이 통합에 걸쳐 필수 패러다임입니다: LLM을 데이터 처리자로 취급하지 말고, 코드 생성자로 취급하세요.
// Before: 47 × Read() = 700 KB. After: 1 × ctx_execute() = 3.6 KB.
ctx_execute ( "javascript" , `
const files = fs.readdirSync('src').filter(f => f.endsWith('.ts'));
files.forEach(f => console.log(f + ': ' + fs.readFileSync('src/'+f,'utf8').split('\\n').length + ' lines'));
` ) ;
산문 스타일 강제 없음 — context-mode는 원시 데이터를 컨텍스트 밖에 유지하지만 모델이 최종 답변을 작성하는 방식을 결코 강제하지 않습니다. 간결함, 완전성, 포맷팅 — 모델의 판단(또는 여러분의 CLAUDE.md / AGENTS.md 를 통한 여러분의 판단)입니다. 공격적인 간결성 프롬프트는 코딩/추론 벤치마크를 저하시키는 것으로 나타났습니다( Moonshot AI on kimi-k2.5 ) — 라우팅 블록은 데이터가 어디로 가는지 에 집중하며, 모델이 어떻게 말하는지에는 집중하지 않습니다.
설치
플랫폼은 설치 복잡도에 따라 그룹화됩니다. 훅을 지원하는 플랫폼은 자동 라우팅 강제를 받습니다. 훅이 없는 플랫폼은 일회성 라우팅 파일 복사가 필요합니다.
Claude Code — 플러그인 마켓플레이스, 완전 자동
사전 요구사항: Claude Code v1.0.33+ ( claude --version ). /plugin 이 인식되지 않으면 먼저 업데이트하세요: brew upgrade claude-code 또는 npm update -g @anthropic-ai/claude-code .
설치:
/plugin marketplace add mksglu/context-mode
/plugin install context-mode@context-mode
Claude Code를 재시작하세요(또는 /reload-plugins 실행).
확인:
/context-mode:ctx-doctor
모든 검사가 [x] 를 표시해야 합니다. doctor는 런타임, 훅, FTS5, 플러그인 등록을 검증합니다.
라우팅: 자동. SessionStart 훅이 런타임에 라우팅 지침을 주입합니다 — 프로젝트에 파일이 작성되지 않습니다. 플러그인은 모든 훅(PreToolUse, PostToolUse, UserPromptSubmit, PreCompact, SessionStart, Stop)과 11개의 MCP 도구를 등록합니다 — 여섯 개의 샌드박스 도구( ctx_batch_execute , ctx_execute , ctx_execute_file , ctx_index , ctx_search , ctx_fetch_and_index )와 다섯 개의 메타 도구( ctx_stats , ctx_doctor , ctx_upgrade , ctx_purge , ctx_insight ).
슬래시 명령
기능
/context-mode:ctx-stats
컨텍스트 절약 — 도구별 분석, 소비된 토큰, 절약 비율.
/context-mode:ctx-doctor
진단 — 런타임, 훅, FTS5, 플러그인 등록, 버전.
/context-mode:ctx-index
로컬 파일 또는 디렉터리를 영구 FTS5 지식 베이스에 인덱싱.
/context-mode:ctx-search
이전에 인덱싱된 콘텐츠 검색.
/context-mode:ctx-upgrade
최신 버전 가져오기, 재빌드, 캐시 마이그레이션, 훅 수정.
/context-mode:ctx-purge
지식 베이스에서 모든 인덱싱된 콘텐츠를 영구 삭제.
/context-mode:ctx-insight
브라우저에서 호스팅되는 Insight 대시보드( context-mode.com/insight )를 엽니다 — AI 지원 엔지니어링 팀을 위한 조직 분석.
참고: 슬래시 명령은 Claude Code 플러그인 기능입니다. 다른 플랫폼에서는 채팅에 ctx stats , ctx doctor , ctx index , ctx search , ctx upgrade , 또는 ctx insight 를 입력하세요 — 모델이 MCP 도구를 자동으로 호출합니다. Utility Commands 를 참조하세요.
상태 표시줄(선택 사항): Claude Code의 플러그인 매니페스트는 상태 표시줄을 선언할 수 없으므로, 이는 ~/.claude/settings.json 에 대한 일회성 수동 편집입니다:
{
"statusLine" : {
"type" : " command " ,
"command" : " context-mode statusline "
}
}
저장 후 Claude Code를 재시작하세요. 표시줄은 이 세션에서 절약된 $ · 모든 세션에 걸쳐 절약된 $ · 효율 % 를 보여주므로 절약이 실시간으로 누적되는 것을 볼 수 있습니다. 연결은 경로에 의존하지 않습니다 — context-mode statusline 은 플러그인 캐시가 어디에 있든 번들 CLI를 통해 해석됩니다.
대안 — MCP 전용 설치(훅 또는 슬래시 명령 없음)
claude mcp add context-mode -- npx -y context-mode
이렇게 하면 자동 라우팅 없이 11개의 MCP 도구를 모두 사용할 수 있습니다. 모델은 여전히 이를 사용할 수 있습니다 — 다만 원시 Bash/Read/WebFetch보다 이를 선호하도록 유도되지 않을 뿐입니다. 전체 플러그인을 적용하기 전에 시험해보기에 좋습니다.
Gemini CLI — 설정 파일 하나, 훅 포함
사전 요구사항: Node.js >= 22.5 (또는 Bun), Gemini CLI 설치됨.
설치:
context-mode를 전역으로 설치:
npm install -g context-mode
다음을 ~/.gemini/settings.json 에 추가하세요. 이 단일 파일이 MCP 서버와 네 개의 훅을 모두 등록합니다:
{
"mcpServers" : {
"context-mode" : {
"command" : " context-mode "
}
},
"hooks" : {
"BeforeTool" : [
{
"matcher" : " run_shell_command|read_file|read_many_files|grep_search|search_file_content|web_fetch|activate_skill|mcp__plugin_context-mode|mcp__context-mode|mcp__(?!.*context-mode) " ,
"hooks" : [{ "type" : " command " , "command" : " context-mode hook gemini-cli beforetool " }]
}
],
"AfterTool" : [
{
"matcher" : " " ,
"hooks" : [{ "type" : " command " , "command" : " context-mode hook gemini-cli aftertool " }]
}
],
"PreCompress" : [
{
"matcher" : " " ,
"hooks" : [{ "type" : " command " , "command" : " context-mode hook gemini-cli precompress " }]
}
],
"SessionStart" : [
{
"matcher" : " " ,
"hooks" : [{ "type" : " command " , "command" : " context-mode hook gemini-cli sessionstart " }]
}
]
}
}
Gemini CLI를 재시작하세요.
확인:
/mcp list
context-mode: ... - Connected 가 표시되어야 합니다.
라우팅: SessionStart 훅을 통해 자동. 선택적으로 전체 모델 인식을 위해 라우팅 지침을 복사:
cp node_modules/context-mode/configs/gemini-cli/GEMINI.md ./GEMINI.md
BeforeTool matcher가 필요한 이유? 대량 출력을 생성하는 도구( run_shell_command , read_file , read_many_files , grep_search , search_file_content , web_fetch , activate_skill )와 context-mode 자체 도구( mcp__plugin_context-mode )만 대상으로 합니다. 이렇게 하면 컨텍스트 윈도우를 범람시킬 수 있는 모든 도구를 가로채면서 경량 도구에 대한 불필요한 훅 오버헤드를 피할 수 있습니다.
전체 설정 참조: configs/gemini-cli/settings.json
VS Code Copilot — SessionStart가 있는 훅
사전 요구사항: Node.js >= 22.5 (또는 Bun), Copilot Chat v0.32+가 있는 VS Code.
설치:
context-mode를 전역으로 설치:
npm install -g context-mode
프로젝트 루트에 .vscode/mcp.json 생성:
{
"servers" : {
"context-mode" : {
"command" : " context-mode "
}
}
}
.github/hooks/context-mode.json 생성:
{
"hooks" : {
"PreToolUse" : [
{ "type" : " command " , "command" : " context-mode hook vscode-copilot pretooluse " }
],
"PostToolUse" : [
{ "type" : " command " , "command" : " context-mode hook vscode-copilot posttooluse " }
],
"SessionStart" : [
{ "type" : " command " , "command" : " context-mode hook vscode-copilot sessionstart " }
]
}
}
VS Code를 재시작하세요.
확인: Copilot Chat을 열고 ctx stats 를 입력하세요. Context-mode 도구가 나타나고 응답해야 합니다.
라우팅: SessionStart 훅을 통해 자동. 선택적으로 전체 모델 인식을 위해 라우팅 지침을 복사:
cp node_modules/context-mode/configs/vscode-copilot/copilot-instructions.md .github/copilot-instructions.md
PreCompact를 포함한 전체 훅 설정: configs/vscode-copilot/hooks.json
JetBrains Copilot — SessionStart가 있는 훅
사전 요구사항: Node.js >= 22.5 (또는 Bun), GitHub Copilot 플러그인 v1.5.57+가 있는 JetBrains IDE.
설치:
context-mode를 전역으로 설치:
npm install -g context-mode
Settings UI를 통해 MCP 서버 추가: Settings > Tools > AI Assistant > Model Context Protocol (MCP) > Add Server :
Name: context-mode
Command: context-mode
.github/hooks/context-mode.json 생성:
{
"hooks" : {
"PreToolUse" : [
{ "type" : " command " , "command" : " context-mode hook jetbrains-copilot pretooluse " }
],
"PostToolUse" : [
{ "type" : " command " , "command" : " context-mode hook jetbrains-copilot posttooluse " }
],
"SessionStart" : [
{ "type" : " command " , "command" : " context-mode hook jetbrains-copilot sessionstart " }
]
}
}
JetBrains IDE를 재시작하세요.
확인: Copilot Chat을 열고 ctx stats 를 입력하세요. Context-mode 도구가 나타나고 응답해야 합니다.
라우팅: SessionStart 훅을 통해 자동. 선택적으로 전체 모델 인식을 위해 라우팅 지침을 복사:
cp node_modules/context-mode/configs/jetbrains-copilot/copilot-instructions.md .github/copilot-instructions.md
PreCompact를 포함한 전체 훅 설정: configs/jetbrains-copilot/hooks.json
전체 설정 가이드: docs/jetbrains-copilot.md
GitHub Copilot CLI — MCP + 훅
사전 요구사항: Node.js >= 22.5 (또는 Bun), GitHub Copilot CLI( copilot ) 설치됨. 격리된 Copilot 홈을 사용하는 경우 먼저 COPILOT_HOME 을 설정하세요.
설치 — 옵션 A(플러그인, 명령 하나 — 권장):
npm install -g context-mode # the plugin's MCP server runs the global binary
copilot plugin install mksglu/context-mode:configs/copilot-cli # registers MCP + hooks + routing skill
번들의 .mcp.json 은 CONTEXT_MODE_PLATFORM=copilot-cli 를 고정하므로, context-mode는 자신을 Copilot으로 식별합니다 — Claude Code가 함께 설치된 경우(그렇지 않으면 그 ~/.claude/ 가 우선함)에도 ctx_upgrade 와 플랫폼 감지가 copilot-cli로 해석됩니다. context-mode upgrade / agent 호출이 필요 없습니다. 기본 브랜치에 반영되기 전에 로컬 클론에서 시험하려면 Copilot을 번들 디렉터리로 지정하세요: copilot --plugin-dir /path/to/context-mode/configs/copilot-cli .
설치 — 옵션 B(수동, 플러그인 없음):
context-mode를 전역으로 설치:
npm install -g context-mode
Copilot CLI의 내장 명령으로 MCP 서버 등록( ~/.copilot/mcp-config.json 을 대신 작성):
copilot mcp add context-mode -- context-mode
~/.copilot/hooks/context-mode.json (또는 $COPILOT_HOME/hooks/context-mode.json )에 훅 구성. 설정은 평면 { "type": "command", "command": "..." } 항목을 사용합니다; context-mode는 최상위 "version": 1 도 작성하지만, 이 필드는 선택 사항입니다 — Copilot CLI는 이를 생략한 훅 설정을 허용합니다(자기 문서화 목적으로만 고정됨). Copilot CLI는 context-mode가 사용하는 여섯 개의 이벤트를 발생시킵니다:
{
"version" : 1 ,
"hooks" : {
"preToolUse" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli pretooluse " }],
"postToolUse" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli posttooluse " }],
"preCompact" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli precompact " }],
"sessionStart" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli sessionstart " }],
"userPromptSubmitted" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli userpromptsubmit " }],
"agentStop" : [{ "type" : " command " , "command" : " context-mode hook copilot-cli stop " }]
}
}
또는 context-mode가 이 훅 파일을 대신 작성하도록 하세요: context-mode upgrade (Copilot CLI 컨텍스트에서 실행하거나 CONTEXT_MODE_PLATFORM=copilot-cli 와 함께). upgrade는 훅 파일만 작성합니다 — 2단계에서 copilot mcp add 로 MCP 서버를 등록하세요.
Copilot CLI를 재시작하세요.
플러그인: 위의 옵션 A는 Copilot CLI의 플러그…
Other tools that do the same work
브라우징하고, 파일을 편집하고, 명령을 실행하고, 기억하는 로컬 우선 AI 에이전트
Claude Code를 위한 자기 학습 스킬 레이어로, 증류하고 병합하고 정리합니다
Agent stacks with this tool(1)View graph
Context Mode: 코딩 에이전트를 위한 샌드박스형 컨텍스트 윈도우 압축
From README links그들은 codex와 opencode로 긴 에이전틱 코딩 세션을 진행하다가 같은 벽에 계속 부딪혔다. 파일 읽기, 테스트 실행, 로그 덤프가 매번 컨텍스트 윈도우에 그대로 쌓여서, 에이전트가 결국 작업을 잊어버리거나 잘린 출력 주변에서 환각을 일으키기 시작했다. 그들은 npm에서 context-mode를 설치하고 에이전트
View stack
No comments yet.
to comment.