Aiku ERP Laravel Development Assistant
An expert Laravel development assistant specifically configured for the Aiku white-label ERP system. This skill enforces Laravel 12 best practices, Inertia v2 patterns, Pest testing standards, and Aiku-specific architectural conventions.
What This Skill Does
This skill guides you through developing features in the Aiku ERP application following its established patterns, conventions, and best practices. It ensures code quality, proper testing, and adherence to Laravel ecosystem standards while respecting the legacy Laravel 10 file structure.
Core Technology Stack
**Backend**: Laravel 12 (PHP 8.4), Horizon, Octane, Sanctum, Scout, Pennant**Frontend**: Inertia v2, Vue 3, Tailwind CSS 3**Testing**: Pest 4, PHPUnit 12**Code Quality**: Laravel Pint**Additional**: Laravel Echo, Ziggy, Socialite, TelescopeInstructions for AI Agent
1. Code Writing Standards
**Never write code comments**. Write clear, self-explanatory code instead.
**PHP Standards:**
Always use curly braces for control structures, even single-lineUse PHP 8 constructor property promotion: `public function __construct(public GitHub $github) {}`Do not allow empty `__construct()` methodsAlways use explicit return type declarationsUse appropriate PHP type hints for parametersPrefer PHPDoc blocks over inline commentsUse TitleCase for Enum keys**Example:**
```php
protected function isAccessible(User $user, ?string $path = null): bool
{
// Implementation
}
```
2. Laravel Best Practices
**File Creation:**
Always use `php artisan make:` commands with `--no-interaction` flagUse `php artisan make:class` for generic PHP classesCheck `list-artisan-commands` tool for available options**Database & Eloquent:**
Use Eloquent models and relationships, NOT raw queriesPrefer `Model::query()` over `DB::`Always use eager loading to prevent N+1 queriesUse proper relationship methods with return type hintsWhen modifying columns in migrations, include ALL previous attributes**Model Creation:**
Create factories and seeders for new modelsUse `casts()` method instead of `$casts` property (follow existing conventions)**APIs:**
Default to Eloquent API Resources with versioningFollow existing application conventions if different**Validation:**
Always create Form Request classes, never inline validationCheck sibling Form Requests for array vs string validation styleInclude custom error messages**Configuration:**
Never use `env()` outside config filesAlways use `config('app.name')`, not `env('APP_NAME')`**URL Generation:**
Prefer named routes and `route()` function**Queues:**
Use queued jobs with `ShouldQueue` for time-consuming operations3. Laravel 10 File Structure
This project uses the Laravel 10 structure (NOT Laravel 12's streamlined structure):
Middleware: `app/Http/Middleware/`Service providers: `app/Providers/`Middleware registration: `app/Http/Kernel.php`Exception handling: `app/Exceptions/Handler.php`Console commands: `app/Console/Kernel.php`No `bootstrap/app.php` configuration**Do not migrate to Laravel 12 structure unless explicitly requested.**
4. Inertia v2 Best Practices
**Component Location:**
Place in `resources/js/Pages` (check `vite.config.js` for overrides)Use `Inertia::render()` for routing**Inertia v2 Features (use extensively):**
PollingPrefetchingDeferred props with animated skeleton empty statesInfinite scrolling with merging props and `WhenVisible`Lazy loading on scroll**Forms:**
Recommended: Use `<Form>` component (search docs: "form component")Alternative: Use `useForm` helper for programmatic controlUse `resetOnError`, `resetOnSuccess`, `setDefaultsOnSuccess`**Example:**
```php
// routes/web.php
Route::get('/users', function () {
return Inertia::render('Users/Index', [
'users' => User::all()
]);
});
```
5. Testing with Pest 4
**Critical Requirements:**
Every change MUST be programmatically testedWrite or update tests, then run them to verifyRun minimum tests needed: `php artisan test --filter=testName`Never remove tests without approval**Test Structure:**
All tests use Pest (NOT PHPUnit)Feature tests: `tests/Feature/`Unit tests: `tests/Unit/`Create: `php artisan make:test --pest {name}` (add `--unit` for unit tests)**Test Patterns:**
```php
it('returns all', function () {
$response = $this->postJson('/api/docs', []);
$response->assertSuccessful(); // Use specific assertions
});
```
**Assertions:**
Use specific methods: `assertForbidden`, `assertNotFound`NOT generic: `assertStatus(403)`**Test Data:**
Use model factories (check for custom states first)Use `$this->faker->word()` or `fake()->randomDigit()` (follow existing conventions)**Running Tests:**
All tests: `php artisan test`Single file: `php artisan test tests/Feature/ExampleTest.php`Filtered: `php artisan test --filter=testName`After passing tests, ask user if they want to run full test suite**Mocking:**
Import: `use function Pest\Laravel\mock;`Or use: `$this->mock()` if existing tests do6. Code Formatting
**DO NOT run `vendor/bin/pint --dirty` automatically** (per guidelines).
**But remember:** Code must be formatted before finalization. If needed:
Run: `vendor/bin/pint` (NOT `--test`)Never run `vendor/bin/pint --dirty`7. Feature Flags (Laravel Pennant)
Application uses Pennant for feature flag managementControls feature availability across organizations and user typesSearch docs for specific implementation guidance8. Conventions & Architecture
**Directory Structure:**
Follow existing structure strictlyDon't create new base folders without approvalCheck sibling files for structure, approach, naming conventions**Naming:**
Use descriptive names: `isRegisteredForDiscounts` not `discount()`Follow existing naming patterns**Component Reuse:**
Check for existing components before creating new ones**Dependencies:**
Do not change without approval**Frontend Changes:**
If UI doesn't reflect changes, may need: `npm run build`, `npm run dev`, or `composer run dev`9. Documentation
**Only create documentation files if explicitly requested by the user.**
10. Error Handling
**Vite Manifest Error:**
If "Unable to locate file in Vite manifest" occursRun `npm run build` or ask user to run `npm run dev`/`composer run dev`11. Response Style
Be concise - focus on what's importantDon't explain obvious detailsProvide clear, actionable guidance12. Workflow for Changes
1. **Understand** - Check sibling files for conventions
2. **Search docs** - Use `search-docs` tool for Laravel ecosystem packages (use multiple broad queries like `['rate limiting', 'routing']`)
3. **Plan** - Use Artisan commands for file creation
4. **Implement** - Follow standards above
5. **Test** - Write/update Pest tests, run filtered tests
6. **Verify** - Ensure tests pass
7. **Format** - Apply Pint if needed (but NOT `--dirty`)
8. **Confirm** - Ask user if they want full test suite run
Examples
**Creating a New Feature:**
```bash
1. Create model with factory and seeder
php artisan make:model Product --factory --seed --no-interaction
2. Create Form Request for validation
php artisan make:request StoreProductRequest --no-interaction
3. Create controller
php artisan make:controller ProductController --no-interaction
4. Create Pest test
php artisan make:test ProductTest --pest --no-interaction
5. Write feature, following conventions
6. Run filtered tests
php artisan test --filter=Product
```
**Proper Eloquent Usage:**
```php
// ✅ Good - Eager loading, typed relationships
public function index(): InertiaResponse
{
$products = Product::query()
->with(['category', 'images'])
->latest()
->limit(10)
->get();
return Inertia::render('Products/Index', [
'products' => $products
]);
}
// ❌ Bad - Raw queries, N+1 problems
public function index()
{
$products = DB::select('SELECT * FROM products');
return Inertia::render('Products/Index', compact('products'));
}
```
Important Constraints
Never bypass established conventions without approvalAlways test changes programmaticallyFollow Laravel 10 file structure (not Laravel 12)Use Eloquent over raw queriesCreate Form Requests for validationUse Pest for all testsNever remove tests without approvalCheck documentation before implementing featuresBe concise in explanationsThis skill ensures high-quality, maintainable code that follows Aiku ERP's established patterns and Laravel ecosystem best practices.