npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cc-expand

v0.3.8

Published

Expand Claude Code's context window beyond 200k tokens

Readme


模型性能下降的主要原因有二:自动压缩、长上下文;cc-expand 允许调整上下文窗口大小帮你绕过这两个问题:

  1. 使上下文窗口突破 200K 的限制,推迟自动压缩的时机:当使用某些模型(只支持 256K 上下文)时,Claude Code 原生 200K 的限制会成为瓶颈。cc-expand 通过修改 Claude Code 二进制中的硬编码常量,将上下文窗口大小提升到目标值。
  2. 把 1M 模型限制在 500k,以便保持在最佳性能区间:模型在 256k、512k 之后,性能下降尤为明显。

以下是详细解释。

首先是长上下文时性能下降问题,图片引用自 mimo-v2.5 pro blogs。

CC 的环境变量允许设置 COMPACT_WINDOW,但不能高于硬编码默认值。所以提高 target 可以推迟压缩时机。例如,我日常使用的 Kimi-K2.6 支持 256k,所以我会把 target 设为 270000 以便将压缩时机从约 17k 提升至 23k

| 使用前 | 使用后 | |--------|--------| | 200K 限制,约 110K 可用上下文 | 270K 限制,约 180K 可用上下文 | | | |

安装

让 AI agent 执行这句:

帮我扩展 Claude Code 的上下文窗口到 270k,使用 cc-expand(npx -y cc-expand@latest)

或可以手动安装

# use npm
npm install -g cc-expand
# or npx
npx cc-expand <command>

特性

  • 支持 Mac、Windows 双平台
  • 功能兼容,允许设置任意上下文大小,无需牺牲自动压缩特性,所以无论是扩大还是缩小上下文窗口都支持

用法

| 命令 | 说明 | |------|------| | cc-expand install [version] | 从 npm 下载 Claude Code 到 ~/.cc-expand/packages/ | | cc-expand patch [options] | 从本地包复制 binary,patch 后保存到 ~/.cc-expand/bin/ | | cc-expand run [tokens] | 启动已 patch 的 Claude Code binary | | cc-expand setup | 安装 shell 快捷方式(ccc alias,以便快速打开已经 patch 的 claude code) | | cc-expand restore | 从备份恢复原始 binary | | cc-expand verify | 验证 binary 是否已被 patch | | cc-expand status | 显示版本和 patch 状态 | | cc-expand supports | 列出支持的 Claude Code 版本 | | cc-expand --version | 列出 cc-expand 的版本 |

  • install version option: latest or v2.1.170
  • token 数量支持纯数字、千分位逗号、k 表示千、w 表示万: 256000256,000270k27w 均表示 270000 tokens
  • patch options:
    -t, --target <count>    目标上下文窗口大小(默认:256000)
    -v, --version <semver>  要 patch 的 Claude Code 版本(如 2.1.170)
    -y, --yes               跳过确认并覆盖 shell 快捷方式
  • patch 成功后,cc-expand 会自动维护 cc/c 快捷方式,使其默认目标与本次 patch 值一致。
  • run 也支持同样的简写,例如 cc-expand run 270k

支持的 CC 版本

| 版本 | darwin-arm64 | darwin-x64 | win32-x64 | linux-arm64 | linux-x64 | |------|:------------:|:----------:|:---------:|:-----------:|:---------:| | 2.1.161 | ✅ | — | — | — | — | | 2.1.162 | ✅ | — | — | — | — | | 2.1.163 | ✅ | — | — | — | — | | 2.1.169 | ✅ | ✅ | ✅ | — | — | | 2.1.170 | ✅ | ✅ | ✅ | — | — | | 2.1.172 | ✅ | ✅ | ✅ | ✅ | ✅ | | 2.1.173 | ✅ | ✅ | ✅ | ✅ | ✅ |

⚠️ cc-expand 自身版本号对应 claude --version。运行 cc-expand supports 查看动态更新的支持 cc-expand 的 CC 版本列表。

版本更新机制

Pattern 数据托管在阿里云 OSS 上,运行 cc-expand 时按需拉取,并缓存在本地 ~/.cc-expand/cache/patterns/,通过 ETag 条件请求减少流量消耗。

每半小时我的 claw 会自动执行项目内 watch-patch 技能,发现新版 Claude Code、提取混淆变量名,并将 pattern 分片上传到 OSS。你无需更新 npm 包即可获得新版本支持 —— pattern 上传 OSS 后立即生效。

但我的 claw 在许多情况会宕机。如果遇到使用的版本比 cc-expand 版本号更新的情况,请暂时使用旧版 CC(如 npx @anthropic-ai/[email protected])。

进阶用户也可以选择让你的 Agent:

我需要更新版 CC 的上下文窗口大小,但 cc-expand 尚不支持的我使用的版本。
你需要拉取本项目源码,阅读 `<project-root>/.claude/skills/watch-patch` 了解算法过程并 patch。
最终将我的 CC 设置为 270k 上下文大小。

支持我

请 Star 以支持我开发更多有趣的应用。

许可证

MIT © Lionad Morotar