Repository navigation
Description
Spicy Claude review ( I think the repo could be a lot better if these were addressed):
1. extract.py Is a 1,588-Line War Crime
This single file contains 13 language-specific extractors, import handlers, call-graph passes, docstring extraction, rationale extraction, AND cross-file resolution. It's doing the work of an entire extractors/ package. Every time you want to touch Python extraction you're scrolling past Go, Rust, Kotlin, Scala, PHP, C#... This is textbook "I'll just add one more language" syndrome until the file became sentient.
The import handlers (_import_python, _import_js, _import_java, _import_c, etc.) are ~80% identical copy-paste with minor variations. A single parameterized handler with a language config would cut 200+ lines.
2. export.py: 954 Lines of Inline JavaScript
You embedded an entire vis.js frontend application as Python f-strings. CSS, JavaScript event handlers, DOM manipulation — all living inside triple-quoted strings with zero IDE support, zero linting, zero syntax checking. If you have a typo in line 600 of that JS blob, you'll find out at runtime when a user opens the HTML. This is how people wrote PHP in 2005.
3. Silent Failures Everywhere — The "It's Fine" Architecture
# extract.py:842
except Exception:
return # shrug emoji
# cache.py:30-31
except OSError:
return None # who needs to know?
# hooks.py:41-43
except Exception as exc:
print(f'[graphify hook] Rebuild failed: {exc}')
sys.exit(0) # exit SUCCESS on failure!That last one is my favorite: the git hook catches an exception, prints "rebuild failed", then exits with code 0 (success). Git will think the hook passed. Your graph is silently stale and you'll never know.
Every error path in this codebase returns None or swallows the exception. Users will get incomplete graphs with no indication that half their files failed to parse.
4. build.py Filters Out Validation Errors by Substring Match
real_errors = [e for e in errors if "does not match any node id" not in e]
if real_errors:
print(...) # but continues anywayYou're using "does not match any node id" not in e as a string filter on your own validation messages. If someone changes the wording in validate.py, this silently starts swallowing real errors. And even when real schema errors ARE found, you just print a warning and build the graph anyway. Validation that doesn't stop execution isn't validation — it's a suggestion.
5. The Token Budget Math Is Wrong
# serve.py:79
char_budget = token_budget * 4 # "Assume 4 chars/token"Modern BPE tokenizers average ~1.3 chars/token for English, ~3-4 for code. Your "2000 token budget" actually allows ~8000 characters, which is roughly 6000 tokens. You're overshooting by 3x. For a tool that literally counts tokens in its benchmark, this is ironic.
6. _is_file_node() — Heuristic Roulette
if label.split(".")[-1] in ("py", "ts", "js", "go", ...):
return TrueA class named config.py would be filtered. A node labeled my.cool.rs would be filtered. You're using filename extension matching on labels that aren't filenames. The node already has a file_type attribute — use it.
7. _node_community_map() Is Defined Twice
The exact same function exists in both analyze.py:6 and export.py:20. Copy-paste instead of importing. Classic.
8. No Logging — Just print()
Every module uses print() for diagnostics. You can't filter by severity, route to a file, disable in tests, or integrate with any logging infrastructure. The [graphify] prefix is manually typed into every string. One import logging and a logger = logging.getLogger(__name__) would fix this across the entire codebase.
9. Cache Writes Aren't Atomic
# cache.py:49
entry.write_text(json.dumps(result))If the process dies mid-write (or two processes race), you get a corrupt JSON file in the cache. Next run reads it, json.loads fails, silently returns None (see point 3), and re-extracts everything. The standard pattern is write-to-temp-then-rename. This is a known footgun.
10. manifest.py Is 4 Lines of Nothing
from graphify.detect import save_manifest, load_manifest, detect_incremental
__all__ = ["save_manifest", "load_manifest", "detect_incremental"]This file exists solely to re-export three functions from detect.py. It adds a layer of indirection that helps nobody.
11. The Hook Script Embeds Python Inside Bash Inside Python
hooks.py defines a bash script as a Python string, which itself contains an inline Python script invoked via python3 -c "...". That embedded Python imports from graphify. If that import fails, the error message will be a bash error wrapping a Python traceback — good luck debugging that in a post-commit hook context.
12. detect_incremental Doesn't Handle Deletions
It only checks for new or modified files against the manifest. Deleted files remain in the manifest forever, and their cached extractions persist as ghost nodes in the graph. Over time your graph accumulates dead nodes from files that no longer exist.
13. Test Suite: Assertions So Loose They'd Pass on an Empty Dict
assert isinstance(communities, dict) # {} passes
assert "## God Nodes" in report # empty section passes
assert any("__init__" in l for l in labels) # substring match, not exact
assert "error" in result # {"error": ""} passesThe pipeline integration test has 9 assertions for a 7-step pipeline. Many tests check for presence of keys/strings rather than correctness of values. A refactor that silently breaks the scoring algorithm would pass every test.
14. Hardcoded Magic Numbers With No Configuration
_MAX_COMMUNITY_FRACTION = 0.25(cluster.py)_MIN_SPLIT_SIZE = 10(cluster.py)_PAPER_SIGNAL_THRESHOLD = 3(detect.py)MAX_NODES_FOR_VIZ = 5_000(export.py)token_budget = 2000(serve.py)- Edge weight
0.8for calls,1.0for imports (extract.py)
None of these are configurable. No CLI flags, no config file, no environment variables. Users get whatever you hardcoded and like it.
15. nx.Graph() Instead of nx.DiGraph()
# build.py:35
G = nx.Graph()You're building a knowledge graph of directional relationships (imports, calls, contains) using an undirected graph. Then you manually store direction with attrs["_src"] and attrs["_tgt"] because the graph type threw it away. This is working around your own data model.
The Good
Credit where it's due: the tree-sitter extraction approach is solid, the SHA256-based cache keying is clean, the Leiden clustering choice is smart, and supporting 13 languages with a config-driven approach shows good instinct. The README is genuinely well-written. The security.py module shows someone was actually thinking about SSRF and XSS. The test suite runs real code paths instead of mocking everything.
The bones are good. The execution has the fingerprints of fast iteration without enough refactoring passes.
Activity
safishamsi commentedon Apr 6, 2026
Genuinely one of the more useful reviews I have gotten. A lot of these hit real issues.
I fixed six of them in de60b68:
The git hook was the worst one. Catching an exception and exiting 0 means git thinks everything went fine while your graph is quietly stale. That is now exit 1.
The token budget math was off by about 3x. Changed the multiplier from 4 to 3, which is closer to reality for mixed graph text output.
_is_file_nodewas doing extension matching on label strings, which would incorrectly filter a class namedconfig.py. It now checks whether the label matches the actual filename from the node'ssource_fileattribute._node_community_mapwas copy-pasted betweenanalyze.pyandexport.py. Removed the duplicate, import from one place now.Cache writes are atomic. Write to a temp file, then
os.replace(). No more corrupt JSON on a mid-write crash.detect_incrementalnow tracks deleted files and returns them so callers can clean up ghost nodes instead of letting them accumulate forever.The refactoring points (extract.py size, inline JS in export.py, print vs logging, loose test assertions, magic numbers) are all valid and on the list for v0.4.0. They are real but not bugs.
On point 15,
nx.Graph()is intentional. Leiden needs an undirected graph to run community detection. Edge direction is stored in attrs for export purposes. It is not a workaround, it is just how the clustering layer works.