Skip to content

[Bug]: Skill templates: five logic bugs in the inline Python snippets, plus an outdated note in hooks.md (0.9.112) #5340

Open

Description

@pawanshukla500

Pre-flight checks

  • I have checked the Troubleshooting section in the README

What happened?

While reviewing a project-scoped install (graphify install --project), I read through the generated skill and reference files and found six problems in tools/skillgen/fragments/. Items 1–5 came from reading the code. Item 6 was reproduced. Happy to split these into separate issues if you prefer.

1. PDF coverage is reported in pages but checked against text lines, so PDFs are retried on every run.
references/shared/extraction-spec.md:29 tells the extraction subagent: "For a file the Read tool returns as pages rather than lines (a PDF), report the number of pages you read." The coverage check in core/core.md:267 counts lines instead: total = sum(1 for _ in p.open(encoding='utf-8', errors='replace')). For a PDF this counts newline bytes in the binary file, which is far more than the page count, so n < total holds. A fully read PDF is marked partial, its output is dropped, and it is re-extracted on every update. The opposite case also happens: a multi-page PDF with few newline bytes can pass while only partly read.
Expected: page-count the PDF (for example with pypdf.PdfReader(p).pages) or skip the line check for PDFs.

2. One malformed chunk file aborts collection, although Step B3 says invalid chunks are skipped.
Step B3 says: "If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort". But the coverage loop in core/core.md:254–258 runs json.loads(Path(c).read_text(...)) on every graphify-out/.graphify_chunk_*.json with no try/except. A single truncated or invalid chunk raises JSONDecodeError and stops the whole step.
Expected: wrap the parse, warn, and continue, matching Step B3.

3. A leftover .graphify_extract.json can be merged into a deletions-only update.
references/shared/update.md:88 only writes the empty extraction for a deletions-only run if [ ! -f graphify-out/.graphify_extract.json ]. Step 9 normally deletes that file. If an earlier build or update was interrupted before Step 9, the stale file stays, and the next deletions-only --update merges it through build_merge(...) (line ~109 onward) instead of an empty extraction. Its content replaces the current nodes for those source_files, which can bring back old nodes. Not reproduced.
Expected: in the deletions-only branch, always overwrite with the empty extraction, or delete .graphify_extract.json at the start of --update.

4. The inline explain fallback hides callers in --directed graphs.
references/query/default.md:303 (and the copies in core/aider.md:1234 and core/devin.md:1366) lists "CONNECTIONS" with for neighbor in G.neighbors(nid):. G comes from json_graph.node_link_graph(data, edges='links'), which keeps directed: true for graphs built with --directed. On a DiGraph, neighbors() returns only successors, so incoming edges such as callers and importers are left out. Undirected graphs (the default) are unaffected.
Expected: when G.is_directed(), iterate G.predecessors(nid) as well as G.successors(nid) and label the direction.

5. The inline query fallback doesn't weight terms by IDF, although the docs say it does.
references/query/default.md:25 says the CLI matches "via case-folded substring + IDF" and "the inline fallback below matches the same way". The fallback at line 96 scores sum(1 for t in terms if t in label), giving every term equal weight. Common words can then outrank rare, specific ones when start nodes are picked. The copies are in core/aider.md:1032 and core/devin.md:1168.
Expected: add IDF weighting to the fallback, or correct the sentence on line 25.

6. hooks.md says graphify claude install writes to CLAUDE.md, but in a repo with only AGENTS.md it writes to AGENTS.md.
references/shared/hooks.md:29 (and core/aider.md:1332): "This writes a ## graphify section to the local CLAUDE.md". The code (_claude_instructions_file in install.py) correctly picks AGENTS.md when no CLAUDE.md-style file exists, because creating a CLAUDE.md would hide AGENTS.md from Claude Code. The doc still names CLAUDE.md, so an agent following the reference by hand may create one.
Expected: "…to the local CLAUDE.md, or to AGENTS.md when the project has one and no CLAUDE.md."

Steps to reproduce

Item 6 (reproduced):

T=$(mktemp -d) && cd "$T" && git init -q
printf '# AGENTS.md\n\nproject rules\n' > AGENTS.md
graphify claude install
ls            # AGENTS.md  (no CLAUDE.md is created)
grep -c '## graphify' AGENTS.md   # 1

Items 1–5 were found by reading the code at the lines above. They are not reproduced end to end.

Error output or graph output

Item 6: graphify section written to <tmp>/AGENTS.md, and no CLAUDE.md is created. That is correct behaviour; only the doc is wrong.

Graphify version

0.9.112 (main at 340268a)

Operating System

Windows 10

Python Version

3.12.10

Installation Method

pip

Additional Environment Details

No provider API keys set. Item 6 was reproduced in a clean temporary repo.

Additional context

Related but separate: #3791 (install deleting content below # graphify). On 0.9.112, with an AGENTS.md whose graphify block was followed by a ## section, re-running graphify install --project kept that section and moved the 3-line # graphify block to the end. So it no longer reproduced for that shape. Mentioning it in case it helps triage #3791.

Activity

  1. github-actions commented on Nov 19, 2026

    @github-actions

    Thanks for opening this issue, @pawanshukla500. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions