compact-ctx

compact-ctx is a command for coding agents from Ramsbaby/jarvis. It costs 49 tokens per session (772 once invoked), scanned A, original, MIT.

A command for managing a coding session when its conversation history becomes large. It explains when to compact the context, start a new session, split work, or use another agent.

In plain words
What is it for?
Use it to check context usage, run or recommend compaction, divide large projects across sessions, and preserve intermediate results in files.
Why use it?
It helps reduce the amount of old conversation that must be carried forward, while keeping the current work understandable.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/ramsbaby/jarvis/compact-ctx
Clone the repo
git clone --depth 1 https://github.com/Ramsbaby/jarvis

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for compact-ctx

README.md
[![agentmods](https://agentmods.dev/badge/commands/ramsbaby/jarvis/compact-ctx.svg)](https://agentmods.dev/commands/ramsbaby/jarvis/compact-ctx)
Your own site
<a href="https://agentmods.dev/commands/ramsbaby/jarvis/compact-ctx"><img src="https://agentmods.dev/badge/commands/ramsbaby/jarvis/compact-ctx.svg" alt="Measured on agentmods" height="20"></a>
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 772 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00049 $0.00772
Opus 5 $0.00024 $0.00386
Sonnet 5 $0.00010 $0.00154
Haiku 4.5 $0.00005 $0.00077

Measured 5d ago against content hash e68527aba6ef, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

compact-ctx scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

dotfiles/claude/commands/compact-ctx.md · 100 lines

What it actually says

컨텍스트 압축 전략 (Compact Context)

현재 세션의 컨텍스트를 효율적으로 관리합니다.


현재 상태 확인

먼저 현재 세션의 토큰 사용량을 확인합니다:

/usage

컨텍스트 압축 기준

사용률 상태 조치
0-50% 여유 정상 진행
50-70% 주의 대용량 출력 자제, 필요시 압축
70-85% 경고 /compact 실행 권장
85%+ 위험 즉시 /compact 또는 /new

압축 전략

전략 1: /compact 사용 (권장)

/compact

현재 대화를 요약하여 컨텍스트를 줄입니다. 기존 작업 흐름은 유지됩니다.

장점: 연속성 유지 단점: 세부 내용 손실 가능

전략 2: /new로 새 세션 (깔끔한 시작)

/new

새 세션을 시작합니다. session-memory 훅이 이전 대화를 자동 저장합니다.

장점: 깨끗한 컨텍스트 단점: 수동으로 컨텍스트 복원 필요

이전 세션 내용 복원:

"이전 세션에서 [작업명] 하고 있었어. 이어서 진행해줘"

전략 3: 작업 분리 (대규모 작업)

하나의 큰 작업을 여러 세션으로 나눕니다:

  1. 세션 1: 분석 + 설계 → 결과를 파일로 저장
  2. 세션 2: 구현 → 코드 작성
  3. 세션 3: 테스트 + 리뷰

각 세션의 결과물을 파일로 남기면 다음 세션에서 읽을 수 있습니다.

전략 4: 서브에이전트 활용

탐색이 많은 작업은 서브에이전트에게 위임하면 메인 컨텍스트를 절약합니다.

  • 코드베이스 탐색 → 서브에이전트
  • 웹 검색/조사 → 서브에이전트
  • 결과만 메인 컨텍스트로 수신

컨텍스트 절약 팁

  1. 큰 파일 전체 읽기 자제: 필요한 부분만 offset/limit으로 읽기
  2. 긴 명령 출력 자제: head, tail로 출력 제한
  3. 반복 검색 자제: 한 번 찾은 정보는 메모하고 재검색 안 하기
  4. 중간 결과 파일 저장: 분석 결과를 /tmp/에 저장하고 필요시 읽기

실행 방법

  1. 상태 확인: "/compact-ctx" 실행 → 현재 사용량 + 권장 조치 안내
  2. 자동 압축: 사용률 70% 이상이면 자동으로 /compact 제안
  3. 작업 분리 가이드: 대규모 작업 시 세션 분리 계획 수립

참고

  • /compact: Claude Code 내장 컨텍스트 압축
  • /new: 새 세션 시작 (session-memory 훅이 자동 저장)
  • /usage: 현재 토큰 사용량 확인
Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 100 lines · 49 tokens per session scan A e68527aba6ef

Subscribe to this mod's changes

compact-ctx is a command published in the GitHub repository Ramsbaby/jarvis (16 stars, last pushed 13d ago), licensed MIT. It adds 49 tokens to every session and 772 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.