mcpbeat Sign in

Phx Boundaries Skill for Claude

Analyze Phoenix context boundaries and module coupling via mix xref. Use when checking cross-context calls…

3k tokens
context cost
the whole folder, loaded on every use
3
files
instructions only
0
copies elsewhere
how many repositories repackaged it
514
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/oliver-kriska/claude-elixir-phoenix --skill phx-boundaries

What comes with it

9 270 bytes besides the instruction
references/context-design.md
references/refactoring-boundaries.md

The instruction itself

17 sections, as written by the author

Phoenix Context Boundary Validation

Analyze module dependencies to ensure clean context separation and proper architectural boundaries.

Usage

$elixir-phoenix:phx-boundaries              # Check for violations
$elixir-phoenix:phx-boundaries --assess     # Score context health (0-100)
$elixir-phoenix:phx-boundaries --fix        # Suggest fixes for violations

--assess Mode: Context Health Score

Evaluate overall boundary health with a quantified score.

Metrics Calculated

| Metric | Healthy Range | Red Flag | Weight |

|--------|---------------|----------|--------|

| Modules per context | 3-15 | >20 or <2 | 20% |

| Public API surface | 5-30 funcs | >40 funcs | 15% |

| Fan-out (contexts called) | 1-4 | >6 | 20% |

| Fan-in (called by contexts) | 1-6 | >10 | 15% |

| Circular dependencies | 0 | >0 | 15% |

| Boundary violations | 0 | >0 | 15% |

Commands for Assessment

Use Glob to count .ex files per context directory under lib/my_app/*/.

Use Grep to count public function definitions per context file under lib/my_app/*.ex.

Run mix xref graph --format stats for dependency analysis.

Run mix xref graph --format cycles --label compile for compile-time circular dependencies.

Output Format

## Context Health Assessment

### Overall Score: 82/100 (Good)

| Context | Modules | API | Fan-Out | Fan-In | Score |
|---------|---------|-----|---------|--------|-------|
| Accounts | 5 | 12 | 2 | 4 | 95 |
| Orders | 18 | 45 | 8 | 3 | 62 |
| Shared | 2 | 8 | 0 | 12 | 78 |

### Issues Found

1. **Orders** - Too large (18 modules, 45 funcs)
   - Consider: Extract Fulfillment, Invoicing sub-contexts

2. **Orders** - High fan-out (8 contexts)
   - Consider: Review if all dependencies necessary

### Recommendations

- Split Orders into Orders + Fulfillment
- Review Accounts ← Billing dependency

Iron Laws - Never Violate These

  • Controllers call only contexts - No direct Repo access from web layer
  • Schemas are pure data - No side effects, no Repo calls in schema modules
  • Contexts own their schemas - Don't import schemas from other contexts
  • Explicit dependencies only - Cross-context calls must be intentional
  • DO NOT refactor context boundaries without running mix xref first — Refactoring without dependency data creates new violations; always map the dependency graph before moving modules

Dependency Rules

| Layer | Can Call | Cannot Call |

|-------|----------|-------------|

| Controllers | Contexts, Plug, Conn | Repo, Schemas directly |

| LiveViews | Contexts, Components, PubSub | Repo, Schemas directly |

| Contexts | Own schemas, Repo, other contexts | Web layer modules |

| Schemas | Ecto types, validations | Contexts, Repo |

Analysis Commands

Check Compile Dependencies

Run mix xref graph --label compile-connected.

Find What Depends on a Context

Run mix xref graph --sink MyApp.Accounts --label compile.

Find What a Module Calls

Run mix xref callers MyApp.Accounts.get_user!/1.

Check for Circular Dependencies

Run mix xref graph --format cycles --label compile.

Red Flags to Detect

| Issue | Detection Command | Fix |

|-------|------------------|-----|

| Repo in web layer | grep -r "Repo\." lib/my_app_web/ | Move to context |

| Schema with queries | grep -r "import Ecto.Query" lib/my_app/**/schemas/ | Move queries to context |

| Cross-context schema import | grep -r "alias MyApp.Other.Schema" lib/my_app/ctx/ | Call context API |

| Business logic in LiveView | grep -r "Repo\.\|Ecto\.Multi" lib/my_app_web/live/ | Extract to context |

Boundary Verification Process

  • Run mix xref graph --label compile-connected for overview
  • Check for context cross-contamination
  • Verify no direct Repo calls from web layer
  • Ensure schemas have no side effects
  • Validate explicit cross-context dependencies

Next Steps

Always end with actionable follow-up — findings without a plan

get lost:

- `$elixir-phoenix:phx-plan` — Create a plan to fix violations (recommended for 3+ issues)
- `$elixir-phoenix:phx-quick` — Fix a single boundary violation directly
- `$elixir-phoenix:phx-review` — Review specific modules for deeper issues

References

For detailed patterns, see:

  • references/context-design.md - Context design principles
  • references/refactoring-boundaries.md - Fixing boundary violations

Other skills for the same job

different authors, same section of the catalogue
Protocolsio Integration
by christophacham
×4

Integration with protocols.io API for managing scientific protocols. This skill should be used when working with protocols.io to search, create, update, or publish protocols; manage protocol steps and materials; handle discussions and comments; organize workspaces; upload and manage files; or integrate protocols.io functionality into workflows. Applicable for protocol discovery, collaborative protocol development, experiment tracking, lab protocol management, and scientific documentation.

16k tokens
Tailored Resume Generator
by frostant
×4

Analyzes job descriptions and generates tailored resumes that highlight relevant experience, skills, and achievements to maximize interview chances

3k tokens
Excalidraw Diagram Generator
by github
vendor ×3

Generate Excalidraw diagrams from natural language descriptions. Use when asked to "create a diagram", "make a flowchart", "visualize a process", "draw a system architecture", "create a mind map", or "generate an Excalidraw file". Supports flowcharts, relationship diagrams, mind maps, and system architecture diagrams. Outputs .excalidraw JSON files that can be opened directly in Excalidraw.

36k tokens scripts
Expo Dev Client
by openai
vendor ×3

Build and distribute Expo development clients locally or via TestFlight

961 tokens
Executing Plans
by ZhanlinCui
×3

Use when you have a written implementation plan to execute in a separate session with review checkpoints

542 tokens
Anndata
by christophacham
×3

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

16k tokens
Benchling Integration
by christophacham
×3

Benchling R&D platform integration. Access registry (DNA, proteins), inventory, ELN entries, workflows via API, build Benchling Apps, query Data Warehouse, for lab data management automation.

14k tokens
Biopython
by christophacham
×3

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

24k tokens

How to use it

Copy the folder

Take oliver-kriska/claude-elixir-phoenix-phx-boundaries from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.