Skip to content

Commit 9de606f

Browse files
committed
docs(agents): add Agent Guidance section to address recurring error patterns (GH#919)
Addresses 4 recurring tool failure patterns observed in contributor sessions: - read:file_not_found (32x): config files use .dist suffix convention, vendor/ and node_modules/ are gitignored and must be installed - webfetch:other (34x): explicit no-webfetch guidance for WordPress/API docs; direct agents to search the codebase instead - edit:not_read_first (24x): mandatory Read-before-Edit reminder - bash:other (20x): prerequisite checks for wp-cli and composer/npm Fixes #919
1 parent a80d44b commit 9de606f

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,60 @@ wp plugin activate $(basename $PWD) # activate this plugin
181181
wp plugin deactivate $(basename $PWD) # deactivate
182182
wp db reset --yes && cd ../wordpress && ./reset.sh # full DB + WordPress reset (requires reset.sh in ../wordpress)
183183
```
184+
185+
## Agent Guidance
186+
187+
Recurring error patterns observed in this codebase. Review before starting any session.
188+
189+
### File Discovery — `.dist` Config Convention
190+
191+
Config files are committed as `.dist` versions; un-suffixed copies are gitignored and may not exist locally:
192+
193+
| Tracked (exists) | Local override (gitignored, may be absent) |
194+
|---|---|
195+
| `.phpcs.xml.dist` | `.phpcs.xml` |
196+
| `phpunit.xml.dist` | `phpunit.xml` |
197+
| `phpstan.neon.dist` | `phpstan.neon` |
198+
199+
Always verify a file is tracked before reading it:
200+
201+
```bash
202+
git ls-files 'phpunit.xml*' # shows phpunit.xml.dist, not phpunit.xml
203+
```
204+
205+
The `vendor/` and `node_modules/` directories are gitignored. If they are absent, run:
206+
207+
```bash
208+
composer install && npm install
209+
```
210+
211+
The `docs/` directory exists but is not described in the Project Structure section above — it contains developer documentation markdown files. The `todo/` directory contains task briefs.
212+
213+
### No External URL Fetching
214+
215+
Do **not** use webfetch for WordPress documentation, PHP manual pages, Stripe/PayPal API docs, or any developer documentation URLs — these requests consistently fail.
216+
217+
Use the codebase itself instead:
218+
219+
- WordPress functions and hooks → `rg 'function_name'` across `inc/`
220+
- Existing gateway patterns → read `inc/gateways/` directly
221+
- REST API shape → read `inc/apis/` trait files
222+
- Hook reference → `rg 'do_action\|apply_filters'` across `inc/`
223+
224+
### Read Before Edit (Mandatory)
225+
226+
The Edit tool **requires** a prior Read call on the same file in the current session. If you attempt to edit without reading first, the tool will fail. Always read the complete target file before editing — even for small changes.
227+
228+
### WP-CLI and Bash Prerequisites
229+
230+
`wp` commands require the dev WordPress install at `../wordpress`. Check it exists before running:
231+
232+
```bash
233+
ls ../wordpress/wp-config.php 2>/dev/null || echo "WordPress dev env not found — run ./reset.sh in ../wordpress first"
234+
```
235+
236+
`vendor/bin/phpunit`, `vendor/bin/phpcs`, and `vendor/bin/phpstan` require `composer install`. Check before running test or lint commands:
237+
238+
```bash
239+
ls vendor/autoload.php 2>/dev/null || composer install
240+
```

0 commit comments

Comments
 (0)