|
| 1 | +# Codebase Refactor — Full Guidelines Compliance |
| 2 | + |
| 3 | +You are refactoring a Laravel codebase to achieve 100% alignment with **codebar-ag coding guidelines**. This prompt is used when (a) newly adopting guidelines in an existing project, or (b) cross-checking AI-generated implementations for compliance. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. Skill Discovery |
| 8 | + |
| 9 | +Locate skills from one of these paths (check in order; first existing wins): |
| 10 | + |
| 11 | +- `vendor/codebar-ag/coding-guidelines/resources/boost/skills/` |
| 12 | +- `guidelines/resources/boost/skills/` |
| 13 | + |
| 14 | +Project overrides in `.ai/skills/{skill-name}/SKILL.md` take precedence over package defaults. |
| 15 | + |
| 16 | +**Action:** List all `SKILL.md` files. For each skill, extract: |
| 17 | + |
| 18 | +- `name` (from frontmatter or folder) |
| 19 | +- `Tags` — the first path-like value (e.g. `app/Models/**/*.php`) is the glob for file discovery |
| 20 | +- `Rules`, `Anti-Patterns`, `Examples` — apply these when analyzing and refactoring |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 2. Processing Order (Dependency-Aware) |
| 25 | + |
| 26 | +Process skills in this order to avoid repeated edits and respect dependencies: |
| 27 | + |
| 28 | +| Phase | Skills | |
| 29 | +|-------|--------| |
| 30 | +| Foundation | `general`, `php`, `helperfunctions` | |
| 31 | +| Data layer | `migrations`, `enums`, `models`, `traits` | |
| 32 | +| Backend core | `actions`, `services`, `dto`, `exceptions`, `interfaces` | |
| 33 | +| HTTP layer | `formrequests`, `controllers`, `middleware`, `requests`, `resources`, `routing` | |
| 34 | +| Infrastructure | `commands`, `jobs`, `events`, `observers`, `policies` | |
| 35 | +| Frontend | `blade`, `design`, `livewire`, `tailwind`, `translations` | |
| 36 | +| Integrations | `saloon`, `docuware`, `albatros` (only if matching files exist) | |
| 37 | +| Helpers | `helpers` | |
| 38 | +| Testing | `phpunit`, `pesttesting`, `phpstan`, `dusk` | |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## 3. Per-Skill Workflow |
| 43 | + |
| 44 | +For each skill in order: |
| 45 | + |
| 46 | +1. **Match files** — Find all files in the workspace that match the skill’s glob patterns from Tags (e.g. `app/Http/Controllers/**/*.php`). |
| 47 | +2. **Skip if empty** — If no files match (e.g. no Albatros service), skip the skill. |
| 48 | +3. **Read skill** — Load the full `SKILL.md` content for Rules, Examples, and Anti-Patterns. |
| 49 | +4. **Analyze** — Check each matching file against the Rules and Anti-Patterns. |
| 50 | +5. **Refactor** — Fix violations using the skill’s Examples. Preserve behavior; do not introduce breaking changes. |
| 51 | +6. **Batch edits** — Group edits by skill (e.g. all controller fixes in one pass). |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## 4. Efficiency Directives |
| 56 | + |
| 57 | +- **Incremental changes** — Prefer small, reviewable edits over large rewrites. |
| 58 | +- **Prioritize when large** — If the scope is large, produce a prioritized compliance report and refactor in phases. |
| 59 | +- **Cross-check mode** — When validating recent AI work, focus first on recently changed files, then broaden if needed. |
| 60 | +- **Avoid redundant passes** — Process skills in the defined order so earlier fixes are not undone by later ones. |
| 61 | + |
| 62 | +--- |
| 63 | + |
| 64 | +## 5. Output Format |
| 65 | + |
| 66 | +### Phase A: Compliance Report (before edits) |
| 67 | + |
| 68 | +Produce a concise report: |
| 69 | + |
| 70 | +- Skills that apply (have matching files) |
| 71 | +- Skills that are skipped (no matching files) |
| 72 | +- Per skill: files with violations, brief description of each violation |
| 73 | +- Summary: total violations, suggested commit grouping |
| 74 | + |
| 75 | +### Phase B: Refactoring (skill-by-skill) |
| 76 | + |
| 77 | +For each skill with violations: |
| 78 | + |
| 79 | +1. State the skill name and what is being fixed. |
| 80 | +2. Apply the changes. |
| 81 | +3. Suggest a commit message for that batch of changes. |
| 82 | + |
| 83 | +--- |
| 84 | + |
| 85 | +## 6. Tags-to-Glob Mapping |
| 86 | + |
| 87 | +Skills use Tags like: |
| 88 | + |
| 89 | +``` |
| 90 | +**Tags:** app/Models/**/*.php, laravel, php, backend, eloquent, model, database |
| 91 | +``` |
| 92 | + |
| 93 | +Use the **first path-like Tag** (e.g. `app/Models/**/*.php`, `database/migrations/**/*.php`, `resources/views/**/*.blade.php`) as the glob. Some skills have multiple paths (e.g. `app/Events/**/*.php`, `app/Listeners/**/*.php`); include all path-like Tags for that skill. |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## 7. Non-Breaking Refactors Only |
| 98 | + |
| 99 | +- Do not change observable behavior. |
| 100 | +- Do not remove or rename public APIs without explicit approval. |
| 101 | +- Prefer additive fixes (add missing types, FormRequests, transactions) over removals. |
| 102 | +- If a refactor is ambiguous or risky, report it and do not apply it automatically. |
| 103 | + |
| 104 | +--- |
| 105 | + |
| 106 | +**Begin by discovering skills, then producing the compliance report, then executing refactors in the specified order.** |
0 commit comments