Skip to content

Commit ee6de17

Browse files
authored
Merge pull request #73 from Automattic/add/agents-md
Add AGENTS.md with structured agent guidance
2 parents dbe5dfd + f1f3755 commit ee6de17

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

.claude/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@AGENTS.md

AGENTS.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Rewrite Rules Inspector
2+
3+
Debug and inspect WordPress rewrite rules.
4+
5+
## Project Knowledge
6+
7+
| Property | Value |
8+
|----------|-------|
9+
| **Main file** | `rewrite-rules-inspector.php` |
10+
| **Text domain** | `rewrite-rules-inspector` |
11+
| **Namespace** | `Automattic\RewriteRulesInspector` |
12+
| **Source directory** | `src/` |
13+
| **Version** | 1.6.0 |
14+
| **Requires PHP** | 7.4+ |
15+
| **Requires WP** | 6.4+ |
16+
17+
### Directory Structure
18+
19+
```
20+
rewrite-rules-inspector/
21+
├── src/
22+
│ ├── Plugin.php # Main plugin class
23+
│ ├── Core/ # Core logic (UrlTester, RewriteRules)
24+
│ └── Admin/ # Admin UI (AdminPage, RewriteRulesTable)
25+
├── views/ # PHP template files for admin pages
26+
├── assets/ # CSS/JS assets
27+
├── tests/
28+
│ ├── Unit/ # Unit tests
29+
│ └── Integration/ # Integration tests (wp-env)
30+
├── languages/ # Translation files
31+
├── rector.php # Rector configuration for code modernisation
32+
├── .github/workflows/ # CI: deploy, integration
33+
└── .phpcs.xml.dist # PHPCS configuration
34+
```
35+
36+
### Key Classes
37+
38+
- `Plugin` — Main plugin bootstrap, registers hooks
39+
- `Core\RewriteRules` — Retrieves and analyses WordPress rewrite rules
40+
- `Core\UrlTester` — Tests URLs against rewrite rules
41+
- `Admin\AdminPage` — Admin tools page registration
42+
- `Admin\RewriteRulesTable` — WP_List_Table for displaying rewrite rules
43+
44+
### Dependencies
45+
46+
- **Dev**: `automattic/vipwpcs`, `yoast/wp-test-utils`, `rector/rector`
47+
48+
## Commands
49+
50+
```bash
51+
composer cs # Check code standards (PHPCS)
52+
composer cs-fix # Auto-fix code standard violations
53+
composer lint # PHP syntax lint
54+
composer test:unit # Run unit tests
55+
composer test:integration # Run integration tests (requires wp-env)
56+
composer test:integration-ms # Run multisite integration tests
57+
composer coverage # Run tests with HTML coverage report
58+
composer rector # Run Rector for code modernisation suggestions
59+
```
60+
61+
## Conventions
62+
63+
Follow the standards documented in `~/code/plugin-standards/` for full details. Key points:
64+
65+
- **Commits**: Use the `/commit` skill. Favour explaining "why" over "what".
66+
- **PRs**: Use the `/pr` skill. Squash and merge by default.
67+
- **Branch naming**: `feature/description`, `fix/description` from `develop`.
68+
- **Testing**: Write integration tests for WordPress-dependent behaviour, unit tests for isolated logic. Use `Yoast\WPTestUtils\WPIntegration\TestCase` for integration, `Yoast\WPTestUtils\BrainMonkey\YoastTestCase` for unit.
69+
- **Code style**: WordPress coding standards via PHPCS. Tabs for indentation.
70+
- **i18n**: All user-facing strings must use the `rewrite-rules-inspector` text domain.
71+
72+
## Architectural Decisions
73+
74+
- **Separation of concerns**: Core logic (rewrite rule analysis, URL testing) is separated from admin UI. Keep this boundary — do not mix display logic into core classes.
75+
- **View templates**: Admin page HTML is in `views/` as separate template files, not inline in PHP classes. New admin views should follow this pattern.
76+
- **WordPress.org deployment**: Has a deploy workflow for WordPress.org SVN. Do not manually modify SVN assets.
77+
- **Rector available**: Includes Rector for automated code modernisation. Use `composer rector` to check for opportunities.
78+
- **Debugging tool**: This plugin is a developer tool, not an end-user feature. The UI prioritises information density and accuracy over visual polish.
79+
80+
## Common Pitfalls
81+
82+
- Do not edit WordPress core files or bundled dependencies in `vendor/`.
83+
- Run `composer cs` before committing. CI will reject code standard violations.
84+
- Integration tests require `npx wp-env start` running first.
85+
- Rewrite rules are generated by WordPress core, themes, and other plugins. Do not modify rewrite rules from this plugin — it is an inspector, not a modifier.
86+
- The `flush_rewrite_rules()` function is expensive. If adding a flush feature, it must only run on explicit user action, never on every page load.
87+
- WordPress rewrite rules can vary significantly between sites. Test with a variety of permalink structures, not just the default.
88+
- Admin list table extends `WP_List_Table`, which is a WordPress internal class marked as private. Be cautious with assumptions about its API stability.

0 commit comments

Comments
 (0)