Skip to content

Commit d0a2dee

Browse files
committed
spark: aion
0 parents  commit d0a2dee

363 files changed

Lines changed: 22236 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.ai/agents/laravel-simplifier.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
name: laravel-simplifier
3+
description: Simplifies and refines PHP/Laravel code for clarity, consistency, and maintainability while preserving all functionality. Focuses on recently modified code unless instructed otherwise.
4+
model: opus
5+
---
6+
7+
You are an expert PHP/Laravel code simplification specialist focused on enhancing code clarity, consistency, and maintainability while preserving exact functionality. Your expertise lies in applying Laravel best practices and standards to simplify and improve code without altering its behavior. You prioritize readable, explicit code over overly compact solutions. This is a balance that you have mastered as a result of your years as an expert PHP developer.
8+
9+
You will analyze recently modified code and apply refinements that:
10+
11+
1. **Preserve Functionality**: Never change what the code does - only how it does it. All original features, outputs, and behaviors must remain intact.
12+
13+
2. **Apply Project Standards**: Follow the established coding standards from CLAUDE.md including:
14+
15+
- Use proper namespace declarations and organize imports logically
16+
- Prefer explicit return type declarations on methods
17+
- Follow Laravel conventions for controllers, models, and services
18+
- Use proper error handling patterns (exceptions, custom exception classes)
19+
- Maintain consistent naming conventions (PSR-12, Laravel standards)
20+
21+
3. **Enhance Clarity**: Simplify code structure by:
22+
23+
- Reducing unnecessary complexity and nesting
24+
- Eliminating redundant code and abstractions
25+
- Improving readability through clear variable and function names
26+
- Consolidating related logic
27+
- Removing unnecessary comments that describe obvious code
28+
- IMPORTANT: Avoid nested ternary operators - prefer match expressions, switch statements, or if/else chains for multiple conditions
29+
- Choose clarity over brevity - explicit code is often better than overly compact code
30+
31+
4. **Maintain Balance**: Avoid over-simplification that could:
32+
33+
- Reduce code clarity or maintainability
34+
- Create overly clever solutions that are hard to understand
35+
- Combine too many concerns into single methods or classes
36+
- Remove helpful abstractions that improve code organization
37+
- Prioritize "fewer lines" over readability (e.g., nested ternaries, dense one-liners)
38+
- Make the code harder to debug or extend
39+
40+
5. **Focus Scope**: Only refine code that has been recently modified or touched in the current session, unless explicitly instructed to review a broader scope.
41+
42+
Your refinement process:
43+
44+
1. Identify the recently modified code sections
45+
2. Analyze for opportunities to improve elegance and consistency
46+
3. Apply project-specific best practices and coding standards
47+
4. Ensure all functionality remains unchanged
48+
5. Verify the refined code is simpler and more maintainable
49+
6. Document only significant changes that affect understanding
50+
51+
You operate autonomously and proactively, refining code immediately after it's written or modified without requiring explicit requests. Your goal is to ensure all code meets the highest standards of elegance and maintainability while preserving its complete functionality.

.ai/artifacts/.gitkeep

Whitespace-only changes.

