@event4u/agent-config 2.25.0 → 2.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent-src/commands/bug-fix.md +1 -0
- package/.agent-src/commands/feature/roadmap.md +2 -2
- package/.agent-src/commands/fix/seeder.md +3 -2
- package/.agent-src/commands/memory/add.md +3 -3
- package/.agent-src/commands/module/create.md +1 -0
- package/.agent-src/commands/module/explore.md +10 -6
- package/.agent-src/commands/onboard.md +9 -1
- package/.agent-src/commands/optimize/augmentignore.md +52 -20
- package/.agent-src/commands/optimize/rtk.md +56 -30
- package/.agent-src/commands/package-test.md +86 -10
- package/.agent-src/commands/quality-fix.md +49 -27
- package/.agent-src/commands/update-form-request-messages.md +2 -1
- package/.agent-src/contexts/augment-infrastructure.md +4 -7
- package/.agent-src/contexts/communication/rules-auto/guidelines-mechanics.md +1 -1
- package/.agent-src/contexts/contracts/research-schema.md +1 -1
- package/.agent-src/contexts/execution/interrupt-examples.md +34 -0
- package/.agent-src/contexts/skills-and-commands.md +2 -2
- package/.agent-src/rules/architecture.md +24 -10
- package/.agent-src/rules/artifact-drafting-protocol.md +6 -0
- package/.agent-src/rules/augment-edit-discipline.md +28 -0
- package/.agent-src/rules/augment-source-of-truth.md +2 -2
- package/.agent-src/rules/autonomous-execution.md +31 -0
- package/.agent-src/rules/context-hygiene.md +1 -1
- package/.agent-src/rules/domain-adoption-policy.md +4 -5
- package/.agent-src/rules/domain-safety-disclaimer.md +114 -0
- package/.agent-src/rules/domain-safety-pii.md +142 -0
- package/.agent-src/rules/domain-safety-retention.md +86 -0
- package/.agent-src/rules/downstream-changes.md +4 -4
- package/.agent-src/rules/framework-neutrality-in-generic-skills.md +130 -0
- package/.agent-src/rules/git-history-discipline.md +99 -0
- package/.agent-src/rules/minimal-safe-diff.md +6 -0
- package/.agent-src/rules/no-roadmap-references.md +4 -2
- package/.agent-src/rules/user-interrupt-priority.md +46 -0
- package/.agent-src/rules/verify-before-complete.md +11 -2
- package/.agent-src/skills/adversarial-review/SKILL.md +1 -1
- package/.agent-src/skills/ai-council/SKILL.md +1 -0
- package/.agent-src/skills/api-endpoint/SKILL.md +58 -154
- package/.agent-src/skills/api-testing/SKILL.md +11 -0
- package/.agent-src/skills/code-refactoring/SKILL.md +36 -30
- package/.agent-src/skills/code-review/SKILL.md +41 -36
- package/.agent-src/skills/context-authoring/SKILL.md +1 -1
- package/.agent-src/skills/dashboard-design/SKILL.md +1 -2
- package/.agent-src/skills/database/SKILL.md +8 -3
- package/.agent-src/skills/dependency-upgrade/SKILL.md +65 -19
- package/.agent-src/skills/developer-like-execution/SKILL.md +25 -14
- package/.agent-src/skills/eloquent/SKILL.md +1 -1
- package/.agent-src/skills/feature-planning/SKILL.md +1 -1
- package/.agent-src/skills/file-editor/SKILL.md +45 -19
- package/.agent-src/skills/finishing-a-development-branch/SKILL.md +2 -2
- package/.agent-src/skills/git-workflow/SKILL.md +4 -4
- package/.agent-src/skills/laravel-api-endpoint/SKILL.md +187 -0
- package/.agent-src/skills/{dto-creator → laravel-dto}/SKILL.md +5 -4
- package/.agent-src/skills/{migration-creator → laravel-migration}/SKILL.md +11 -10
- package/.agent-src/skills/laravel-reverb/SKILL.md +3 -3
- package/.agent-src/skills/{websocket → laravel-websocket}/SKILL.md +4 -3
- package/.agent-src/skills/learning-to-rule-or-skill/SKILL.md +1 -1
- package/.agent-src/skills/merge-conflicts/SKILL.md +49 -17
- package/.agent-src/skills/migration-architect/SKILL.md +6 -6
- package/.agent-src/skills/module-management/SKILL.md +1 -0
- package/.agent-src/skills/multi-tenancy/SKILL.md +15 -8
- package/.agent-src/skills/pest-testing/SKILL.md +18 -0
- package/.agent-src/skills/php-debugging/SKILL.md +28 -0
- package/.agent-src/skills/php-service/SKILL.md +3 -3
- package/.agent-src/skills/playwright-testing/SKILL.md +16 -1
- package/.agent-src/skills/project-analyzer/SKILL.md +68 -42
- package/.agent-src/skills/readme-writing-package/SKILL.md +94 -23
- package/.agent-src/skills/roadmap-management/SKILL.md +1 -1
- package/.agent-src/skills/rtk-output-filtering/SKILL.md +23 -8
- package/.agent-src/skills/rule-refactor/SKILL.md +145 -0
- package/.agent-src/skills/rule-writing/SKILL.md +34 -8
- package/.agent-src/skills/security/SKILL.md +38 -29
- package/.agent-src/skills/skill-reviewer/SKILL.md +1 -1
- package/.agent-src/skills/test-driven-development/SKILL.md +4 -4
- package/.agent-src/skills/test-performance/SKILL.md +6 -5
- package/.agent-src/skills/verify-completion-evidence/SKILL.md +24 -27
- package/.agent-src/templates/agents/agent-project-settings.example.yml +1 -1
- package/.agent-src/templates/copilot-instructions.md +2 -2
- package/.agent-src/templates/rule.md +2 -2
- package/.claude-plugin/marketplace.json +6 -4
- package/AGENTS.md +1 -1
- package/CHANGELOG.md +74 -170
- package/README.md +2 -2
- package/docs/architecture.md +2 -2
- package/docs/archive/CHANGELOG-pre-2.25.0.md +191 -0
- package/docs/catalog.md +17 -12
- package/docs/contracts/file-ownership-matrix.json +473 -43
- package/docs/contracts/kernel-membership.md +17 -0
- package/docs/contracts/smoke-contracts.md +8 -8
- package/docs/getting-started.md +1 -1
- package/docs/guidelines/php/api-design.md +1 -1
- package/docs/guidelines/php/controllers.md +1 -1
- package/docs/guidelines/php/resources.md +1 -1
- package/docs/guidelines/php/validations.md +1 -1
- package/package.json +1 -1
- package/scripts/build_linear_digest.py +0 -1
- package/scripts/lint_framework_leakage.py +348 -0
- package/scripts/lint_framework_leakage_allowlist.json +476 -0
- package/scripts/measure_augment_budget.py +6 -0
- package/scripts/schemas/command.schema.json +5 -0
- package/scripts/schemas/skill.schema.json +5 -0
- package/scripts/skill_linter.py +60 -7
- package/scripts/smoke/kernel.sh +4 -4
- package/scripts/smoke/router.sh +2 -2
- package/.agent-src/rules/agent-docs.md +0 -20
- package/.agent-src/rules/augment-portability.md +0 -23
- package/.agent-src/rules/capture-learnings.md +0 -19
- package/.agent-src/rules/docs-sync.md +0 -20
- package/.agent-src/rules/domain-safety-disclaimer-consulting.md +0 -52
- package/.agent-src/rules/domain-safety-disclaimer-financial.md +0 -54
- package/.agent-src/rules/domain-safety-disclaimer-legal.md +0 -49
- package/.agent-src/rules/domain-safety-disclaimer-medical.md +0 -56
- package/.agent-src/rules/domain-safety-export-redact.md +0 -65
- package/.agent-src/rules/domain-safety-logging-pii-floor.md +0 -55
- package/.agent-src/rules/domain-safety-pii-finance.md +0 -57
- package/.agent-src/rules/domain-safety-pii-marketing.md +0 -60
- package/.agent-src/rules/domain-safety-pii-recruiting.md +0 -56
- package/.agent-src/rules/domain-safety-pii-support.md +0 -57
- package/.agent-src/rules/domain-safety-retention-finance.md +0 -48
- package/.agent-src/rules/domain-safety-retention-support.md +0 -55
- package/.agent-src/rules/e2e-testing.md +0 -19
- package/.agent-src/rules/no-unsolicited-rebase.md +0 -107
- package/.agent-src/rules/post-push-rewrite-discipline.md +0 -70
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: api-endpoint
|
|
3
|
-
description: "Use when
|
|
3
|
+
description: "Use when creating an API endpoint or HTTP route handler — detects the project stack and routes to the matching carve-out (laravel-api-endpoint, nextjs-patterns, symfony-workflow)."
|
|
4
4
|
source: package
|
|
5
5
|
domain: engineering
|
|
6
6
|
---
|
|
@@ -9,178 +9,82 @@ domain: engineering
|
|
|
9
9
|
|
|
10
10
|
## When to use
|
|
11
11
|
|
|
12
|
-
Use this skill when the user asks to create a new API endpoint, REST route, or
|
|
13
|
-
|
|
12
|
+
Use this skill when the user asks to create a new API endpoint, REST route, or HTTP handler.
|
|
14
13
|
|
|
15
14
|
Do NOT use when:
|
|
16
|
-
- Modifying existing endpoints
|
|
17
|
-
- API design decisions (use `api-design`
|
|
18
|
-
|
|
19
|
-
##
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
4. **Create FormRequest** — Validate all input at the boundary.
|
|
25
|
-
5. **Create Resource** — Transform model output via API Resource.
|
|
26
|
-
6. **Verify** — Run PHPStan, run tests, confirm response shape matches conventions.
|
|
27
|
-
|
|
28
|
-
## Laravel projects
|
|
29
|
-
|
|
30
|
-
### What to generate
|
|
31
|
-
|
|
32
|
-
1. **Controller** — Single Action (invokable). Read `agents/docs/controller.md` and `../../../docs/guidelines/php/controllers.md`.
|
|
33
|
-
2. **FormRequest** — Validation rules, `authorize()` via policies. Read `../../../docs/guidelines/php/validations.md`.
|
|
34
|
-
3. **Resource** — JSON response transformation. Read `agents/docs/api-resources.md`.
|
|
35
|
-
4. **Route** — Add to the correct versioned route file.
|
|
36
|
-
5. **Policy** — If authorization is needed.
|
|
37
|
-
6. **Filter classes** — If it's a list endpoint with filtering. Read `agents/docs/query-filter.md` (if it exists).
|
|
38
|
-
|
|
39
|
-
### Conventions
|
|
40
|
-
|
|
41
|
-
- Controllers are thin — delegate to Services.
|
|
42
|
-
- **Every controller MUST return an API Resource** — never raw arrays, models, or `response()->json()`.
|
|
43
|
-
- Controllers type-hint the return value as the Resource class (e.g. `): ProjectResource`).
|
|
44
|
-
- Use `Resource::make()` for single items, `Resource::collection()` for lists.
|
|
45
|
-
- Use method injection on `__invoke()` for new controllers.
|
|
46
|
-
- Use DTOs for data transfer between layers.
|
|
47
|
-
|
|
48
|
-
### Show endpoint example
|
|
49
|
-
|
|
50
|
-
```php
|
|
51
|
-
declare(strict_types=1);
|
|
52
|
-
|
|
53
|
-
namespace App\Http\Controllers\v1\Project;
|
|
54
|
-
|
|
55
|
-
use App\Http\Controllers\Controller;
|
|
56
|
-
use App\Http\Requests\v1\Projects\ShowProjectRequest;
|
|
57
|
-
use App\Http\Resources\v1\Project\ProjectResource;
|
|
58
|
-
use App\Models\ExternalCustomerDatabase\Project\Project;
|
|
59
|
-
use App\OpenApi\Schema\Request\ShowResourceRequestSchema;
|
|
60
|
-
use App\OpenApi\Schema\Response\ResourceNotFoundResponse;
|
|
61
|
-
use App\OpenApi\Schema\Response\ShowResourceResponseSchema;
|
|
62
|
-
|
|
63
|
-
class ShowProjectController extends Controller
|
|
64
|
-
{
|
|
65
|
-
#[ShowResourceRequestSchema(path: '/projects/{id}', version: '1', resource: ProjectResource::class)]
|
|
66
|
-
#[ShowResourceResponseSchema(ProjectResource::class, wrapInDataObject: false)]
|
|
67
|
-
#[ResourceNotFoundResponse(ProjectResource::class)]
|
|
68
|
-
public function __invoke(ShowProjectRequest $request, Project $project): ProjectResource
|
|
69
|
-
{
|
|
70
|
-
return ProjectResource::make($project);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Create endpoint with service injection
|
|
76
|
-
|
|
77
|
-
```php
|
|
78
|
-
class CreateCustomerController extends Controller
|
|
79
|
-
{
|
|
80
|
-
#[CreateCustomerRequestSchema(path: '/customers', version: '1', resource: CustomerResource::class)]
|
|
81
|
-
#[CreateResourceResponseSchema(resource: CreatedCustomerResource::class, wrapInDataObject: false)]
|
|
82
|
-
#[ValidationErrorResponse]
|
|
83
|
-
public function __invoke(
|
|
84
|
-
CreateCustomerRequest $request,
|
|
85
|
-
CustomerModelService $customerService,
|
|
86
|
-
): CustomerResource {
|
|
87
|
-
$result = $customerService->create(CreateCustomerDTO::fromRequest($request));
|
|
88
|
-
|
|
89
|
-
return CreatedCustomerResource::make($result);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### FormRequest example
|
|
95
|
-
|
|
96
|
-
```php
|
|
97
|
-
declare(strict_types=1);
|
|
98
|
-
|
|
99
|
-
namespace App\Http\Requests\v1\Projects;
|
|
100
|
-
|
|
101
|
-
use Illuminate\Foundation\Http\FormRequest;
|
|
102
|
-
|
|
103
|
-
class ShowProjectRequest extends FormRequest
|
|
104
|
-
{
|
|
105
|
-
public function authorize(): bool
|
|
106
|
-
{
|
|
107
|
-
return $this->user()->can('view', $this->route('project'));
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/** @return array<string, mixed> */
|
|
111
|
-
public function rules(): array
|
|
112
|
-
{
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### List endpoint with CollectionFormRequest
|
|
119
|
-
|
|
120
|
-
For list endpoints, extend `CollectionFormRequest` which provides `perPage`, `page`, and `orderBy` rules:
|
|
121
|
-
|
|
122
|
-
```php
|
|
123
|
-
use App\Contracts\Http\Requests\CollectionFormRequest;
|
|
124
|
-
|
|
125
|
-
class ListProjectsRequest extends CollectionFormRequest
|
|
126
|
-
{
|
|
127
|
-
public string $model = Project::class;
|
|
128
|
-
|
|
129
|
-
/** @return array<string, mixed> */
|
|
130
|
-
public function rules(): array
|
|
131
|
-
{
|
|
132
|
-
return [
|
|
133
|
-
...parent::rules(),
|
|
134
|
-
'status' => ['sometimes', 'string'],
|
|
135
|
-
];
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### File locations
|
|
141
|
-
|
|
142
|
-
| Component | Path |
|
|
15
|
+
- Modifying existing endpoints — use the code-refactoring skill.
|
|
16
|
+
- API design decisions (versioning, deprecation, contract shape) — use [`api-design`](../api-design/SKILL.md).
|
|
17
|
+
|
|
18
|
+
## Stack routing
|
|
19
|
+
|
|
20
|
+
Detect the stack, then hand off to the matching carve-out skill for the framework-specific procedure (file layout, validation primitive, response-shaping convention).
|
|
21
|
+
|
|
22
|
+
| Detected stack | Carve-out skill |
|
|
143
23
|
|---|---|
|
|
144
|
-
|
|
|
145
|
-
|
|
|
146
|
-
|
|
|
147
|
-
|
|
|
148
|
-
|
|
|
24
|
+
| Laravel (`artisan` + `composer.json` with `laravel/framework`) | [`laravel-api-endpoint`](../laravel-api-endpoint/SKILL.md) |
|
|
25
|
+
| Symfony (`bin/console` + `composer.json` with `symfony/framework-bundle`) | [`symfony-workflow`](../symfony-workflow/SKILL.md) |
|
|
26
|
+
| Next.js (`next` in `package.json`) | [`nextjs-patterns`](../nextjs-patterns/SKILL.md) |
|
|
27
|
+
| Express / Fastify / NestJS / plain Node | follow project conventions in `agents/` + `package.json scripts` |
|
|
28
|
+
| FastAPI / Django / Flask | follow project conventions in `agents/` + `pyproject.toml` |
|
|
29
|
+
| Go (`net/http`, `gin`, `echo`, `fiber`) | follow project conventions in `agents/` + `go.mod` |
|
|
30
|
+
| Rust (`axum`, `actix-web`, `rocket`) | follow project conventions in `agents/` + `Cargo.toml` |
|
|
31
|
+
|
|
32
|
+
If the project doc folder (`agents/`) has an endpoint-creation guide, that is the source of truth — read it before generating code.
|
|
33
|
+
|
|
34
|
+
## Procedure: Create an API endpoint (stack-neutral)
|
|
35
|
+
|
|
36
|
+
1. **Read project docs** — Check `./agents/` and `AGENTS.md` for endpoint conventions, routing layout, response shape.
|
|
37
|
+
2. **Detect stack** and route to the carve-out per the table above.
|
|
38
|
+
3. **Plan the endpoint** — method, path, request shape, response shape, auth requirement, idempotency.
|
|
39
|
+
4. **Create the route registration** in the project's routing surface (route file, decorator-annotated handler, file-based router).
|
|
40
|
+
5. **Create the request handler / controller** — thin; delegate business logic to a service / use-case.
|
|
41
|
+
6. **Validate input at the boundary** via the framework's validation primitive (FormRequest, Zod, class-validator, Pydantic, struct-tag validators, etc.) — never inline ad-hoc `if` checks.
|
|
42
|
+
7. **Authorize the action** via the framework's authz primitive (Policy, voter, guard, middleware, route dependency).
|
|
43
|
+
8. **Shape the response** through a transformer / serializer / DTO — never return raw ORM entities.
|
|
44
|
+
9. **Document** the endpoint (OpenAPI annotations / generated spec / project doc).
|
|
45
|
+
10. **Verify** — run the project type-checker + targeted tests + smoke probe (`curl` / Bruno / Postman / integration test).
|
|
46
|
+
|
|
47
|
+
## Conventions (apply on every stack)
|
|
48
|
+
|
|
49
|
+
- **One handler, one responsibility** — prefer single-purpose handlers over multi-action controllers when the framework supports it.
|
|
50
|
+
- **No business logic in the handler** — delegate to a service / use-case layer.
|
|
51
|
+
- **Validate at the boundary** — never trust raw request data inside the handler.
|
|
52
|
+
- **Authorize every state-changing action** — no unprotected mutating endpoints.
|
|
53
|
+
- **Shape responses through a transformer** — DTO, serializer, API resource, response model — never expose raw ORM entities.
|
|
54
|
+
- **Version the API surface** explicitly (`/v1/`, header, content-type) — don't rely on implicit versioning.
|
|
149
55
|
|
|
150
|
-
|
|
56
|
+
## Stack-specific procedures
|
|
151
57
|
|
|
152
|
-
|
|
58
|
+
For Laravel projects (the most fully-fleshed-out carve-out in this package), see [`laravel-api-endpoint`](../laravel-api-endpoint/SKILL.md) — covers single-action controllers, `FormRequest`, `Resource`, `Policy`, `CollectionFormRequest`, OpenAPI attributes, and the versioned route layout.
|
|
153
59
|
|
|
154
|
-
-
|
|
155
|
-
- `ShowResourceResponseSchema`, `ListResourceResponseSchema`, `CreateResourceResponseSchema`
|
|
156
|
-
- `ResourceNotFoundResponse`, `ValidationErrorResponse`
|
|
60
|
+
For other stacks, read the matching carve-out from the table above and combine with the project's `agents/` docs.
|
|
157
61
|
|
|
158
62
|
## Output format
|
|
159
63
|
|
|
160
|
-
1. Generated files —
|
|
161
|
-
2. Test file with happy path and validation
|
|
162
|
-
3. Summary of created files and their locations
|
|
64
|
+
1. Generated files — route registration, handler, request validator, response shaper, authorization rule.
|
|
65
|
+
2. Test file with happy path and validation-error cases (using the project's test framework).
|
|
66
|
+
3. Summary of created files and their locations.
|
|
163
67
|
|
|
164
68
|
## Gotcha
|
|
165
69
|
|
|
166
|
-
- Don't forget to register the route — creating the
|
|
70
|
+
- Don't forget to register the route — creating the handler without the route is a common miss.
|
|
167
71
|
- Always check if a similar endpoint already exists — duplicates cause confusion.
|
|
168
|
-
-
|
|
169
|
-
-
|
|
72
|
+
- Validation rules must match the documented contract (OpenAPI / schema / typed client) — keep them in sync.
|
|
73
|
+
- Response shapes are part of the public contract — adding a field is additive; renaming or removing is breaking.
|
|
170
74
|
|
|
171
75
|
## Do NOT
|
|
172
76
|
|
|
173
|
-
- Do NOT put business logic in
|
|
174
|
-
- Do NOT skip
|
|
175
|
-
- Do NOT return raw
|
|
176
|
-
- Do NOT create
|
|
177
|
-
- Do NOT
|
|
178
|
-
- Do NOT use `response()->json()` — use `Resource::make()`.
|
|
77
|
+
- Do NOT put business logic in the handler — delegate to services / use-cases.
|
|
78
|
+
- Do NOT skip request validation — every handler validates at the boundary via the framework's primitive.
|
|
79
|
+
- Do NOT return raw ORM entities — always go through a transformer / serializer / response model.
|
|
80
|
+
- Do NOT create unprotected state-changing endpoints — authorize every mutation.
|
|
81
|
+
- Do NOT improvise framework idioms — read the carve-out (`laravel-api-endpoint`, `nextjs-patterns`, etc.) for the stack-correct shape.
|
|
179
82
|
|
|
180
83
|
## Auto-trigger keywords
|
|
181
84
|
|
|
182
85
|
- create endpoint
|
|
183
86
|
- new API route
|
|
87
|
+
- route handler
|
|
184
88
|
- controller creation
|
|
185
|
-
-
|
|
186
|
-
-
|
|
89
|
+
- REST endpoint
|
|
90
|
+
- add endpoint
|
|
@@ -151,6 +151,17 @@ expect($data['title'])->toBeString();
|
|
|
151
151
|
expect($data['total'])->toBeString(); // Money as string, not float
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
When a failing test dumps the full JSON body, narrow the diagnosis with `jq` or `grep`
|
|
155
|
+
instead of scrolling the whole payload:
|
|
156
|
+
|
|
157
|
+
```bash
|
|
158
|
+
# Extract only the failing assertion path
|
|
159
|
+
echo "$RESPONSE_JSON" | jq '.data.status, .errors'
|
|
160
|
+
|
|
161
|
+
# Targeted log scan
|
|
162
|
+
rg --json 'API call failed' storage/logs/laravel.log | jq -r '.data.lines.text'
|
|
163
|
+
```
|
|
164
|
+
|
|
154
165
|
## External service mocking
|
|
155
166
|
|
|
156
167
|
```php
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: code-refactoring
|
|
3
|
-
description: "Use when the user says
|
|
3
|
+
description: "Use when the user says 'refactor this', 'rename class', or 'move method'. Safely refactors code in any language — finds all callers, updates downstream dependencies, verifies via quality tools."
|
|
4
4
|
source: package
|
|
5
5
|
domain: engineering
|
|
6
6
|
---
|
|
@@ -20,7 +20,7 @@ Do NOT use when:
|
|
|
20
20
|
## Before refactoring
|
|
21
21
|
|
|
22
22
|
1. **Read the agent docs** — check `agents/docs/` and `agents/contexts/` for the area you're refactoring.
|
|
23
|
-
For modules, also read `app/Modules/{Module}/agents
|
|
23
|
+
For modules, also read the project's module-docs directory (path varies by stack — Laravel: `app/Modules/{Module}/agents/`; Nx: `apps/{app}/docs/`; mono-repo: per-package `docs/`). See the `project-docs` skill for the mapping.
|
|
24
24
|
2. **Understand the scope** — what exactly needs to change and why?
|
|
25
25
|
3. **Find ALL references** — use `codebase-retrieval` and `view` with `search_query_regex` to find every
|
|
26
26
|
caller, implementation, test, and configuration that references the code being changed.
|
|
@@ -34,34 +34,35 @@ Do NOT use when:
|
|
|
34
34
|
- Rename, extract, move, or restructure the target code.
|
|
35
35
|
- Keep the change minimal and focused.
|
|
36
36
|
|
|
37
|
-
### Step 2: Update all downstream
|
|
37
|
+
### Step 2: Update all downstream dependencies
|
|
38
38
|
|
|
39
39
|
For each affected file (from the impact analysis):
|
|
40
40
|
|
|
41
41
|
- **Callers**: Update method calls, constructor arguments, imports.
|
|
42
42
|
- **Interfaces / abstract methods**: Update all implementations to match new signatures.
|
|
43
43
|
- **Subclasses**: Update overridden methods.
|
|
44
|
-
- **Type hints /
|
|
44
|
+
- **Type hints / annotations**: Update type references (PHPDoc, TypeScript types, Python type hints, Go generics, Rust generics).
|
|
45
45
|
- **Config / bindings**: Update service container bindings, route references, etc.
|
|
46
|
-
- **Imports**: Add or update `use`
|
|
46
|
+
- **Imports**: Add or update import statements (`use` for PHP, `import` for JS/TS/Python, `import` blocks for Go, `use` for Rust).
|
|
47
47
|
|
|
48
|
-
### Step 3: Update API layer (if
|
|
48
|
+
### Step 3: Update API layer (if request handlers / endpoints are affected)
|
|
49
49
|
|
|
50
|
-
When refactoring touches
|
|
50
|
+
When refactoring touches handlers, route registrations, request validators, or response shapers, walk the stack-appropriate boundary. Use the carve-out skill for the project's framework if one exists; otherwise consult the table below for what to check on each stack.
|
|
51
51
|
|
|
52
|
-
|
|
|
52
|
+
| Layer | What to check and update |
|
|
53
53
|
|---|---|
|
|
54
|
-
| **
|
|
55
|
-
| **
|
|
56
|
-
| **
|
|
57
|
-
| **
|
|
58
|
-
| **
|
|
59
|
-
| **
|
|
60
|
-
| **
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
| **Route registration** | Route file / decorator / file-based-router entry — name, URL, HTTP method, parameter binding |
|
|
55
|
+
| **Handler / Controller** | Entry signature, injected dependencies, return type |
|
|
56
|
+
| **Request validator** | Validation rule definitions, allowlisted fields (FormRequest, Zod schema, class-validator DTO, Pydantic model, struct tags) |
|
|
57
|
+
| **Response shaper** | Field mapping in the transformer (API Resource, serializer, DTO mapper, response model) |
|
|
58
|
+
| **API contract** | OpenAPI annotations, generated spec, typed client (regenerate if generated) |
|
|
59
|
+
| **Authorization rule** | Policy / voter / guard / middleware / route dependency that protects the route |
|
|
60
|
+
| **Module routes** | Module-local routing surface (Laravel `app/Modules/*/Routes/`, Nx `apps/*/src/routes`, mono-repo per-package routes) |
|
|
61
|
+
|
|
62
|
+
Carve-out routing:
|
|
63
|
+
- Laravel: [`laravel-api-endpoint`](../laravel-api-endpoint/SKILL.md)
|
|
64
|
+
- Next.js: [`nextjs-patterns`](../nextjs-patterns/SKILL.md)
|
|
65
|
+
- Symfony: [`symfony-workflow`](../symfony-workflow/SKILL.md)
|
|
65
66
|
|
|
66
67
|
### Step 4: Update tests — with user approval
|
|
67
68
|
|
|
@@ -89,19 +90,24 @@ When refactoring touches controllers, requests, resources, or routes:
|
|
|
89
90
|
- Do NOT delete tests — adapt them to the new code structure.
|
|
90
91
|
- Do NOT reduce test coverage — if you split a class, split the test too.
|
|
91
92
|
|
|
92
|
-
### Step 5: Verify with quality tools
|
|
93
|
+
### Step 5: Verify with the project's quality tools
|
|
93
94
|
|
|
94
|
-
Run
|
|
95
|
+
Run the project's type-checker and linter after each significant step — do NOT batch everything to the end. The exact command set depends on the stack; resolve via `quality-tools` skill or the project's `Taskfile.yml` / `package.json scripts` / `composer.json scripts` / `Makefile`.
|
|
95
96
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
| Stack | Typical pipeline |
|
|
98
|
+
|---|---|
|
|
99
|
+
| Laravel / PHP | `vendor/bin/phpstan analyse` → `vendor/bin/rector process` → `vendor/bin/ecs check --fix` → re-run PHPStan |
|
|
100
|
+
| TypeScript | `tsc --noEmit` → `eslint --fix` → `prettier --write` |
|
|
101
|
+
| Python | `mypy` (or `pyright`) → `ruff check --fix` → `ruff format` |
|
|
102
|
+
| Go | `go vet ./...` → `golangci-lint run --fix` → `gofmt -w` |
|
|
103
|
+
| Rust | `cargo check` → `cargo clippy --fix` → `cargo fmt` |
|
|
104
|
+
|
|
105
|
+
If auto-fixers can rewrite types (Rector for PHP, `eslint --fix` for TS), re-run the type-checker after them — auto-fixers can introduce new errors.
|
|
100
106
|
|
|
101
107
|
### Step 6: Run tests
|
|
102
108
|
|
|
103
|
-
- Run tests related to the changed code first (`php artisan test --filter
|
|
104
|
-
- Then run the full test suite (`php artisan test`).
|
|
109
|
+
- Run tests related to the changed code first (`php artisan test --filter=...`, `pnpm test -- <pattern>`, `pytest -k <pattern>`, `go test ./{path}/...`, `cargo test {pattern}`).
|
|
110
|
+
- Then run the full test suite (`php artisan test`, `pnpm test`, `pytest`, `go test ./...`, `cargo test`).
|
|
105
111
|
- All tests must pass before the refactoring is considered complete.
|
|
106
112
|
|
|
107
113
|
### Step 7: Update documentation
|
|
@@ -142,9 +148,9 @@ After the code changes are verified, update all affected documentation:
|
|
|
142
148
|
1. Update controller + request + resource + OpenAPI schemas + route → present test changes →
|
|
143
149
|
update docs (`agents/docs/controller.md`, `agents/docs/api-resources.md`) → run PHPStan → run tests.
|
|
144
150
|
|
|
145
|
-
### Replace
|
|
146
|
-
1. Create new
|
|
147
|
-
changes → update docs → run PHPStan → run tests → remove old
|
|
151
|
+
### Replace implementation (e.g. switch service)
|
|
152
|
+
1. Create new implementation → update binding → find all direct references → update → present test
|
|
153
|
+
changes → update docs → run PHPStan → run tests → remove old implementation.
|
|
148
154
|
|
|
149
155
|
### Move/restructure module
|
|
150
156
|
1. Move files → update namespaces → update `ModuleServiceProvider` if needed → update module routes →
|
|
@@ -37,68 +37,73 @@ Use this skill when:
|
|
|
37
37
|
|
|
38
38
|
## Review checklist
|
|
39
39
|
|
|
40
|
+
The checks below are stack-agnostic. For framework-specific conventions (PSR-12 + `declare(strict_types=1)`, FormRequest, single-action `__invoke`, API Resources, Pest, Blade escaping, Eloquent N+1) defer to the carve-outs:
|
|
41
|
+
- PHP / Laravel → [`laravel`](../laravel/SKILL.md), [`laravel-validation`](../laravel-validation/SKILL.md), [`eloquent`](../eloquent/SKILL.md), [`pest-testing`](../pest-testing/SKILL.md), [`blade-ui`](../blade-ui/SKILL.md), [`php-coder`](../php-coder/SKILL.md)
|
|
42
|
+
- Symfony → [`symfony-workflow`](../symfony-workflow/SKILL.md)
|
|
43
|
+
- Next.js / TS → [`nextjs-patterns`](../nextjs-patterns/SKILL.md), [`react-shadcn-ui`](../react-shadcn-ui/SKILL.md)
|
|
44
|
+
|
|
40
45
|
### Code quality
|
|
41
46
|
|
|
42
47
|
| Check | What to look for |
|
|
43
48
|
|---|---|
|
|
44
|
-
| **
|
|
45
|
-
| **
|
|
46
|
-
| **Naming** | Clear, descriptive names
|
|
49
|
+
| **Type discipline** | New code is fully typed in the project's idiom (PHP typed properties + `declare(strict_types=1)`, TS strict, Python type hints, Go / Rust by construction). |
|
|
50
|
+
| **Style conformance** | Matches the project's formatter / linter output — no reformatting battles, no out-of-band style. |
|
|
51
|
+
| **Naming** | Clear, descriptive names; matches the dominant casing in the surrounding code (camelCase / snake_case / PascalCase per the language's idiom). |
|
|
47
52
|
| **Early returns** | No deep nesting. Guard clauses at the top. |
|
|
48
|
-
| **Single responsibility** | Each class/
|
|
49
|
-
| **No magic** | No
|
|
50
|
-
| **
|
|
53
|
+
| **Single responsibility** | Each class / module / function does one thing. HTTP handlers stay thin. |
|
|
54
|
+
| **No magic** | No reach-through to globals (`app()`, `$_GET`, ambient context). No untyped data shapes leaking out of the I/O boundary. |
|
|
55
|
+
| **Doc comments** | Only where the type system is insufficient (generics, complex shapes). No redundant docblocks. |
|
|
51
56
|
|
|
52
57
|
### Architecture
|
|
53
58
|
|
|
54
59
|
| Check | What to look for |
|
|
55
60
|
|---|---|
|
|
56
|
-
| **Layer separation** | Business logic in services, not
|
|
57
|
-
| **
|
|
58
|
-
| **
|
|
59
|
-
| **
|
|
60
|
-
| **DTOs** | Structured data
|
|
61
|
-
| **Dependency injection** | Constructor injection
|
|
61
|
+
| **Layer separation** | Business logic in services / use-cases, not in HTTP handlers. Domain models stay I/O-free. |
|
|
62
|
+
| **Handler shape** | New handlers follow the framework's recommended shape (Laravel single-action `__invoke`, Next.js route handler, Express handler-per-route). See the stack carve-out. |
|
|
63
|
+
| **Input validation** | Validated at the request boundary via the framework's primitive (Laravel `FormRequest`, Zod / class-validator, Pydantic, struct-tag validators). No ad-hoc inline `if` checks. |
|
|
64
|
+
| **Response shaping** | Returns through a transformer / serializer / DTO. Never returns raw ORM entities. |
|
|
65
|
+
| **DTOs / value objects** | Structured data between layers, not raw associative arrays / `any` / `dict[str, Any]`. |
|
|
66
|
+
| **Dependency injection** | Constructor injection (or framework-idiomatic equivalent). No service-locator calls in business logic. |
|
|
62
67
|
|
|
63
68
|
### Database & Performance
|
|
64
69
|
|
|
65
70
|
| Check | What to look for |
|
|
66
71
|
|---|---|
|
|
67
|
-
| **N+1 queries** | Relationship access in loops without eager loading |
|
|
68
|
-
| **Missing indexes** | New columns used in WHERE/JOIN without index |
|
|
69
|
-
| **Unbounded queries** | `Model::all()`
|
|
70
|
-
| **Raw SQL** |
|
|
71
|
-
| **Migrations** | Reversible
|
|
72
|
-
| **Money** | Uses `decimal`
|
|
72
|
+
| **N+1 queries** | Relationship / association access in loops without eager / batch loading. |
|
|
73
|
+
| **Missing indexes** | New columns used in `WHERE` / `JOIN` without a supporting index. |
|
|
74
|
+
| **Unbounded queries** | Full-table reads (`Model::all()`, `SELECT *` without `LIMIT`, unpaged list endpoints). |
|
|
75
|
+
| **Raw SQL** | Parameterised queries only. No string concatenation with user input. |
|
|
76
|
+
| **Migrations** | Reversible. Targets the right connection / schema. Idempotent where the platform supports it. |
|
|
77
|
+
| **Money / precision** | Uses an exact-precision type (PHP `decimal` / `Math` helper, TS bigint / decimal lib, Python `Decimal`), never `float`. |
|
|
73
78
|
|
|
74
79
|
### Security
|
|
75
80
|
|
|
76
81
|
| Check | What to look for |
|
|
77
82
|
|---|---|
|
|
78
|
-
| **Authorization** |
|
|
79
|
-
| **Input validation** | All user input validated via
|
|
80
|
-
| **Mass assignment** | No
|
|
81
|
-
| **
|
|
82
|
-
| **
|
|
83
|
-
| **Sensitive data** | No secrets, tokens, or passwords in code or
|
|
83
|
+
| **Authorization** | Authz check at every state-changing endpoint (Laravel Policy, Symfony voter, NestJS guard, framework middleware). No unprotected mutating routes. |
|
|
84
|
+
| **Input validation** | All user input validated at the boundary via the framework's primitive. |
|
|
85
|
+
| **Mass assignment** | No bulk-binding raw request payloads to ORM entities without an explicit allow-list (`$fillable` / `$guarded` in Laravel, DTO mapping in TS / Python). |
|
|
86
|
+
| **Injection** | No raw queries / command lines / template strings with unescaped user input. |
|
|
87
|
+
| **Output encoding** | Template output is escaped by default; raw / unescaped output is intentional and reviewed (Blade `{{ }}` vs `{!! !!}`, React `dangerouslySetInnerHTML`, Jinja `\|safe`). |
|
|
88
|
+
| **Sensitive data** | No secrets, tokens, or passwords in code, logs, or error responses. |
|
|
84
89
|
|
|
85
90
|
### Tests
|
|
86
91
|
|
|
87
92
|
| Check | What to look for |
|
|
88
93
|
|---|---|
|
|
89
|
-
| **Coverage** | New code paths have tests. Bug fixes have regression tests. |
|
|
90
|
-
| **Test quality** | Tests verify
|
|
91
|
-
| **
|
|
92
|
-
| **
|
|
94
|
+
| **Coverage** | New code paths have tests. Bug fixes have regression tests (RED → GREEN). |
|
|
95
|
+
| **Test quality** | Tests verify behaviour, not implementation details. |
|
|
96
|
+
| **Framework idiom** | Correct conventions for the project's test framework (Pest / PHPUnit, Jest / Vitest, pytest, `go test`, `cargo test`) — see the stack carve-out for specifics. |
|
|
97
|
+
| **Test data** | Provisioned via the project's idiom (seeders, factories, fixtures, builders). |
|
|
93
98
|
| **Assertions** | Meaningful assertions. Not just "no exception thrown". |
|
|
94
|
-
| **Flaky risks** | Time-dependent tests
|
|
99
|
+
| **Flaky risks** | Time-dependent tests freeze the clock (`travel()`, `jest.useFakeTimers()`, `freezegun`). No reliance on execution speed. |
|
|
95
100
|
|
|
96
101
|
## Before creating a PR
|
|
97
102
|
|
|
98
|
-
1. Run quality pipeline
|
|
99
|
-
2. Run tests
|
|
103
|
+
1. Run the project's quality pipeline (see the stack carve-out for the exact commands — PHP: `quality-tools`).
|
|
104
|
+
2. Run tests via the project's runner (`make test`, `npm test`, `pytest`, `go test ./...`, or the project's wrapper script).
|
|
100
105
|
3. Ensure CI passes on the branch.
|
|
101
|
-
4. Self-review the diff: `git diff origin/main..HEAD
|
|
106
|
+
4. Self-review the diff: `git diff origin/main..HEAD`.
|
|
102
107
|
|
|
103
108
|
## Receiving feedback
|
|
104
109
|
|
|
@@ -114,7 +119,7 @@ When receiving code review feedback, follow this sequence:
|
|
|
114
119
|
6. **IMPLEMENT** — One item at a time, test each.
|
|
115
120
|
|
|
116
121
|
If **any item is unclear**, STOP — do not implement anything yet. Items may be related;
|
|
117
|
-
partial understanding
|
|
122
|
+
partial understanding leads to wrong implementation.
|
|
118
123
|
|
|
119
124
|
### No performative agreement
|
|
120
125
|
|
|
@@ -132,7 +137,7 @@ partial understanding → wrong impl.
|
|
|
132
137
|
**External / Copilot / bot feedback** (less context):
|
|
133
138
|
- Check: Technically correct for THIS codebase?
|
|
134
139
|
- Check: Does it break existing functionality?
|
|
135
|
-
- Check: Is there a reason for the current
|
|
140
|
+
- Check: Is there a reason for the current implementation?
|
|
136
141
|
- Check: Does the reviewer understand the full context?
|
|
137
142
|
- **YAGNI check:** If the reviewer suggests "implementing properly", grep the codebase
|
|
138
143
|
for actual usage. If unused → suggest removing (YAGNI).
|
|
@@ -181,7 +186,7 @@ Description and suggested improvement.
|
|
|
181
186
|
Description.
|
|
182
187
|
```
|
|
183
188
|
|
|
184
|
-
Group related findings. Don't repeat what
|
|
189
|
+
Group related findings. Don't repeat what the project's linter / type-checker already catches — focus on
|
|
185
190
|
logic, architecture, and things tools can't detect.
|
|
186
191
|
|
|
187
192
|
## Adversarial review
|
|
@@ -211,5 +216,5 @@ Focus on the "Code changes / Refactoring" attack questions.
|
|
|
211
216
|
- Do NOT approve without actually reading the code.
|
|
212
217
|
- Do NOT agree with review comments without verifying them against the codebase.
|
|
213
218
|
- Do NOT use performative language when responding to feedback ("Great point!", "Excellent catch!").
|
|
214
|
-
- Do NOT nitpick style issues
|
|
219
|
+
- Do NOT nitpick style issues the project's formatter / auto-refactor (ECS, Prettier, Ruff, gofmt) handles automatically.
|
|
215
220
|
- Do NOT merge without CI passing and quality checks green.
|
|
@@ -71,7 +71,7 @@ source when the user is unsure.
|
|
|
71
71
|
|---|---|
|
|
72
72
|
| `auth-model.md` | Policy classes, Gate definitions, permission seeders, role enums, `@can` directives, middleware |
|
|
73
73
|
| `tenant-boundaries.md` | Base query scopes, connection-switching middleware, tenant-resolution service, global scopes, `.env` vars like `TENANT_*` |
|
|
74
|
-
| `data-sensitivity.md` | Eloquent `$hidden` / `$casts`, Sentry `beforeSend`, logging helpers, API resources, export commands |
|
|
74
|
+
| `data-sensitivity.md` | ORM hidden-field config (Eloquent `$hidden` / `$casts`, Symfony `#[Ignore]`, Prisma `select` defaults, SQLAlchemy `__init__` filters), Sentry `beforeSend`, logging redaction helpers, API serialisers / resources, export commands |
|
|
75
75
|
| `deployment-order.md` | `database/migrations/`, feature-flag config (Pennant / LaunchDarkly), deploy scripts, CI workflow, rollback runbooks in `docs/` |
|
|
76
76
|
| `observability.md` | `config/logging.php`, Sentry init, dashboard links in READMEs, alert rules in Terraform/Grafana dashboards |
|
|
77
77
|
|
|
@@ -14,8 +14,8 @@ domain: engineering
|
|
|
14
14
|
Use when designing schemas, optimizing queries, adding indexes, or troubleshooting database performance.
|
|
15
15
|
|
|
16
16
|
Do NOT use when:
|
|
17
|
-
- Writing
|
|
18
|
-
- Creating migrations only
|
|
17
|
+
- Writing framework-specific ORM models (use the matching skill — e.g. `eloquent` for Laravel, `symfony-workflow` for Doctrine, framework-native skill for Prisma / TypeORM / SQLAlchemy / GORM / Diesel)
|
|
18
|
+
- Creating migrations only — use the framework-specific migration skill (`laravel-migration` for Laravel, framework-native for others)
|
|
19
19
|
|
|
20
20
|
## Procedure: Optimize a query
|
|
21
21
|
|
|
@@ -52,7 +52,12 @@ Re-run `EXPLAIN` and confirm improved plan.
|
|
|
52
52
|
|
|
53
53
|
1. **Read migrations** — source of truth
|
|
54
54
|
2. **Read models** — `$table`, `$connection`, `$fillable`, `$casts`, relationships
|
|
55
|
-
3. **Run schema queries** —
|
|
55
|
+
3. **Run schema queries** — use the project's REPL or a raw introspection query:
|
|
56
|
+
- Laravel: `php artisan tinker --execute="Schema::getColumnListing('table')"`
|
|
57
|
+
- Symfony / Doctrine: `bin/console doctrine:mapping:info`
|
|
58
|
+
- Rails: `bin/rails runner "p ActiveRecord::Base.connection.columns('table').map(&:name)"`
|
|
59
|
+
- Prisma: `npx prisma db pull --print | grep -A20 "model Table"`
|
|
60
|
+
- Generic SQL: `psql -d mydb -c "\d table"` / `mysql -e "DESCRIBE table"`
|
|
56
61
|
4. **Check project docs** — `agents/docs/` for conventions
|
|
57
62
|
|
|
58
63
|
| Trap | Reality |
|