Are you the author? Sign in to claim
Claude Code CLAUDE.md import-block installer for local instruction files
Claude Code CLAUDE.md import-block installer for local instruction files.
Status boundary / 状态边界
claude-keysmithis a small local helper for managing Claude CodeCLAUDE.mdimport blocks and separate Markdown instruction files. It is not a Claude Code fork, does not patch binaries, does not intercept network traffic, does not save credentials, tokens, cookies, or MCP secrets, and does not guarantee that installed instructions will improve model behavior.
claude-keysmith是一个小型本地工具,用来管理 Claude CodeCLAUDE.md中的 import 区块,以及独立存放的 Markdown 指令文件。它不是 Claude Code 分叉版,不修改二进制,不劫持网络,不保存凭证、token、cookie 或 MCP 机密,也不保证安装后的指令一定改善模型行为。
把下面这段话复制到 Codex、Claude Code、Cursor Agent 或其他智能体:
请使用 https://github.com/Jia-Ethan/claude-keysmith 帮我安全安装 Claude Code 的 user scope 本地 CLAUDE.md import-block 指令文件,也就是写入 ~/.claude/CLAUDE.md 和 ~/.claude/keysmith/<name>.md。先阅读 README 和脚本,默认只做静态审计和 dry-run,不要直接写入;写入前展示将修改的准确文件路径、备份路径和 import block,并等我确认;确认后先备份再安装。不要修改 Claude Code 二进制、settings、MCP、网络、运行进程,也不要保存任何 token、cookie 或私密配置。
本项目接受 LINUX DO 社区佬友监督与反馈:LINUX DO
同系列项目 / Same series:
CLAUDE.md 的受管理 import-block 安装器,用于本地 Markdown 指令文件。 / Managed Claude Code CLAUDE.md import-block installer for local Markdown instruction files.system-role.md 接入 runtime customSystemPrompt 的 system-message 路径。 / Managed true system-role entrypoint for ZCode App; an agent-server wrapper routes system-role.md into the runtime customSystemPrompt system-message path.AGENTS.md 指令部署工具,支持 compat/hook 隔离、中断恢复与分层卸载。 / Global AGENTS.md instruction deployment for Grok Build with compat/hook isolation, interruption recovery, and layered uninstall.Claude Code already supports persistent instructions through CLAUDE.md, CLAUDE.local.md, project .claude files, and @path/to/import imports. This tool does not replace that system. It only gives you a safer, repeatable way to place one instruction file under a keysmith-managed directory and insert a small managed import block into the appropriate Claude memory file.
Official references:
claude-keysmith 是 codex-keysmith 思路的 Claude Code 版改造。原项目围绕 Codex CLI 的 model_instructions_file 与 ~/.codex/config.toml;本项目不写 Codex 配置,也不写 Claude Code 的真实设置 JSON、token、cookie、MCP 或二进制。
Claude Code 版的核心是:
CLAUDE.md 或 CLAUDE.local.md 中插入一个可识别、可卸载的 import block;| scope | 被修改的 Claude memory 文件 | 指令文件位置 | import 目标 |
|---|---|---|---|
user | ~/.claude/CLAUDE.md | ~/.claude/keysmith/<name>.md | @keysmith/<name>.md |
project | <repo>/CLAUDE.md | <repo>/.claude/keysmith/<name>.md | @.claude/keysmith/<name>.md |
local | <repo>/CLAUDE.local.md | <repo>/.claude/keysmith/<name>.md | @.claude/keysmith/<name>.md |
Managed block example:
<!-- claude-keysmith:start name=claude-project-rules -->
@.claude/keysmith/claude-project-rules.md
<!-- claude-keysmith:end name=claude-project-rules -->
--yes 时只预览,不写入;如果 --dry-run 和 --yes 同时出现,--dry-run 优先。CLAUDE.md / CLAUDE.local.md。uninstall 只移除同名 managed block,并备份后移除对应 keysmith 指令文件。restore 会先备份当前 target,再用指定 backup 恢复。--name 只允许字母、数字、点、下划线、连字符,拒绝路径、绝对路径、..、空文件名和空格。~/.claude/settings.json、.claude/settings.json、MCP、凭证、二进制或运行中进程。先预览,不写入:
python3 claude-instruct.py install --scope project --project-dir /path/to/repo
确认后写入项目级规则:
python3 claude-instruct.py install \
--scope project \
--project-dir /path/to/repo \
--name claude-project-rules \
--yes
安装到用户级 ~/.claude/CLAUDE.md:
python3 claude-instruct.py install --scope user --name personal-rules --yes
安装到本地项目偏好 CLAUDE.local.md:
python3 claude-instruct.py install \
--scope local \
--project-dir /path/to/repo \
--name local-rules \
--yes
使用自己的 Markdown 指令文件:
python3 claude-instruct.py install \
--scope project \
--project-dir /path/to/repo \
--file ./my-claude-rules.md \
--name team-rules \
--yes
python3 claude-instruct.py status --scope project --project-dir /path/to/repo --name team-rules
JSON 输出:
python3 claude-instruct.py status --scope user --name personal-rules --json
默认只预览:
python3 claude-instruct.py uninstall --scope project --project-dir /path/to/repo --name team-rules
确认卸载:
python3 claude-instruct.py uninstall --scope project --project-dir /path/to/repo --name team-rules --yes
uninstall 不会清空整份 CLAUDE.md;它只删除:
<!-- claude-keysmith:start name=team-rules -->
...
<!-- claude-keysmith:end name=team-rules -->
以及对应的 .claude/keysmith/team-rules.md 文件。
从指定备份恢复:
python3 claude-instruct.py restore \
--target /path/to/repo/CLAUDE.md \
--backup /path/to/repo/CLAUDE.md.bak_YYYYMMDD_HHMMSS \
--yes
没有 --yes 时只预览,不写入。
python3 -m py_compile claude-instruct.py
python3 -m pytest tests
额外建议用临时 HOME / 临时 project directory 跑 user、project、local 三种 scope,确认不会触碰真实 Claude Code 配置。
claude-keysmith/
├── claude-instruct.py
├── examples/
│ └── claude-project-rules.md
├── tests/
│ └── test_claude_instruct.py
├── README.md
├── LICENSE
└── .gitignore
pip install 工具。claude-keysmith 自己插入的 HTML 注释区块。/memory 或真机 smoke test 确认。.claude/rules/、settings、hooks、permissions、MCP 或自动记忆目录。claude-keysmith is a local helper for installing Markdown instruction files into Claude Code's official memory/import model. It writes a separate instruction file and inserts a small managed import block into CLAUDE.md or CLAUDE.local.md.
It is adapted from the safety posture of codex-keysmith, but it intentionally does not reuse Codex-specific logic such as ~/.codex/config.toml or model_instructions_file.
| scope | Memory file | Instruction file | Import target |
|---|---|---|---|
user | ~/.claude/CLAUDE.md | ~/.claude/keysmith/<name>.md | @keysmith/<name>.md |
project | <repo>/CLAUDE.md | <repo>/.claude/keysmith/<name>.md | @.claude/keysmith/<name>.md |
local | <repo>/CLAUDE.local.md | <repo>/.claude/keysmith/<name>.md | @.claude/keysmith/<name>.md |
Preview install:
python3 claude-instruct.py install --scope project --project-dir /path/to/repo
Write after explicit confirmation:
python3 claude-instruct.py install --scope project --project-dir /path/to/repo --yes
Check status:
python3 claude-instruct.py status --scope project --project-dir /path/to/repo --name claude-project-rules
Uninstall only the matching managed block:
python3 claude-instruct.py uninstall --scope project --project-dir /path/to/repo --name claude-project-rules --yes
Restore from a selected backup:
python3 claude-instruct.py restore --target ./CLAUDE.md --backup ./CLAUDE.md.bak_YYYYMMDD_HHMMSS --yes
--yes is provided; if --dry-run and --yes are both provided, --dry-run wins.--name.uninstall removes only the matching managed block.python3 -m py_compile claude-instruct.py
python3 -m pytest tests
MIT
1000+ skills curated from Anthropic, Vercel, Stripe, and other engineering teams
Agent harness performance optimization with skills, instincts, memory, and security
Design enforcement with memory — keeps your UI consistent across a project
Detects 37 AI writing patterns and rewrites text with human rhythm across 5 voice profiles