Skip to content
Merged
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
57 changes: 57 additions & 0 deletions .claude/skills/fix-a-fact/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: fix-a-fact
description: Fix, consolidate, or add how the server answers one question (a fact) so it matches PHP and has one route - find every route, review a design adversarially before code, build test-first against an oracle, and review adversarially again before the pull request leaves draft. Use for any bug fix or refactor that changes what the server says about code.
---

# Fix a fact

A fact is one question the server answers: what a member access is, which members a class has, what type an expression has.
Two rules govern every step: do what PHP does, and have one route to the fact.
Finishing means one route remains, nothing is left dangling, and the answer matches PHP.

## 1. Pin down the fact and PHP's behavior

1. State the fact as a question PHP's semantics answer, in plain terms.
2. Find what PHP does: the manual, or php-src for precise rules.
Where the manual is vague or versions may differ, write a short script for the maintainer to run on 3v4l across versions; do not run ad hoc PHP here.
3. If PHP's behavior differs by version, stop and ask which to follow.

## 2. Find every route

1. Name the closed set of code that can decide the fact: every file handling the syntax node types or domain types involved (grep for them), and every consumer of the types that carry the answer.
2. Read all of it.
A route is any code that decides any part of the fact, including code that re-derives it from something it was handed.
3. Write the routes down.
If a route decides the fact for code PHP rejects outright, it needs no answer; do not invent one.

## 3. Design, then attack the design

1. Write a short design in the scratchpad: the one owner, what it replaces, the rules it follows with PHP behavior stated plainly, and what is out of scope with the issue that tracks it.
2. Fix at the root.
If the routes disagree because a lower-level fact is wrong (an edge, a domain field), that fact is fixed first, in its own pull request.
3. Give the design to a fresh agent with the prompt below, verify each finding yourself against PHP or the code, revise, and repeat until a round finds nothing that holds.

> Adversarially review the design at `<path>`. The project's two rules: do what PHP does, and one route per fact. Try to prove the design wrong: (1) find any rule or step that differs from PHP for code PHP accepts, with a concrete PHP example; (2) find any part of the fact that would still be decided in more than one place in `src/`, or that the design itself decides twice; (3) find anything left dangling, and any cycle or bad input that could crash the server. Do not edit files. Report verified findings only, each with evidence and a concrete example.

## 4. Build

1. Work test-first.
Prefer an oracle over hand-written expectations: PHP's own reflection checks member facts (`MemberResolverTypeGraphTest`).
2. Reuse existing fixtures before adding any; extend a shared fixture additively when a new case fits it.
3. Confirm each new test fails without the change.
4. Keep commits small: tests, then the change, per logical step.

## 5. Review

1. Open the pull request as a draft.
Its description is for someone with no context: the problem with a short example, the cause, the change, visible behavior, tests, known limits.
State PHP's behavior plainly; do not cite php-src.
2. Run `pr-review` in a fresh agent.
3. Run a second fresh agent with the prompt below.

> The pull request claims `<fact>` now has exactly one owner: `<owner>`. Try to prove that false. Search all of `src/`, not just the changed files, for any code that still decides any part of the fact, directly or by re-deriving it from something it was handed. For each candidate, decide whether it decides this fact or a different one, and report both kinds separately with a concrete input. Do not edit files.

4. Verify every finding against the code.
Fix findings in the pull request's own code fully, in the pull request.
A finding in code the pull request did not touch becomes an issue linked from the pull request; with a reproduction, also a known-defect script (ADR 0008).
5. If a review finds a new case of a problem already fixed in this pull request, stop and report to the maintainer before patching again.
3 changes: 2 additions & 1 deletion .claude/skills/pr-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Review one pull request (by number, or the current branch against `main`) and re

## Passes

Run all three and report each separately.
Run all of them and report each separately.

1. **Simplify.** Run the `simplify` skill on the diff, reporting its suggestions instead of applying them.
2. **Correctness.** Run the `code-review` skill on the pull request at high effort, reporting only.
Expand All @@ -25,6 +25,7 @@ Run all three and report each separately.
- **Deferrals:** a comment or pull request text that knowingly leaves a structural problem in place for later.
- **Tool workarounds:** code shaped to get past PHPStan, deptrac, or a failing test rather than to solve the problem.
- **Scope:** changes that do not serve the issues the pull request closes, and "Done when" criteria it does not meet.
4. **Remaining routes.** For each fact the pull request gives one owner, search all of `src/`, not only the changed files, for code that still decides any part of it, directly or by re-deriving it from something it was handed. Report each candidate with a concrete input, and say whether it decides this fact or a different one.

## Rules

Expand Down
4 changes: 4 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Every request is answered correctly without background work, and background work

Code being edited usually does not parse, and every feature must keep working on it.
At any position, every feature sees the same structure, and it is the structure the code will have once completed.
Whether a feature must handle some shape of broken code is answered from the parser's guarantees (`ParsedDocument`, `Located`), never from how recovery happens to work.

### Source text

Expand Down Expand Up @@ -132,6 +133,9 @@ When a tool such as PHPStan or deptrac blocks a change, the intent of its rule m
- A fact read from syntax gets its first route in the one walker that reads the syntax tree, never in a feature.
- Debug through the test suite. Do not write ad hoc PHP scripts.
- When creating a new issue, add the `ai-authored` label.
- Work that changes what the server says about code follows the `fix-a-fact` skill: its design is reviewed adversarially against PHP's behavior and the one-route rule before any code is written.
- Fix at the root. When routes to a fact disagree because a lower-level fact is wrong, fix that fact first, in its own pull request, instead of patching the symptom where it shows.
- A pull request description is for a reader with no context: the problem with a short example, the cause, then the change. State PHP's behavior plainly rather than citing php-src.

## LSP Protocol

Expand Down
Loading