Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .agents/recipes/pr-review/recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ Review pull request #{{pr_number}} using the `review-code` skill.

## Instructions

1. Run `/review-code {{pr_number}}`
2. The skill writes the review to `/tmp/review-{{pr_number}}.md`. If it does
1. If `/tmp/structural-impact-{{pr_number}}.md` exists, read it. This contains
a pre-computed structural impact analysis (risk level, god nodes affected,
import direction violations, cross-package dependencies). Use it to inform
your review - high-risk PRs warrant extra scrutiny on blast radius and
backward compatibility.
2. Run `/review-code {{pr_number}}`
3. The skill writes the review to `/tmp/review-{{pr_number}}.md`. If it does
not, save the review output there yourself.
3. Before finishing, read `/tmp/review-{{pr_number}}.md` and verify it contains
4. If the structural impact analysis exists, append its content to the review
file (before the Verdict section) under a `### Structural Impact` heading.
5. Before finishing, read `/tmp/review-{{pr_number}}.md` and verify it contains
a valid review (Summary, Findings, Verdict sections). If the file is empty
or malformed, write a brief "Review could not be completed" note to the file
instead.
Expand Down
39 changes: 38 additions & 1 deletion .agents/recipes/structure/recipe.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,38 @@ done
This enables modern type syntax (`list[str]` instead of `List[str]`,
`str | None` instead of `Optional[str]`) and defers annotation evaluation.

### 4. Dead exports
### 4. Graphify structural analysis

Run the graphify-based structural analysis tool. This builds a directed AST
graph of the entire codebase (~2s) and produces god node rankings,
cross-package edge counts, and import direction violations that grep-based
checks miss (e.g., inferred cross-file dependencies from class-level import
resolution).

```bash
PREV_GRAPH=""
if [ -f "graphify-out/graph.json" ]; then
PREV_GRAPH="--previous-graph graphify-out/graph.json"
fi
python .agents/tools/structural_impact.py --full $PREV_GRAPH \
--output /tmp/graphify-structure.md
```

Read `/tmp/graphify-structure.md` and incorporate relevant findings:

- **God nodes**: track the top 10 most-connected entities. Compare against
the previous baseline in runner memory. A god node gaining 10+ connections
since last week signals growing coupling.
- **Cross-package edge summary**: the table shows edge counts per direction.
All edges should flow interface -> engine -> config. Any VIOLATION row is a
finding for the import boundary section.
- **Changes since last run**: new/removed entities and relationships since
the previous audit. Flag any unexpected removals of god nodes.

After the audit, update `baselines` in runner memory with the current god
node list and cross-package edge counts from `graphify-out/baselines.json`.

### 5. Dead exports

Find symbols in `__all__` that nothing outside their module references:

Expand Down Expand Up @@ -161,12 +192,18 @@ Write the report to `/tmp/audit-{{suite}}.md`:
|---------|--------|--------|----------|
| ... | ... | ... | No external imports found |

### Structural graph analysis (graphify)

(Paste the content of /tmp/graphify-structure.md here)

### Summary

- N import boundary violations (M new since last run)
- N lazy import violations (M new)
- N files missing future annotations (M new)
- N potentially dead exports (M new)
- God nodes: top entity has N connections (delta: +/-M from last run)
- Cross-package edges: N total (M violations)
```

If no findings in any category, write `NO_FINDINGS` on the first line instead.
Expand Down
27 changes: 27 additions & 0 deletions .agents/skills/review-code/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ Before diving into details, build a mental model:
5. **Note cross-cutting concerns** (e.g., a rename that touches many files vs. substantive logic changes)
6. **Check existing feedback** (PR mode): inspect both inline comments (Step 1, item 5) and PR-level review bodies (Step 1, item 5b) so you don't duplicate feedback already given

## Step 3.5: Structural Impact (if available)

Check for a pre-computed structural impact analysis at
`/tmp/structural-impact-<pr-or-branch>.md`. This file is produced by
`graphify` AST extraction and contains:

- **Risk level** (LOW/MEDIUM/HIGH) based on god nodes touched, import
violations, and cluster spread
- **Core abstractions modified** - the most-connected entities in the
codebase (high blast radius if changed)
- **Import direction violations** - cross-package edges that violate the
layering rule (interface -> engine -> config)
- **High-connectivity changes** - entities with many dependents
- **Cross-package dependencies** - edges crossing package boundaries

If the file exists, read it and use it to calibrate your review:

- **HIGH risk**: apply extra scrutiny in Pass 2 (Design & Architecture).
Verify backward compatibility for god nodes. Check that cross-package
changes don't break existing callers.
- **Import violations**: flag them as Warnings in the review if they
represent real dependency direction issues (not just inferred edges).
- **LOW risk**: the structural analysis confirms a localized change. You
can focus more on correctness (Pass 1) and less on architecture.

If the file does not exist (e.g. local branch review), skip this step.

## Step 4: Review Each Changed File (Multi-Pass)

Perform **at least 2-3 passes** over the changed files. Each pass has a different focus β€” this catches issues that a single read-through would miss.
Expand Down
Loading
Loading