Repository navigation
Description
Summary
#3741 fixed the CRLF conversion in _register_always_on_block and in the Gemini install path. The remaining writers listed below still use Path.write_text without newline="", and all of them read existing files through Path.read_text, which normalises CRLF to LF before the text is modified. When these paths rewrite an existing file, its line endings are normalised to CRLF or LF depending on platform and writer; the original convention is not reliably preserved. (An install that changes nothing, or an uninstall without a graphify section, leaves the file untouched.)
Where (v0.9.84, graphify/install.py)
- Still without
newline="":claude_installL2047,_agents_installL1809,codebuddy_installL2238,_strip_graphify_md_sectionL2216 (uninstall of CLAUDE.md),_agents_uninstallL1983 (AGENTS.md),gemini_uninstallL1060,vscode_installL1117 (L1120 creates a new file),vscode_uninstallL1160,codebuddy_uninstallL2311. - Fixed in fix(install): stop corrupting line endings and fix the re-install guard in _register_always_on_block #3741:
_register_always_on_blockL498-L533 andgemini_installL935-L948 - but these still read withread_text(encoding="utf-8"). - Permalink:
Lines 2197 to 2218 in 2cb81c6
def _strip_graphify_md_section(target: Path) -> bool: """Strip the ## graphify section from one CLAUDE.md-style file. Returns True if a section was removed. Deletes the file if nothing else remains after removal. """ try: content = target.read_text(encoding="utf-8") except (OSError, UnicodeDecodeError): # An unreadable/undecodable CLAUDE.md-style file (e.g. non-UTF-8, or a # directory of that name) must not abort uninstall - nothing to strip. return False # Remove graphify's ## graphify section (heading matched exactly, never as a # substring of a user's ### graphify) from the marker to the next H2 or EOF. cleaned = _remove_marker_section(content, _CLAUDE_MD_MARKER) if cleaned is None: return False # A symlink stays: writing through it cleans the file it points to. if cleaned or target.is_symlink(): target.write_text(cleaned + "\n", encoding="utf-8") print(f"graphify section removed from {target.resolve()}") else:
Why it matters
On Windows, these writes convert the normalised LF text to CRLF whenever a rewrite happens. That changes the bytes of an LF file in the working tree and can show up as an every-line diff where git does not normalise line endings (with * text eol=lf, git diff may hide it). On Linux/macOS a CRLF file loses its \r the same way. For CLAUDE.md/AGENTS.md, which are often shared and reviewed, that can hide the real change in noise and trip line-ending checks.
Minimal reproduction (Windows, Git Bash, Python 3.12)
- In a project directory, create
CLAUDE.mdwith LF line endings (printf 'a b ' > CLAUDE.md). - Run
graphify claude install, thengraphify uninstall. - Inspect the file (
file CLAUDE.md).
Expected: only the graphify block is added and later removed; the remaining lines keep LF.
Actual: the file is rewritten with CRLF line endings. The same read-modify-write pattern in isolation (read_text, append, write_text) turns both LF and CRLF input into CRLF on Windows with the default write, or into LF with newline=""; neither choice preserves both input conventions.
Suggested fix
Read the existing file without newline translation (open(..., newline=""), or read bytes and decode; Path.read_text(newline=...) needs Python 3.13), detect its line ending, write the new block with that ending (the helpers currently join with a hard-coded ), and write with newline="" everywhere. A single helper used by all install/uninstall writers would cover the remaining paths and keep them from drifting apart again. A round-trip test per writer (LF file and CRLF file in, same endings out, only the graphify block changed) would pin it.
Environment
graphify 0.9.84 (release commit above). Windows 11, Claude Code. Found during an internal security review.
Activity
github-actions commentedon Oct 12, 2026
Thanks for opening this issue, @ujconsulting. A maintainer will take a look soon.
If you would like to discuss it in real time, come say hi on our Discord server. For longer-form questions and ideas there is also GitHub Discussions.
To help us triage, please make sure the report includes what you expected, what actually happened, and the steps (and a small sample) to reproduce it.
fix(install): preserve line endings of CLAUDE.md, AGENTS.md and sibli…
safishamsi commentedon Oct 12, 2026
Fixed in v0.9.88 (
graphifyy 0.9.88on PyPI) via #4372.fix(install): remove the global skill registration on uninstall