.ai/commands/reflect.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## /reflect - Analyze session for retrospective on mistakes and patterns
2+
3+
**Purpose**: Analyze the current session for reusable patterns and mistakes, then update modular guideline files (stubs or overrides) in `.ai/guidelines/` with learnings.
4+
5+
**Usage**: `/reflect`
6+
7+
**Process**:
8+
1. I will analyze the session for:
9+
- Recurring mistakes that happened multiple times
10+
- Universal patterns that are domain-agnostic
11+
- Decision points where confusion arose
12+
- Architectural/design patterns violated or followed
13+
- Testing patterns and organization issues (AAA, Data Providers, etc.)
14+
- Code quality and style issues (Commenting, PHP 8 features)
15+
- Module boundary violations (Isolation, Contracts, Events)
16+
17+
2. I will categorize learnings by their related guideline file:
18+
- **Compliance/Process**`.ai/guidelines/stubs/compliance.stub`
19+
- **Modular Architecture**`.ai/guidelines/stubs/architecture.stub`
20+
- **PHP Standards**`.ai/guidelines/php/core.blade.php` (override extending Boost PHP)
21+
- **Laravel Architecture**`.ai/guidelines/laravel/core.blade.php` (override extending Boost Laravel)
22+
- **General Code Quality**`.ai/guidelines/stubs/quality.stub`
23+
- **PHPUnit Testing**`.ai/guidelines/phpunit/core.blade.php` (override for PHPUnit standards)
24+
- **Agent Behavior**`.ai/guidelines/stubs/behavior.stub`
25+
26+
3. I will determine if learnings should be:
27+
- **Added to existing guidelines**: Universal, reusable patterns applicable to all future work
28+
- **Saved as session notes**: Feature-specific or temporary learnings in `.ai/guidelines/stubs/session-learnings.stub` (create file if it doesn't exist)
29+
30+
4. I will generate proposed changes with:
31+
- Clear section title referencing the related guideline file
32+
- Organized subsections matching existing modular structure
33+
- Concrete examples using `<code-snippet>` tags where helpful
34+
- Consistent formatting matching existing stubs (Zero Emoji Usage)
35+
- Absolute file paths for all references
36+
37+
5. I will show you the proposed changes and ask for confirmation
38+
39+
6. Only after your approval will I:
40+
- Update/Create the appropriate `.stub` or `.blade.php` files
41+
- **MANDATORY**: Run `php artisan boost:update` to synchronize changes into `CLAUDE.md`
42+
43+
**Confirmation prompt**:
44+
```
45+
Here are the proposed additions based on this session's learnings:
46+
47+
[PROPOSED CHANGES TO .ai/guidelines/...]
48+
49+
Do you want me to apply these changes and run boost:update? (yes/no)
50+
```
51+
52+
**Guidelines for Updates**:
53+
- Follow the exact format of existing files (stubs or blade overrides)
54+
- Use standard Markdown headers and spacing
55+
- Add to existing sections when possible, create new sections only when necessary
56+
- Keep entries concise but complete with concrete examples
57+
- Mirror the style of existing guideline files (High density, professional tone)
58+
- Never add suggestions - only mandatory requirements
59+
- NEVER use emojis (including symbols like ✅/❌)
60+
- Use bold text for emphasis instead of icons
61+
- Ensure code examples use `<code-snippet>` tags
62+
63+
**Note**: The command focuses on reusable patterns and mandatory requirements. After any modification to the modular files, `php artisan boost:update` must be executed to ensure the authoritative `CLAUDE.md` remains in sync with the source stubs and overrides.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# MANDATORY COMPLIANCE & STANDARDS
2+
3+
**CRITICAL**: Every item in this file is a MANDATORY requirement. This document serves as the authoritative preamble for CLAUDE.md.
4+
5+
---
6+
7+
{!! Blade::render(file_get_contents(base_path('.ai/guidelines/stubs/compliance.stub')), ['assist' => $assist]) !!}
8+
9+
---
10+
11+
{!! Blade::render(file_get_contents(base_path('.ai/guidelines/stubs/architecture.stub')), ['assist' => $assist]) !!}
12+
13+
---
14+
15+
{!! Blade::render(file_get_contents(base_path('.ai/guidelines/stubs/quality.stub')), ['assist' => $assist]) !!}
16+
17+
---
18+
19+
{!! Blade::render(file_get_contents(base_path('.ai/guidelines/stubs/behavior.stub')), ['assist' => $assist]) !!}
20+
21+
---
22+
23+
@if(file_exists(base_path('.ai/guidelines/stubs/session-learnings.stub')))
24+
{!! Blade::render(file_get_contents(base_path('.ai/guidelines/stubs/session-learnings.stub')), ['assist' => $assist]) !!}
25+
@endif
26+
27+
---
28+
29+
**Remember: Every single item in this document is a requirement, not a suggestion.**
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{!! Blade::render(file_get_contents(base_path('vendor/laravel/boost/.ai/laravel/core.blade.php')), ['assist' => $assist]) !!}
2+
3+
### Requests
4+
- Never use inline validation. Always use Form Requests.
5+
6+
### Resources
7+
- **No database queries in API Resources.** Make sure the controller are providing all needed data.
8+
9+
### Architecture Constraints
10+
- **Follow event-driven architecture** with service contracts and dependency injection.
11+
- **Actions & DTOs**: Follow strict structural requirements (defined in **Guidelines: Architecture**). For the creation procedure, refer to **Skill: create-dto-action**.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{!! Blade::render(file_get_contents(base_path('vendor/laravel/boost/.ai/phpunit/core.blade.php')), ['assist' => $assist]) !!}
2+
3+
### Suite Selection & Naming
4+
5+
#### 1. Unit Tests (`*UnitTest.php`)
6+
- **Purpose**: Test a single class in isolation without Laravel's container or database.
7+
- **Base Class**: `Tests\Support\TestCases\UnitTestCase`.
8+
- **Location**: Mirror `app/` in `tests/App/` (e.g., `tests/App/Modules/Auth/DTOs/UserDataUnitTest.php`).
9+
- **Targets**: DTOs, Value Objects, Exceptions, pure logic classes.
10+
- **Preference**: Use whenever logic doesn't require database or complex service integration.
11+
12+
#### 2. Functional Tests (`*FunctionalTest.php`)
13+
- **Purpose**: Test the integration of internal module components and business logic.
14+
- **Base Class**: `Tests\Support\TestCases\FunctionalTestCase`.
15+
- **Location**: Mirror `app/` in `tests/App/` (e.g., `tests/App/Modules/Auth/Actions/RegisterUserActionFunctionalTest.php`).
16+
- **Targets**: Actions (main entry points), Models (relationships/scopes), Service Providers.
17+
- **Entails**: Database access, Event fakes, mocking other module Actions.
18+
19+
#### 3. Integration Tests (`*IntegrationTest.php`)
20+
- **Purpose**: Test the HTTP Transport layer and the full request/response cycle.
21+
- **Base Class**: `Tests\Support\TestCases\FunctionalTestCase`.
22+
- **Location**: Mirror `app/Http/` in `tests/Integration/Http/` (e.g., `tests/Integration/Http/Api/Auth/LoginIntegrationTest.php`).
23+
- **Targets**: Controllers, Form Requests, API Resources, Routing.
24+
- **Entails**: Mocking the business logic (Action) to focus strictly on the transport layer (validation, status codes, JSON structure).
25+
- **Mandatory**: Every Integration test MUST include a `test_it_integrates()` method that exercises the endpoint **without any mocking** to ensure the entire stack is correctly wired. This test does NOT need to be comprehensive; it should simply make a valid request and ensure it succeeds.
26+
27+
#### Mirroring Rule
28+
- All tests in `tests/App/` and `tests/Integration/` MUST mirror the corresponding directory structure of the file being tested.
29+
30+
### AAA+A Formatting
31+
*(Procedure: Refer to Skill: format-phpunit-tests)*
32+
- **Supported Blocks**: `// Arrange`, `// Anticipate` (for mocks/expectations), `// Act`, `// Assert`.
33+
- **Absolute Enclosure**: **NOTHING** must be defined outside of these blocks. Every piece of code MUST fall under one of these headers.
34+
- **Leave exactly ONE extra line break** after each comment (`// Arrange\n\n`).
35+
- **Never add extra content to the block comments**: Put the comment in a separate line, with a two line break apart from the block comment.
36+
<code-snippet name="Example clean AAA blocks" lang="php">
37+
❌ BAD
38+
// Arrange - Create a user in the US region so it triggers a {particular} pre-condition
39+
40+
$user = User::region('us')->create();
41+
42+
---
43+
44+
✅ GOOD
45+
// Arrange
46+
47+
// Create a user in the US region so it triggers a {particular} pre-condition
48+
$user = User::region('us')->create();
49+
</code-snippet>
50+
51+
### Dependency Injection
52+
- **Always use `resolve(ClassName::class)`** - Laravel IoC will inject spies/mocks automatically.
53+
- **Create spies before calling `resolve()`.**
54+
- **Never manually instantiate with `new ClassName()`** if it has dependencies. Unless it is a Unit test.
55+
56+
### Data Providers
57+
- **Always use `Generator`**.
58+
- **Use descriptive string keys**.
59+
60+
<code-snippet name="Data Provider Example" lang="php">
61+
public static function dataProvider(): Generator
62+
{
63+
yield 'successful scenario' => [
64+
'input' => 'valid',
65+
'expected' => true,
66+
];
67+
68+
yield 'unsuccessful scenario' => [
69+
'input' => 'invalid',
70+
'expected' => false,
71+
];
72+
}
73+
</code-snippet>
74+
75+
### Implementation Standards
76+
- **Use `spy()` over `mock()`** unless you need to set expectations (Anticipate block).
77+
- **Always use `LogFake::bind()`** to mock logs.
78+
- **Never test private methods directly**.
79+
- **NEVER test controllers directly** (use HTTP endpoint integration tests).
80+
- **Always add `CoversClass(ClassName::class)` attirubte(s)** to all tests adding the classes being covered.

.ai/guidelines/pint/core.blade.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## Laravel Pint Code Formatter
2+
3+
- You must run `composer style:fix` before finalizing changes to ensure your code matches the project's expected style.
4+
- Do not run `vendor/bin/pint --test`, simply run `composer style:fix` to fix any formatting issues.

.ai/guidelines/stubs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
session-learnings.stub
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## MODULAR ARCHITECTURE
2+
3+
### CORE ARCHITECTURAL PRINCIPLE
4+
The application is structured into **Modules** representing distinct business domains. Each module must be self-contained and isolated.
5+
6+
### MODULE BOUNDARIES
7+
- **Modules must be isolated**. No direct use of another module's Models/Actions.
8+
- **Communication via Contracts**: Use interfaces in `app/Modules/Domain/Contracts`.
9+
- **Prefer Events for Decoupling**.
10+
- **No Cross-Module Database Joins**.
11+
12+
### DIRECTORY STRUCTURE
13+
*(Procedure: Refer to Skill: 'scaffold-module')*
14+
15+
- **Logic**: `app/Modules/{Domain}/`
16+
- `Actions/`: Single-method business logic classes.
17+
- `Models/`: Domain-specific Eloquent models.
18+
- `DTOs/`: Readonly data transfer objects.
19+
- `Contracts/`: Interfaces for cross-module interaction.
20+
- `Enums/`: Domain enumerations.
21+
- `Services/`: Complex logic spanning multiple actions.
22+
- `Exceptions/`: Domain-specific exceptions.
23+
- **Transport**: `app/Http/{Application}/{Domain}/`
24+
- `Controllers/`: Bridges HTTP requests to Actions.
25+
- `Requests/`: Form Requests for validation.
26+
- `Resources/`: Eloquent API Resources for JSON transformation.
27+
- `Shared/`: Shared components for all domains.
28+
29+
### SHARED COMPONENTS
30+
- **Definition**: Components located in `app/Modules/Shared/` (e.g., `User` model, shared interfaces).
31+
- **Status**: Shared models are considered **Global Contracts**. They may be used directly across module boundaries without additional interfaces.
32+
- **Limit**: Only truly universal domain concepts should reside in the Shared module.
33+
### SERVICES
34+
- **Purpose**: Orchestrate logic spanning multiple Actions or interact with complex external SDKs.
35+
- **Constraint**: Must adhere to strict typing and constructor property promotion.
36+
- **Caution**: Avoid "fat services" that violate single-responsibility. Prefer granular Actions.
37+
38+
### EXCEPTIONS
39+
- **Standard**: Actions must throw domain-specific exceptions (e.g., `UnableToLoginException`) for expected failure states.
40+
- **Handling**: Controllers are responsible for catching domain exceptions and converting them to HTTP responses (e.g., via `ValidationException`).
41+
42+
### ACTIONS
43+
*(Procedure: Refer to Skill: 'create-dto-action')*
44+
45+
- **Naming**: Use `VerbNounAction` naming convention (e.g., `CreateUserAction`).
46+
- **Method**: Must have exactly **ONE** public method: `public function execute()`.
47+
- **Parameters**: Accept only **ONE** parameter (use a DTO for multiple).
48+
- **No Data Querying**: Actions should be pure executors of logic. They must NOT perform database queries (e.g. `User::find()`) to retrieve their inputs.
49+
- **Pure State**: All necessary models or state MUST be provided to the `execute()` method via the DTO.
50+
- **Isolation**: Return Contracts (e.g. `AuthenticatableWithIdentity`) rather than concrete Models.
51+
- **Testability**: Mark with `/** @final */` annotation instead of the `final` keyword.
52+
53+
### DTOS
54+
*(Procedure: Refer to Skill: 'create-dto-action')*
55+
56+
- **Structure**: Must be `final readonly` classes.
57+
- **Promotion**: Use PHP 8.2+ `readonly` class modifier and constructor property promotion.
58+
- **Provisioning**: DTOs are responsible for encapsulating ALL inputs required by the Action.
59+
- **Factories**: Use static factory methods (e.g., `fromRequest()`) to resolve and inject models/dependencies. The factory is the layer where "finding" data occurs, keeping the Action clean.

.ai/guidelines/stubs/behavior.stub

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
## COMPOSER SCRIPTS
2+
3+
This project defines named scripts in `composer.json`. **Always prefer `composer scripts` over calling vendor binaries directly** when a script exists for the tool. Check the scripts section of `composer.json` before invoking any quality tool.
4+
5+
| Script | Purpose |
6+
|---|---|
7+
| `composer test` | Clear config + run full test suite |
8+
| `composer test:parallel` | Run tests in parallel via paratest |
9+
| `composer test:coverage` | Generate HTML coverage report |
10+
| `composer style:fix` | Run Laravel Pint formatter |
11+
| `composer phpstan` | Run PHPStan with project config + 2G memory limit |
12+
| `composer rector` | Run Rector with project config |
13+
14+
---
15+
16+
## AGENT BEHAVIOR
17+
18+
### Communication Rules
19+
- **No Emojis** in responses (except requirement markers).
20+
- **No Fluff Documentation**: Never generate unnecessary markdown files (e.g., `COMPLETION_REPORT.md`, `SUMMARY.md`, etc.).
21+
- **Never assume action from observation**.
22+
- When the user asks a question about your changes, don't imply the user is asking you to change anything. **Answer the question** as is and wait for the next instruction.
23+
24+
### Artifact Management Rules
25+
26+
- **Use `.ai/artifacts/` folder EXCLUSIVELY** for all AI-generated artifacts including:
27+
- Execution plans (unless you are in an environment that has interactive plans like Antigravity)
28+
- Summaries
29+
- Audits
30+
- Analysis reports
31+
- Investigation notes
32+
- Any other AI-generated documentation
33+
- **NEVER write AI-generated artifacts** to other folders (e.g., `docs/`, root directory).
34+
- **Keep artifacts organized** with descriptive filenames including dates (e.g., `SECURITY_AUDIT_2026_01_14.md`).
35+
- **NEVER modify user-managed documentation** in `docs/`, `wiki/`, or any other project folders unless explicitly requested.
36+
37+
### TASK FINALIZATION
38+
*(Refer to skill: `task-finalization` for procedure)*
39+
Before completing a task, you MUST run the project's quality tools (Style, Analysis, Refactor, Types, Tests) as defined in the skill. This is not optional.

0 commit comments

Comments
 (0)