Php coder

From event4u-app/agent-config · View interactive version

Php coder is an AI agent skill from the GitHub repository event4u-app/agent-config. Writes or edits PHP code — controllers, classes, type hints, SOLID refactors, modern idioms — even without naming PHP. NOT for writing tests (use pest-testing) or explaining PHP concepts.

How to use this skill

Skill file

coder

When to use

This skill applies to ALL code generation and editing tasks. Every other skill builds on top of this one.

Do NOT use when:

Procedure: Before writing code

Step 0: Inspect project

  1. Read AGENTS.md and .github/copilot-instructions.md for project-specific rules.
  2. If working in a module (app/Modules/*/), check app/Modules/{Module}/agents/ for module docs.
  3. Look at neighboring files in the same directory — match the style.
  4. Read ./agents/ for project-specific architecture.
  5. Check ecs.php / rector.php (if they exist) — code accordingly.
  6. Read Makefile or Taskfile.yml for available build/test/quality targets.

Step 1: Detect project type

Step 2: Apply conventions

→ See php-coding rule (always loaded) for PHP coding standards.

→ See guideline php/general.md for detailed PHP conventions.

→ See guideline php/controllers.md, php/eloquent.md, etc. for domain-specific conventions.

Step 3: Stop-gate — branching on a discriminator?

Before writing a second match/switch arm, a second if/elseif

branch, or a second class hardcoded to one enum/string value (e.g.

Provider::FOO->value, 'stripe', a case Type::CSV), STOP and run the

Strategy sniff test.

Trigger keywords in the task or surrounding code:

Driver, Kind

CsvExporter, Ks21Job next to GeoCaptureJob with the same shape

→ Run the sniff test in

CODE0.

Two "yes" answers → propose Strategy + Registry before adding the new

branch. Three "yes" → it is already overdue and the refactor is the change.

This gate fires per task, not per file — once you've passed the sniff

test for a given discriminator, do not re-ask on the next branch.

Core principles

Validate

Output format

  1. Code following project guidelines and existing patterns
  2. All downstream changes (callers, tests, imports) included

Verification examples

Gotcha

Do NOT

Anti-bruteforce — diagnose before retry

When PHPStan, Rector, or a test goes red after a change, do not retry blindly by toggling type hints, adding @phpstan-ignore, or shuffling arguments until it passes. Diagnose the root cause first — read the error, trace the symbol, then apply a targeted fix. Trial-and-error type narrowing hides real type errors.

Auto-trigger keywords

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.