AGENTS.md
AGENTS.mdAGENTS.mdroot
Quality
96/100
Scores the file, not the repository.Length
1,256 words
28 headings · 3 code blocksRepository
6
— · pushed 2 days agoLast changed
3 days ago
First indexed 3 days ago.1# AGENTS.md23This file provides guidance for AI coding agents (Claude Code, Codex, Gemini CLI, etc.) working in this repository.45## Navigation67- Locating files or understanding structure → [Repository Structure](#repository-structure)8- Writing or reviewing PHP → [Key Conventions → PHP](#php) + [Known Constraints → PHP Constraints](#php-constraints)9- Working on REST API controllers → [Key Conventions → REST API](#rest-api)10- Editing styles or scripts → [Key Conventions → CSS/JS](#cssjs) + [Known Constraints → JavaScript](#javascript)11- Checks required before committing → [Development Workflow](#development-workflow)12- Branch naming or commit format → [Creating Branches](#creating-branches) + [Commits](#commits)13- Verifying whether a file is safe to modify → [What Not to Touch](#what-not-to-touch)1415## Project Overview1617**CoCart JWT Authentication** is an open-source WordPress plugin that adds JWT (JSON Web Token) authentication support to CoCart. It enables stateless authentication for headless and decoupled storefronts using CoCart's REST API.1819- **Plugin file:** `cocart-jwt-authentication.php`20- **Main class:** `CoCart\JWTAuthentication\Plugin` (namespaced)21- **Autoloader:** PSR-4 via Composer (`CoCart\JWTAuthentication\` → `includes/classes/`)22- **Constant:** `COCART_JWT_AUTHENTICATION_FILE`23- **Text domain:** `cocart-jwt-authentication`24- **PHP minimum:** 7.425- **WordPress minimum:** 6.026- **WooCommerce minimum:** 7.027- **CoCart minimum:** 4.328- **Default branch:** `master`29- **License:** GPLv3 — public repository, open-source3031## Repository Structure3233```text34cocart-jwt-authentication.php # Main plugin file — defines constants, boots plugin35includes/36├── class-cocart-jwt-authentication.php # Boots CoCart\JWTAuthentication\Plugin37├── abstracts/ # Abstract base classes38└── classes/ # All feature classes (namespaced)39 ├── class-cocart-jwt-plugin.php # Main plugin class (singleton)40 └── rest-api/ # REST API controllers and auth handlers41assets/42├── scss/ # SCSS source — only this is tracked in git43├── css/ # Compiled CSS — generated by CI, not tracked44├── js/ # JS source; *.min.js compiled by CI, not tracked45└── images/ # Static images46languages/ # Only README.md tracked; .pot/.po/.mo generated by CI47tests/48└── unit/ # PHPUnit unit test classes49bin/50└── install-wp-tests.sh # WordPress test environment installer51```5253## Key Conventions5455### PHP5657- Follow [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/)58- All classes use the `CoCart\JWTAuthentication\` namespace — do not add global class names59- Use `cocart-jwt-authentication` as the text domain in all translatable strings60- Use numbered arguments in `printf`/`sprintf` when replacing more than one value: `%1$s`, `%2$s`61- Use sentence case for translatable strings: `Some thing` not `Some Thing`62- Avoid HTML in strings — insert via `sprintf` instead63- Do not call deprecated functions from plugin source; use replacement functions directly64- Use `COCART_JWT_AUTHENTICATION_FILE` constant — do not hardcode the plugin path6566### REST API6768- Authentication handlers live in `includes/classes/rest-api/`69- CoCart uses WooCommerce Data Stores API for session management — not WooCommerce default sessions70- This plugin extends CoCart's authentication layer — do not bypass CoCart's auth hooks71- JWT tokens are issued and validated here — do not duplicate logic in controllers7273### CSS/JS7475- Edit SCSS source in `assets/scss/` — never edit compiled CSS in `assets/css/`76- Compiled CSS and minified JS are generated by CI (`npx grunt css js`) — do not commit them77- RTL CSS is auto-generated from compiled CSS — do not create RTL files manually7879## Build Commands8081```bash82# Install dependencies83npm ci84composer install8586# Compile CSS and JS87npx grunt css js8889# Watch for changes during development90npx grunt watch9192# Code standards93composer phpcs # Check PHP coding standards94composer phpcbf # Auto-fix coding standards issues95composer phpstan # Static analysis9697# Download translations98npx grunt get-translations99100# Fix text domain references101npm run fix:textdomain102```103104## Development Workflow1051061. Make code changes1072. Run `composer phpcs` on changed PHP files — fix all violations before continuing1083. Run `composer phpstan` on changed PHP files — fix errors in code, never add to baseline1094. Run `vendor/bin/phpunit` — all tests must pass before committing1105. Compile assets if SCSS/JS changed: `npx grunt css js`1116. Commit only after checks are clean1127. Open a pull request against `master`113114### Pre-commit Checks115116**Before committing PHP changes**, run these to avoid CI failures:117118```bash119# Check coding standards on changed files120composer phpcs121122# Static analysis123composer phpstan124125# Run the test suite126vendor/bin/phpunit127```128129**PHPStan baseline policy:** The baseline file (`phpstan-baseline.neon`) must never grow. If PHPStan reports a new error, fix it in the code. If your fix resolves a previously baselined error, remove the corresponding entry from the baseline. The baseline should only shrink over time.130131## Known Constraints132133### Project Structure134135- Never add standalone global functions — all code must use the `CoCart\JWTAuthentication\` namespace136- Never modify `CHANGELOG.md` — updated by the CoCart team only137- Never commit compiled CSS (`assets/css/`) or minified JS (`assets/js/**/*.min.js`) — generated by CI138- Never commit `.pot` files — generated by CI139- Never edit RTL CSS files manually — auto-generated from compiled CSS140- All new classes go in `includes/classes/` under the appropriate subdirectory141142### JavaScript143144- Never write inline JavaScript — all JS must live in enqueued script files so it can be compiled, linted, and minified145- Never use dynamic code execution functions (`call`, `apply`, `Function` constructor, or similar patterns that execute strings as code)146- Never enqueue scripts or styles outside the designated admin class147148### PHP Constraints149150- Never use `var_dump()`, `print_r()`, or `error_log()` in committed code — remove all debug output before committing151- Never access `$_GET`, `$_POST`, or `$_SERVER` directly in REST API controllers — use `WP_REST_Request` parameter methods152- Never write raw database queries — use WooCommerce Data Stores or existing CoCart abstractions153- Never use `wp_die()` inside REST API controllers — return a `WP_Error` instance instead154- Never output unescaped content — use `esc_html()`, `esc_attr()`, `wp_json_encode()`, or the appropriate escaping function155- Never hardcode credentials, tokens, or API keys — use WordPress options or constants defined outside the codebase156157## What Not to Touch158159- **`CHANGELOG.md`** — updated by the CoCart team, not contributors160- **`languages/*.pot`** — generated by CI (`wp i18n make-pot`), not tracked in git161- **`assets/css/`** — compiled by CI, not tracked in git162- **`assets/js/**/*.min.js`** — compiled by CI, not tracked in git163- **`vendor/`** — managed by Composer, not tracked in git164- **`node_modules/`** — managed by npm, not tracked in git165166## Creating Branches167168Branch names follow this structure (`{short-slug}` = brief descriptor of the change):169170- `release/{version}` — release branches171- `refactor/{short-slug}` — refactors172- `test/{short-slug}` — test-only changes173- `fix/{issue-number}-{short-slug}` — bug fixes (always include the issue number)174- `add/{short-slug}` — new features175176## Commits177178- Each commit should address one atomic unit of work179- Subject line: imperative mood, no trailing period, max 50 characters (e.g. `Fix token expiry on guest checkout`)180- Blank line between subject and body181- Body lines: max 72 characters182- Explain *what* and *why*, not just *how* — only explain *how* if it isn't obvious183- Reference the related issue number in the commit body (e.g. `Fixes #123`)184- Do not amend published commits185186## Agent Rules187188- Run pre-commit checks before every commit — do not skip them for any reason189- Do not modify generated files (`assets/css/`, `*.min.js`, `*.pot`) — CI overwrites them190- Do not add entries to the PHPStan baseline — fix the error in code instead191- Do not create new files when an existing class can be extended or modified192- Do not reach past a CoCart abstraction to call WordPress or WooCommerce directly — use the abstraction193- Do not amend commits that have already been pushed194- Check [What Not to Touch](#what-not-to-touch) before modifying any file you are uncertain about195- Check [Known Constraints](#known-constraints) before writing any new PHP, JS, or SQL196
Also in cocart-headless/cocart-jwt-authentication
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| cocart-headless/cocart-jwt-authentication.cursor/rules/git.mdc · 6 | Cursor rules | gitagent-behaviour | 39/100 | 3 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| wpscanteam/wpscanAGENTS.md · 9.7k | AGENTS.md | setupbuildteststyle+6 | 100/100 | 2 days ago | |
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago |
