| name | elixir-phoenix-init |
| description | Install or update the plugin rules and AGENTS.md wiring in a Phoenix project. |
| metadata | {"short-description":"Set up Phoenix plugin rules"} |
Plugin Initialization
Install the Elixir/Phoenix plugin's behavioral instructions into the project's AGENTS.md.
Usage
`elixir-phoenix-init` # First-time installation
`elixir-phoenix-init` --update # Update existing installation with latest rules
Iron Laws
- NEVER overwrite content outside plugin markers — User-written AGENTS.md rules must be preserved verbatim
- Always detect stack before generating — Never assume Phoenix/Ecto versions
- Always validate after installation — Verify markers present and stack correct
Workflow
Step 1: Check Existing AGENTS.md
Check whether AGENTS.md exists, then search it for an existing
ELIXIR-PHOENIX-PLUGIN:START marker.
Step 2: Detect Project Stack
Scan the project to customize the injected instructions:
Read mix.exs and extract:
- Phoenix version: search for
phoenix.*"~> in mix.exs
- Ecto version: search for
ecto.*"~> in mix.exs
- Oban: search for
"oban" and "oban_pro" in mix.exs
- Frameworks: search for
"ash", "surface" in mix.exs
- Tidewave: search for
"tidewave" in mix.exs
- Project size: count
lib/**/*.ex files
Step 3: Handle Installation Modes
Mode A: Fresh Install (no AGENTS.md or no markers)
- Create/append to AGENTS.md
- Insert full behavioral instructions between markers
- Include only relevant sections based on detected stack
Mode B: Update (--update flag or markers exist)
- Find content between
<!-- ELIXIR-PHOENIX-PLUGIN:START --> and <!-- ELIXIR-PHOENIX-PLUGIN:END -->
- Replace with latest behavioral instructions
- Preserve everything outside the markers
CRITICAL: NEVER overwrite or delete existing AGENTS.md content outside the plugin markers — user-written rules, project conventions, and other plugin sections must be preserved verbatim
Step 4: Generate Content
Write the following structure to AGENTS.md:
<!-- ELIXIR-PHOENIX-PLUGIN:START -->
<!-- Last updated: {date} | Plugin version: 1.0 | Stack: Phoenix {version}, Ecto {version}, {optional: Oban, Tidewave} -->
# Elixir/Phoenix Plugin - Auto-Activation Rules
{Include all sections from the Content Template below, filtered by detected stack}
<!-- ELIXIR-PHOENIX-PLUGIN:END -->
Step 5: Output Summary
✅ Elixir/Phoenix plugin initialized
Detected stack:
- Phoenix {version}
- Ecto {version}
- {Oban standard | Oban Pro | not detected}
- {Tidewave ✓ | Tidewave not detected}
- {Ash Framework detected - Ecto patterns disabled | not detected}
Added to AGENTS.md:
- Auto-activation rules (complexity detection, interview mode)
- Agent trigger patterns ({n} agents available)
- Reference auto-loading ({n} reference docs)
- Iron Laws enforcement ({n} laws)
- Verification rules
Run `elixir-phoenix-init` --update after plugin updates.
Run `elixir-phoenix-audit` for a full project health check.
Content Template
The exact content to inject is in references/injectable-template.md.
Key structure:
- 7-Step Mandatory Procedure — Codex MUST execute before every response
- Iron Laws — STOP behavior on violations
- Conditional Sections — Include based on detected stack:
{OBAN_SECTION} — If Oban detected (not Pro)
{OBAN_PRO_SECTION} — If Oban Pro detected
{ASH_SECTION} — If Ash Framework detected
{TIDEWAVE_SECTION} — If Tidewave detected
- Verification — Mandatory after code changes
- Quick Reference — Skill routing table
Placeholder substitution:
| Placeholder | Source |
|---|
{DATE} | Current date |
{PHOENIX_VERSION} | From mix.exs |
{ECTO_VERSION} | From mix.exs |
{OPTIONAL_STACK} | Detected optional deps |
See references/injectable-template.md for full template with all placeholders and conditional sections.
Validation
After running elixir-phoenix-init:
- Check AGENTS.md contains markers
- Verify detected stack matches actual project
- New session should:
- Auto-detect complexity when given tasks
- Stop on Iron Law violations
- Offer relevant workflows based on task
Error Handling
| Scenario | Action |
|---|
| AGENTS.md read-only | Error: "Cannot modify AGENTS.md - check permissions" |
| Markers corrupted | Warn, offer to remove and reinstall |
| Unknown Phoenix version | Use conservative defaults (all features enabled) |
| Not an Elixir project | Error: "No mix.exs found - is this an Elixir project?" |
Relationship to Other Commands
| Command | When to Use |
|---|
elixir-phoenix-init | First time, or after plugin updates |
elixir-phoenix-audit | Periodic project health check |
elixir-phoenix-verify | After code changes |