BEFORE ANY CHANGES:
- READ EXISTING CODE - Use Read tool, analyze patterns, check implementations
- VERIFY CLAUDE.MD LOADED - Reference architectural patterns, follow conventions
- UNDERSTAND ARCHITECTURE - Check dependencies, existing helpers/traits
- FIGHT MESSY CODE - Reject hacks, use existing patterns
MULTI-TOOL PARALLEL ATTACK:
# RUN IN PARALLEL
- mcp__github-ai__analyze_with_context7 (50+ lines)
- mcp__sequential-thinking__sequentialthinking (complex problems)
- Task tool + Bash tinker + Multiple Grep/ReadDEEP DATA INSPECTION:
$attributes = $record->getAttributes(); // Raw DB values
$casted = $record->toArray(); // Laravel casted values
foreach ($fields as $field => $value) {
echo "{$field}: " . gettype($value) . (is_array($value) ? ' [ARRAY-DANGER!]' : '');
}FILAMENT ARRAY BUG SOLUTIONS:
// ❌ NEVER: TextEntry::make('array_field')->formatStateUsing(...)
// ✅ ALWAYS: Computed fields with getStateUsing()
TextEntry::make('field_display')
->getStateUsing(function (Model $record): string {
try {
if (is_array($state)) {
\Log::error('ARRAY DETECTED', ['field' => 'name', 'value' => $state]);
return 'ERROR: Array - ' . json_encode($state);
}
return $state?->someMethod() ?? 'fallback';
} catch (\Exception $e) {
\Log::error('FIELD ERROR', ['error' => $e->getMessage()]);
return 'Error: ' . $e->getMessage();
}
})- MANDATORY CODE READING - Never change without reading existing first
- CLAUDE.MD COMPLIANCE - Always verify loaded, follow patterns
- PARALLEL TOOL EXECUTION - Multiple tools simultaneously
- 100% ACCURACY DEMAND - Full context (200+ lines minimum)
- SYSTEMATIC ELIMINATION - Remove components to isolate problems
- DEEP DATA INSPECTION - Raw vs casted analysis on every bug
- ERROR-FIRST THINKING - Assume arrays break string components
- COMPREHENSIVE LOGGING - Debug every suspected component
- ANTI-MESSY CODE - Reject hacks, demand clean solutions
- Array Fields: NEVER direct access - Use computed fields with
getStateUsing() - Enum Fields: ALWAYS null coalescing (
$state?->getLabel()) - Complex Data: Create virtual fields (
field_display) - Cache Issues: Clear cache after changes - Filament caches aggressively
- Multi-Tenant: All queries respect tenant scoping via policies
BANNED BEHAVIORS: ❌ Copy-paste coding ❌ Spaghetti flows ❌ Magic numbers ❌ God methods ❌ Tight coupling ❌ No error handling ❌ Unclear naming ❌ Long parameters ❌ Deep nesting ❌ Mixed responsibilities
SENIOR COMMANDMENTS:
- Single Responsibility - One thing, done well
- DRY Enforcement - Extract to methods/traits/helpers
- Readable Code - Descriptive names, explain WHY not WHAT
- Simple Flows - Linear paths, early returns, guard clauses
- Composition - Traits, dependency injection, focused interfaces
CODE QUALITY GATES:
- Methods ≤20 lines | Classes ≤300 lines | Parameters ≤4 items
- Nesting ≤3 levels | Single purpose | Testable design
IF CODE >50 LINES - EMERGENCY INTERVENTION:
1. ❌ REJECT massive code immediately
2. 🔍 ANALYZE what it accomplishes
3. 🧠 BREAK DOWN into 3-5 components
4. 📋 CREATE proper architecture plan
5. ✅ IMPLEMENT incrementally
RED FLAGS - INTERVENE IMMEDIATELY: 🚨 God class >500 lines 🚨 Monolith method >30 lines 🚨 Copy-paste 3+ times 🚨 Nested hell >4 levels 🚨 Parameter chaos 6+ 🚨 Mixed responsibilities 🚨 No separation 🚨 Hardcoded nightmare
5-STEP INTERVENTION:
- STOP & ANALYZE - WHAT/WHO/WHERE/WHEN/WHY
- DECOMPOSE - Validation service, repository, DTOs, domain services, presenters
- DESIGN ARCHITECTURE - Controller→Service→Repository→Model
- IMPLEMENT INCREMENTALLY - Core→Business→API→UI→Testing
- VALIDATE STANDARDS - SRP, <20 lines, <300 lines, testable, patterns
ANTI-PSYCHO TECHNIQUES:
// ✅ SENIOR: Extract services, form requests, DTOs, repositories
class OrderController {
public function store(CreateOrderRequest $request) {
$order = $this->orderService->create($request->validated());
return new OrderResource($order);
}
}- "ACTIVATE PSYCHO-JUNIOR PREVENTION - NO 2000-line madness!"
- "ENFORCE 50-LINE MAXIMUM - Break down massive code!"
- "APPLY SENIOR ARCHITECT INTERVENTION - 5-step process!"
- "IMPLEMENT ANTI-PSYCHO TECHNIQUES - Services, DTOs, repositories!"
- "VALIDATE EMERGENCY STOPS - No god classes/monoliths!"
- "FOLLOW INCREMENTAL IMPLEMENTATION - Small pieces!"
- "MAINTAIN QUALITY GATES - Single responsibility, testable!"
- "FIGHT JUNIOR MADNESS - Clean, focused code only!"
✅ Methods <20 lines? ✅ Classes <300 lines? ✅ Single responsibility?
✅ Self-documenting? ✅ Unit testable? ✅ Follows project patterns?
✅ Maintainable? ✅ Proper separation? ✅ No repeated code? ✅ Error handling?
IF ANY NO → REJECT & REDESIGN!
- Test Changes: Run lint/typecheck after changes
- Tinker Debug: Test data structures before UI implementation
- Multi-Tool: Parallel debugging for efficiency
- Deep Analysis: Raw vs casted data comparison
- Follow Patterns: Examine similar implementations first
- Use Helpers: Check existing traits/services before creating
- Maintain Consistency: Follow naming/architectural conventions
- Senior Standards: Maintainable, reusable, clean architecture
- Array Handling: Never TextEntry on arrays - use getStateUsing()
- Enum Display: Always null coalescing for labels
- Cache Updates: Clear Filament cache after changes
- Error Handling: Try-catch with logging for formatters
- Tenant Isolation: Respect team-based scoping
- Permissions: Use policies/middleware for access control
- Observers: Follow established patterns for lifecycle events
- Performance: Eager loading, efficient queries, prevent N+1
- Read First: Use Read tool before changes
- Verify Architecture: Ensure fits documented patterns
- Check Dependencies: Verify methods/classes exist via Grep/Read
- Test Incrementally: Isolate each change before next component
- Do what's asked - nothing more, nothing less
- NEVER create files unless absolutely necessary
- ALWAYS prefer editing existing files
- NEVER create documentation files unless explicitly requested