Agent Skillsyvgude/lean-ctx › lean-ctx

lean-ctx

GitHub

为AI代理提供本地上下文管理SDK,支持文件读写、Shell执行及代码分析。通过锚点编辑和多种读取模式优化上下文,提升推理效率并防止上下文膨胀。

rust/src/templates/SKILL.md yvgude/lean-ctx

Trigger Scenarios

需要高效读取或编辑大文件时 执行Shell命令以获取环境状态时 进行代码结构分析或影响范围评估时

Install

npx skills add yvgude/lean-ctx --skill lean-ctx -g -y
More Options

Non-standard path

npx skills add https://github.com/yvgude/lean-ctx/tree/main/rust/src/templates -g -y

Use without installing

npx skills use yvgude/lean-ctx@lean-ctx

指定 Agent (Claude Code)

npx skills add yvgude/lean-ctx --skill lean-ctx -a claude-code -g -y

安装 repo 全部 skill

npx skills add yvgude/lean-ctx --all -g -y

预览 repo 内 skill

npx skills add yvgude/lean-ctx --list

SKILL.md

Frontmatter
{
    "name": "lean-ctx",
    "description": "Local context tooling for AI agents. Use it to select, shape, reuse, recover, and inspect context before inference when reading files, running shell commands, searching code, or exploring directories."
}

lean-ctx — Local Context SDK for AI Agents

Setup

which lean-ctx || curl -fsSL https://raw.githubusercontent.com/yvgude/lean-ctx/main/skills/lean-ctx/scripts/install.sh | bash
lean-ctx setup

Tool Visibility Profiles

Profile Tools advertised
Lean (default, unpinned) ctx_read, ctx_shell, shell, ctx_search, ctx_glob, ctx_tree, ctx_session, ctx_compose, ctx_callgraph, ctx_patch*, ctx_call, ctx_expand
minimal ctx_read, ctx_shell, ctx_search, ctx_glob, ctx_tree; ctx_call is also advertised as the fallback invoker
standard Minimal + ctx_compose, ctx_explore, ctx_knowledge, ctx_session, ctx_callgraph, ctx_graph, ctx_delta, ctx_execute, ctx_expand, ctx_overview, ctx_url_read, ctx_patch; ctx_call is also advertised as the fallback invoker
power Full public tool registry

* Lean hides ctx_patch for clients with a reliable native editor. Disabled tools, role policy, and client compatibility can further narrow every profile.

Shell Hook (use instead of raw exec)

lean-ctx -c "git status"
lean-ctx -c "cargo test"
lean-ctx -c "npm install"
lean-ctx ls src/

ctx_read Modes

Mode When
anchored Files you will edit (full text + N:hh| anchors for ctx_patch)
full Verbatim cached read
map Context-only (deps + exports)
signatures API surface only
diff After edits (changed lines)
aggressive Large files, syntax-stripped; JSON arrays row-deduped (lossless)
entropy Shannon filtering
task Task-relevant lines
lines:N-M Specific range
auto System selects optimal

Re-reads may use the local cache. Set fresh=true to bypass it. Redundant JSON (arrays of like objects) is crushed losslessly into a compact _defaults + per-row form; if a slice was dropped, recover it with ctx_expand(id, json_path=… | search=…).

File Editing

Anchored editing keeps an exact, source-addressable view: ctx_read(mode="anchored")ctx_patch(path, op, line, hash, new_text). Never reproduce old text byte-for-byte; batch via ops:[…]; op=create writes new files. Stale anchor → CONFLICT with fresh anchors (retry once). Native Edit/StrReplace stay fine; ctx_edit (str_replace) is the legacy fallback via ctx_call/power profile.

More Tools (via ctx_call or ctx_load_tools)

Architecture: ctx_symbol, ctx_callgraph, ctx_impact, ctx_architecture, ctx_routes, ctx_smells, ctx_quality ↳ "What breaks if I change this file/class/type?" → ctx_impact (file-level blast radius; resolves same-package/namespace type usage with no import for C#, Java, Go and Kotlin). "Who calls this function?" → ctx_callgraph (symbol-level). "How navigable / how much is complexity costing me?" → ctx_quality (navigability score + token quality tax). Experimental local collaboration (explicit opt-in only): ctx_agent, ctx_share, ctx_task, ctx_handoff, ctx_workflow Verify: ctx_benchmark, ctx_verify, ctx_proof, ctx_review Batch: ctx_fill, ctx_execute, ctx_expand, ctx_pack

Full docs: https://leanctx.com/docs

Version History

  • 5a90893 Current 2026-08-27 17:47

    清理20K行代码模块后移除一个工具,更新文档反映83个工具总数;从路径防火墙白名单中删除已删除的tui组件。

  • 995c9e1 2026-08-19 20:03

    更新工具数量至84个;修复CI流水线故障;解决cli_ls回归问题;完善锁顺序文档及静态统计信息。

  • 8c9c8dd 2026-08-16 07:10

    R35版本实现Phase 0-3功能,统一工具数量为79,增强质量门控、知识路由及基准测试;修复CI LOC限制和工具计数漂移问题。

  • fe36c06 2026-07-24 16:13

Same Skill Collection

skills/lean-ctx-review/SKILL.md
skills/lean-ctx/SKILL.md

Metadata

Files
0
Version
e710e85
Hash
31febfba
Indexed
2026-07-24 16:13

Accueil - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-09-10 18:58
浙ICP备14020137号-1 $Carte des visiteurs$