Skip to content

fix(claudecode):初始化Claudecode时使用CLAUDE.md#271

Closed
kkz-01 wants to merge 2 commits into
mindfold-ai:mainfrom
kkz-01:main
Closed

fix(claudecode):初始化Claudecode时使用CLAUDE.md#271
kkz-01 wants to merge 2 commits into
mindfold-ai:mainfrom
kkz-01:main

Conversation

@kkz-01
Copy link
Copy Markdown

@kkz-01 kkz-01 commented May 12, 2026

When using trellies init command and select claude code, initialize CLAUDE.md instead of AGETNS.md.
使用trellies init 命令初始化并选择Claudecode时创建CLAUDE.md而不是AGETNS.md

@kkz-01
Copy link
Copy Markdown
Author

kkz-01 commented May 12, 2026

I discovered an interesting phenomenon but I'm not sure if it's a bug. Currently, if the user chooses not to modify AGENTS.md, AGENTS.md will also be written into the.template-hashes.json file, and it will be deleted along with it when uninstalling.

我发现了一个有意思的现象但我不确定这是不是BUG,现在如果用户选择不修改AGENTS.md,AGENTS.md也会被写入到.template-hashes.json中,执行uninstall的时候会被一起删掉

Perhaps it would be better to restore AGENTS.md to its state before the user executed the init command.
或许将AGENTS.md恢复成用户执行init命令之前会更好

@taosu0216
Copy link
Copy Markdown
Contributor

trellis init 的时候本身是不需要 AGENTS.md / CLAUDE.md 的,因为都是通过 hook 注入,然后 AGENTS.md 因为是个开放标准所以才搞得;
另外删掉 AGENTS.md 确实是个 bug,感谢捉虫🙏,如果你愿意的话可以再开一个 pr 单独搞一下,如果不方便的话也可以我来搞

@kkz-01
Copy link
Copy Markdown
Author

kkz-01 commented May 13, 2026

trellis init 的时候本身是不需要 AGENTS.md / CLAUDE.md 的,因为都是通过 hook 注入,然后 AGENTS.md 因为是个开放标准所以才搞得; 另外删掉 AGENTS.md 确实是个 bug,感谢捉虫🙏,如果你愿意的话可以再开一个 pr 单独搞一下,如果不方便的话也可以我来搞

If Trellis does not need to use AGENTS.md to achieve the effect of emphasizing commands, can it not operate AGENTS.md when running the trellis init command?
如果Trellis 不需要通过AGENTS.md来起到强调命令的效果的话是不是可以在trellis init命令不操作AGENTS.md

If we need to generate AGENTS.md, wouldn't it be better to consider adapting it to the standards of Claude? I feel this statement is a bit strange because Claudecode doesn't seem to read AGENTS.md, or it could write a CLAUDE.md file that imports AGENTS.md. However, from a standard perspective, it seems a bit awkward.
如果需要生成AGENTS.md的话是不是考虑一下适配一下Claude的标准会好些?感觉这个说法有点奇怪,因为claudecode似乎不会去读AGENTS.md 或者可以写一个CLAUDE.md里面import AGENTS.md,只是标准的话感觉有些勉强

If you don't want to delete AGENTS.md, the simplest way is not to generate it. Then, don't write it into .template-hashes.json (this will have an adverse effect as it will modify the user's AGENTS.md). It seems to me that trellis uninstall deletes files based on the content of .template-hashes.json.
如果想要不删掉 AGENTS.md其实最简单的一个做法就是不要生成,再然后就是不要写入到.template-hashes.json(这样会有副作用就是把用户的AGENTS.md修改了),因为我看起来似乎trellis uninstall是根据.template-hashes.json内容删除文件的

taosu0216 pushed a commit that referenced this pull request May 13, 2026
trellis init walked managed dirs (.codex/, .claude/, .opencode/) and hashed
every file into .template-hashes.json — including pre-existing user data
(.codex/sessions/, .claude/projects/, user-owned AGENTS.md). trellis uninstall
then unlinked every manifest entry, deleting that user data. Two real reports:
GitHub Issue #221 (.codex/sessions/ wiped) and PR #271 (pre-existing AGENTS.md
wiped via skip-existing path).

Manifest is now derived from "what trellis actually wrote this run", not from
walking the disk:

- writeFile() instruments recordWrite() on actual disk writes only. byte-
  identical, skip-existing, and append paths do NOT record. initializeHashes
  consumes the recorded set instead of fs.readdirSync walks.
- Root-level AGENTS.md only enters manifest when trellis writes it.
- pruneOrphanManifestKeys() self-heals already-poisoned manifests at the top
  of both trellis update and trellis uninstall. Preserves .trellis/* (still
  walk-managed), every configured-platform collectTemplates() path, every
  path referenced by any migration manifest from/to, and AGENTS.md only when
  it still carries trellis managed-block markers.
- Homedir guard: trellis init / uninstall refuse to run when cwd is exactly
  the user's home directory (realpathSync.native + Windows lowercase). Bypass
  via TRELLIS_ALLOW_HOMEDIR=1; --force does not bypass.

.trellis/ files keep their existing walk-based hashing — trellis uninstall
rm -rf's that subtree wholesale regardless of manifest content, so over-
hashing there does not affect uninstall safety.

Internal:
- New utils/cwd-guard.ts and utils/manifest-prune.ts.
- claude configurator excludes dev-only .ts from its template walk.
- 27 new tests across recorder boundaries, prune semantics, homedir cases,
  and full init+uninstall reproductions for both reported scenarios.

Spec:
- .trellis/spec/cli/backend/migrations.md adds "Manifest ownership contract"
  with the recorder rules, prune preserve-set, homedir guard, wrong-vs-
  correct, and tests required for any future change in this area.
taosu0216 pushed a commit that referenced this pull request May 13, 2026
trellis init walked managed dirs (.codex/, .claude/, .opencode/) and hashed
every file into .template-hashes.json — including pre-existing user data
(.codex/sessions/, .claude/projects/, user-owned AGENTS.md). trellis uninstall
then unlinked every manifest entry, deleting that user data. Two real reports:
GitHub Issue #221 (.codex/sessions/ wiped) and PR #271 (pre-existing AGENTS.md
wiped via skip-existing path).

Manifest is now derived from "what trellis actually wrote this run", not from
walking the disk:

- writeFile() instruments recordWrite() on actual disk writes only. byte-
  identical, skip-existing, and append paths do NOT record. initializeHashes
  consumes the recorded set instead of fs.readdirSync walks.
- Root-level AGENTS.md only enters manifest when trellis writes it.
- pruneOrphanManifestKeys() self-heals already-poisoned manifests at the top
  of both trellis update and trellis uninstall. Preserves .trellis/* (still
  walk-managed), every configured-platform collectTemplates() path, every
  path referenced by any migration manifest from/to, and AGENTS.md only when
  it still carries trellis managed-block markers.
- Homedir guard: trellis init / uninstall refuse to run when cwd is exactly
  the user's home directory (realpathSync.native + Windows lowercase). Bypass
  via TRELLIS_ALLOW_HOMEDIR=1; --force does not bypass.

.trellis/ files keep their existing walk-based hashing — trellis uninstall
rm -rf's that subtree wholesale regardless of manifest content, so over-
hashing there does not affect uninstall safety.

Internal:
- New utils/cwd-guard.ts and utils/manifest-prune.ts.
- claude configurator excludes dev-only .ts from its template walk.
- 27 new tests across recorder boundaries, prune semantics, homedir cases,
  and full init+uninstall reproductions for both reported scenarios.

Spec:
- .trellis/spec/cli/backend/migrations.md adds "Manifest ownership contract"
  with the recorder rules, prune preserve-set, homedir guard, wrong-vs-
  correct, and tests required for any future change in this area.

(cherry picked from commit c76ff33)
@taosu0216
Copy link
Copy Markdown
Contributor

  1. 没啥必要适配 CLAUDE.md ,因为 cc 本身是通过 hook+skill+slash command 驱动的,也不需要它去读 CLAUDE.md 才会去使用 trellis 的流程,之前搞 AGENTS.md 是因为有些 agent ide 没做相关适配,但是会阅读 AGENTS.md 当一个通用标准,所以才搞得(并不是单纯为了 codex 才搞得)
  2. agents.md 连带删除的问题在后续 pr 已修复

@taosu0216 taosu0216 closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants