You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
install --platform claude deletes all CLAUDE.md content below the graphify block when no later H1 exists (regression in 0.9.66, #3741) #3791
Since 0.9.66 (#3741, fix for #3668), graphify install --platform claude deletes all user content in CLAUDE.md below the graphify block when the file has no H1 heading after # graphify. The install prints only Done., with no warning.
This is the default shape of a file that graphify has registered into: the block is written as the H1 # graphify. If the user's own content uses only ## headings (common in CLAUDE.md), the next re-install removes all of it.
Reproduction (0.9.67, macOS)
T=$(mktemp -d)printf'# graphify\n- **graphify** (`old/path/SKILL.md`) - any input to knowledge graph. Trigger: `/graphify`\nWhen the user types `/graphify`, use the installed graphify skill or instructions before doing anything else.\n\n## My own rules\n- rule one\n- rule two\n'>"$T/CLAUDE.md"
wc -l <"$T/CLAUDE.md"# 7
CLAUDE_CONFIG_DIR="$T" graphify install --platform claude # prints "Done."
wc -l <"$T/CLAUDE.md"# 3 — "## My own rules" and everything below it is gone
On a real global CLAUDE.md this removed 217 lines, and 208 lines in a second config dir. We restored both from a copy made before the install.
Cause
_register_always_on_block → _replace_or_append_section(content, _SKILL_REGISTRATION_MARKER, registration, boundary_prefix="# "). The replaced section runs from # graphify to the next line starting with # , or to EOF if there is none. Our block is 3 lines, but the section runs to the end of the file. Before 0.9.66 the bare substring guard made re-install a no-op, so this path was never reached for files that already had the block.
_remove_claude_skill_registration → _remove_marker_section(..., boundary_prefix="# ") has the same boundary. I have only read this code and not run it, but uninstall looks like it would delete the same content.
Suggested fix
Bound the section by the block graphify itself writes, not by the next heading of the same level. For example:
wrap the registration in explicit begin/end markers (<!-- graphify:start --> / <!-- graphify:end -->) and replace only between them, or
when no end marker exists (legacy files), replace only the known registration lines. Stop at the first blank line or the first line that is not part of _skill_registration() output, and never extend to EOF.
A cheap guard would also help: refuse to write (and warn) if the replacement would remove more than N lines that graphify did not write.
Workaround
Add any H1 heading directly after the graphify block. Re-install then replaces only the 3-line block.
Another shape of the same cause, still present in 0.9.72: the next H1 exists, but every non-heading line between the graphify block and that H1 is deleted. That includes the markers of other tools that manage a block in the same file, so the "add an H1 after the block" workaround does not protect them.
Reproduction (0.9.72, Linux):
T=$(mktemp -d)printf'# graphify\n- **graphify** (`old/path/SKILL.md`) - any input to knowledge graph. Trigger: `/graphify`\nWhen the user types `/graphify`, use the installed graphify skill or instructions before doing anything else.\n<!-- BEGIN other-tool -->\n<!-- managed by another tool -->\n\n# Other tool section\ntext\n\n<!-- END other-tool -->\n'>"$T/CLAUDE.md"
CLAUDE_CONFIG_DIR="$T" graphify install --platform claude # exit 0, prints no warning
cat "$T/CLAUDE.md"
Result: <!-- BEGIN other-tool --> and <!-- managed by another tool --> are gone. <!-- END other-tool --> is left without its pair.
We hit this on a real ~/.claude/CLAUDE.md during a scheduled update. Our installer found an END marker with no BEGIN marker and refused to touch the block. On our side, we now add our block at the top of the file, so it is never below the graphify section. The explicit <!-- graphify:start --> / <!-- graphify:end --> markers suggested above would fix both shapes.
A regression test for the "foreign content after the block" shape could use: a file with only ## headings after the block, a file with another tool's marker block after it, and a CRLF file - all three must come back byte-identical except for the graphify block.
Environment: v0.9.84, Windows 11, Claude Code. Found during an internal security review.
Still reproduces in 0.9.112 on Windows, and also with --platform windows, not only --platform claude.
Upgraded from 0.7.19 with uv tool install --upgrade graphifyy. The upgrade warning said to run graphify install --platform claude; I ran graphify install --platform windows.
The global ~/.claude/CLAUDE.md started with the 3-line # graphify block written by the old version, followed by 48 lines of my own instructions under ## headings only (no later H1).
After install the file was 3 lines: only the graphify block. The install printed CLAUDE.md -> skill registered in ... and Done., with no warning. Restored from a copy taken just before the install.
Two notes from this run:
The upgrade warning points users straight at the destructive command, so anyone upgrading a pre-0.9.66 install with a ##-only CLAUDE.md hits this on the first re-install.
install already keeps SKILL.md.bak when the skill differs from the packaged one; doing the same for CLAUDE.md (or refusing to drop more lines than the block it writes) would make this recoverable even if the boundary bug comes back.
Activity
EliveltonRepolho commentedon Sep 30, 2026
Another shape of the same cause, still present in 0.9.72: the next H1 exists, but every non-heading line between the graphify block and that H1 is deleted. That includes the markers of other tools that manage a block in the same file, so the "add an H1 after the block" workaround does not protect them.
Reproduction (0.9.72, Linux):
Result:
<!-- BEGIN other-tool -->and<!-- managed by another tool -->are gone.<!-- END other-tool -->is left without its pair.We hit this on a real
~/.claude/CLAUDE.mdduring a scheduled update. Our installer found an END marker with no BEGIN marker and refused to touch the block. On our side, we now add our block at the top of the file, so it is never below the graphify section. The explicit<!-- graphify:start -->/<!-- graphify:end -->markers suggested above would fix both shapes.ujconsulting commentedon Oct 11, 2026
Thanks for the detailed report. Two related observations from our own review that might help prioritise the fix:
install/uninstallrewriteCLAUDE.md/AGENTS.md(and the user-global~/.claude/CLAUDE.md) without keeping a copy.settings.jsonalready gets a rolling<name>.graphify-bak(_write_settings_with_backup, claude install --strict overwrites the entire ~/.claude/settings.json (destroys mcpServers, plugins, and all other hooks) with no backup #2167) andSKILL.mdgets a.bak(install: --platform X never writes .graphify_version (permanent upgrade warning), and install silently overwrites a modified SKILL.md #3144), so the same single-copy approach for the instruction files would turn a data-loss bug into a recoverable one. fix: clean home-scope skill registration on uninstall; back up config files (#1121) #1310 contains a backup helper for exactly this, if that PR is revived.claude_uninstallstill looks only at the project directory (install.pymd_targets), so a global install leaves its block in~/.claude/CLAUDE.mdpointing at a deleted skill; that is fix(install): remove the user-global CLAUDE.md registration on uninstall #3573.A regression test for the "foreign content after the block" shape could use: a file with only
##headings after the block, a file with another tool's marker block after it, and a CRLF file - all three must come back byte-identical except for the graphify block.Environment: v0.9.84, Windows 11, Claude Code. Found during an internal security review.
Permalinks:
graphify/graphify/install.py
Lines 2179 to 2183 in 2cb81c6
graphify/graphify/install.py
Lines 986 to 1000 in 2cb81c6
singhrohit90 commentedon Nov 19, 2026
Still reproduces in 0.9.112 on Windows, and also with
--platform windows, not only--platform claude.uv tool install --upgrade graphifyy. The upgrade warning said to rungraphify install --platform claude; I rangraphify install --platform windows.~/.claude/CLAUDE.mdstarted with the 3-line# graphifyblock written by the old version, followed by 48 lines of my own instructions under##headings only (no later H1).CLAUDE.md -> skill registered in ...andDone., with no warning. Restored from a copy taken just before the install.Two notes from this run:
##-only CLAUDE.md hits this on the first re-install.installalready keepsSKILL.md.bakwhen the skill differs from the packaged one; doing the same for CLAUDE.md (or refusing to drop more lines than the block it writes) would make this recoverable even if the boundary bug comes back.