You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

@anduril-code/ctx

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@anduril-code/ctx

Token-efficient, context-aware compression for agent pipelines.

npmnpm
Version
0.1.8
Version published
Weekly downloads
53
-76.34%
Maintainers
1
Weekly downloads
 
Created
Source

ctx

Token-aware context management for AI agents.

npm version license: MIT node >=20

Agents don't need to dump entire codebases into context. ctx gives them tools to navigate structure, rank by relevance, extract only what they need, and compress what they carry.

It ships as Claude Code skills, an MCP server, a CLI, and a library.

Claude Code Skills

The fastest way to get started. Three slash commands cover the main agent workflows:

CommandWhen to use
/ctx-explore [question or path]Navigate a codebase, research a topic, onboard to a new repo
/ctx-review [branch or range]Code review — compress diffs, outline changed files, surface risks
/ctx-test [command or file]Run tests — prune noisy output, highlight failures with structural context

Install via add-skill:

# All ctx skills
npx add-skill AndurilCode/ctx

# Or pick specific ones
npx add-skill AndurilCode/ctx --skill ctx-explore --skill ctx-review --skill ctx-test

MCP Server

For any MCP-compatible client (Claude Desktop, Cursor, etc.):

{
  "mcpServers": {
    "ctx": {
      "command": "npx",
      "args": ["ctx-mcp"]
    }
  }
}

Use the lowest-fidelity tool that answers your question:

Navigation (start here for unknown documents) ctx_sections · ctx_locate

Code intelligence ctx_tree · ctx_rank · ctx_gather · ctx_context · ctx_outline · ctx_imports · ctx_symbols · ctx_review · ctx_focus · ctx_verify

Extraction & compression ctx_extract · ctx_compact · ctx_expand · ctx_changes · ctx_prune

AI summarization (lossy, cached) ctx_summarize · ctx_batch

Typical agent reading flow:

ctx_sections → budget the doc
ctx_extract  → pull the sections you need
ctx_compact  → compress if carrying the full doc

CLI

npx @anduril-code/ctx <command> [options]
# Context assembly
ctx gather "authentication flow" --maxTokens 2000
ctx rank "error handling" --glob "**/*.ts"
ctx tree src/ --depth 3

# Code intelligence
ctx outline src/core/compact.ts
ctx imports src/stages/tables.ts
ctx symbols "compact" --kind function
ctx review "security" --diffBase main --evidence
ctx focus src/core/patch.ts::patch
ctx verify src/core/patch.ts --symbol patch --since a3b2
ctx verify src/core/patch.ts --exec

# Document navigation
ctx sections docs/api.md
ctx extract docs/api.md --onlySections "Authentication"
ctx summarize docs/api.md

# Compression
git diff | ctx changes --changes-only
cat test.log | ctx prune --profile test
cat doc.md | ctx compact | ctx expand   # round-trips exactly
ctx roundtrip doc.md                    # round-trip validation command

Library

For embedding compression primitives in your own pipeline:

npm install @anduril-code/ctx
import { compact, expand, pruneLog, compactDiff } from '@anduril-code/ctx';

// Lossless Markdown compression — expand(compact(md)) === md, always
const { output, stats } = compact(md, { dedup: true, stats: true });
console.log(stats.savings); // e.g. 0.38

// Log pruning
const { output: pruned } = pruneLog(testOutput, { profile: 'test' });

// Diff compression
const compressed = compactDiff(gitDiff, { changesOnly: true });

See TypeScript types for full option references.

Development

bun install
bun test
bun run build       # ESM + CJS + type declarations
bun run lint        # biome check
bun run typecheck   # tsc --noEmit

Contributing

Read AGENTS.md — it documents the architecture, dependency rules, and invariants.

MIT

FAQs

Package last updated on 02 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts