Przejdź do treści
Biblioteka skilli
Programowanie · Przegląd i audyt

phx-boundaries

/phx-boundaries

Pokazuje, które moduły Phoenix zależą od siebie, przez mix xref, przed podziałem kontekstu albo przeglądem architektury.

Licencja
MIT
Ostatnia zmiana repozytorium
22.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
3
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 22.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Pokazuje, które moduły Phoenix zależą od siebie, przez mix xref, przed podziałem kontekstu albo przeglądem architektury.

Oryginalny opis (EN)

Analyze Phoenix context boundaries and module coupling via mix xref. Use when checking cross-context calls, validating dependencies, before splitting modules, or reviewing architecture.

Jak działa

  1. Usage
  2. --assess Mode: Context Health Score
  3. Iron Laws - Never Violate These
  4. Dependency Rules
  5. Analysis Commands
  6. Red Flags to Detect
  7. Boundary Verification Process
  8. Next Steps
  9. References
Sekcje z nagłówków SKILL.md, w oryginale · 132 linii, 674 słów
Podgląd SKILL.md
---
name: phx-boundaries
description: Analyze Phoenix context boundaries and module coupling via mix xref.
  Use when checking cross-context calls, validating dependencies, before splitting
  modules, or reviewing architecture.
---

# Phoenix Context Boundary Validation

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

## Usage

```
/skill:phx-boundaries              # Check for violations
/skill:phx-boundaries --assess     # Score context health (0-100)
/skill: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

```markdown
## 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

1. **Controllers call only contexts** - No direct Repo access from web layer
2. **Schemas are pure data** - No side effects, no Repo calls in schema modules
3. **Contexts own their schemas** - Don't import schemas from other contexts
4. **Explicit dependencies only** - Cross-context calls must be intentional
5. **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

1. Run `mix xref graph --label compile-connected` for overview
2. Check for context cross-contamination
3. Verify no direct Repo calls from web layer
4. Ensure schemas have no side effects
5. Validate explicit cross-context dependencies

## Next Steps

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

```
- `/skill:phx-plan` — Create a plan to fix violations (recommended for 3+ issues)
- `/skill:phx-quick` — Fix a single boundary violation directly
- `/skill: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
Pliki w paczce (3)
  • SKILL.md 4 KB
  • references/context-design.md 4 KB
  • references/refactoring-boundaries.md 5 KB

Wersje

RepozytoriumWynikLicencja
Ta strona · oliver-kriska/claude-elixir-phoenix100MIT
oliver-kriska/claude-elixir-phoenix100MIT
oliver-kriska/claude-elixir-phoenix100MIT
oliver-kriska/claude-elixir-phoenix100MIT

Migawka bazy z 13.11.2026 · wersja paczki 060f17e0fe4d (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100boundaries
    Analizuje granice kontekstów Phoenix i sprzężenie modułów przez mix xref: wywołania między kontekstami, zależności, podział modułów i przegląd architektury.
  • 100phx-audit
    Ocenia stan projektu Phoenix pod kątem architektury i wydajności, przydatny przed wydaniem albo po refaktoryzacji.
  • 100phoenix-code-review
    Przegląda kod Phoenix pod kątem wzorców kontrolerów, granic kontekstów, routingu i plugów, w kontrolerach, routerach i modułach kontekstów.
  • 100phoenix-scopes-and-generators
    Pomaga uruchamiać generatory phx.gen z zakresami, rozbudowywać strukturę %Scope{} o organizację i konfigurować :scopes.
  • 100phoenix-patterns
    Stosuje dobre praktyki frameworku Phoenix: projektowanie kontekstów, wzorce kontrolerów i architektura aplikacji.
  • 100phoenix-auth-customization
    Dodaje pola do użytkownika wygenerowanego przez phx.gen.auth, takie jak nazwa użytkownika i pola profilu, wraz z changesetem rejestracji, migracjami i fixture'ami.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.