The graph doesn't just show you what exists — it reveals the patterns in how your code is organized. This lesson teaches you to extract those patterns and use them as constraints for AI-generated code.
After this lesson, you can identify architectural patterns from graph structure and feed them to the AI as explicit constraints — producing code that matches your project's conventions on the first attempt.
Patterns are structural regularities. In a well-organized codebase, you'll see:
The report's community descriptions hint at patterns. Look for:
# In GRAPH_REPORT.md, you might see:
#
# Community: "Update Operator Tests"
# Key nodes: test_min_comparisons, test_max_comparisons, test_inc_basic, ...
# Common imports: framework.assertions, framework.test_case, framework.parametrize
# Structure: Each file inherits UpdateTestCase, defines TESTS list, has one test function
That last line is the pattern. Extract it explicitly.
Once you identify a pattern, express it as a constraint document the AI can reference:
# .graphify-patterns.md
## Update Operator Test Pattern
Every operator test file in the "Update Operator Tests" community:
1. Imports: framework.assertions, framework.test_case, framework.parametrize
2. Defines a dataclass extending UpdateTestCase (frozen=True)
3. Has a single TESTS: list[TestCase] at module level
4. Has a single parametrized test function using pytest_params()
5. Test IDs are prefixed with the operator name (e.g., min_, max_)
6. Module docstring describes what the file tests
7. File naming: test_{operator}_{aspect}.py
Feed this to the AI alongside the graph for highly consistent output.
Ask the AI to audit against the extracted pattern:
"Using the graph, find all test files in the 'Update Operator Tests' community
that DON'T import framework.parametrize. These are likely violating
our standard pattern."
Or check for structural drift:
"Compare the import edges of test_min_comparisons.py vs test_inc_basic.py.
Do they follow the same pattern? What's different?"
The graph makes boundaries visible. A well-architected project has clear layers with dependencies flowing in one direction:
# Expected dependency direction:
# test files → framework → utilities → driver
#
# Violations (circular or backwards dependencies):
# "framework.assertions imports test_helpers" ← boundary violation
Ask the AI to check for these:
"Using the graph edges, are there any imports that flow backwards —
from framework/ into tests/, or from utilities/ back into framework/?"
Patterns extracted from the graph are more reliable than patterns you think exist. The graph shows what the code actually does, not what the README says it should do. Trust the graph over documentation when they conflict.
What makes graph-extracted patterns more reliable than documented conventions?
How do you use an extracted pattern to improve AI-generated code?
GRAPH_REPORT.md and pick the largest community