[BUG] Claude generates Filament v3 code patterns instead of v4, causing fatal errors
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
FROM CLAUDE:
Description
When working on a Laravel project using Filament v4, Claude consistently generates code using
Filament v3 patterns, resulting in fatal PHP errors. This happens even when:
- The codebase clearly uses Filament v4
- CLAUDE.md explicitly documents the v3→v4 differences
- Working v4 examples exist in the same codebase
- The user has corrected the same mistake multiple times in the conversation
Impact
- Site-breaking errors: Fatal PHP errors crash the application
- Repeated corrections: User must fix the same issue across multiple files
- Lost productivity: Each new resource/component risks the same mistake
- Trust erosion: User cannot rely on generated Filament code being correct
Expected Behavior
Claude should:
- Recognize Filament v4 from composer.json, existing code patterns, or explicit documentation
- Generate v4-compatible code by default for projects using v4
- When corrected once, apply the fix pattern consistently to subsequent code generation
Environment
- Filament v4
- Laravel 12.x
- PHP 8.3
Suggested Improvements
- Update training data: Include Filament v4 patterns and migration guides
- Context awareness: Detect Filament version from composer.json or composer.lock
- Pattern matching: When working code exists in the codebase, match its import/usage patterns
- Session learning: When corrected, apply the correction to all subsequent related code
What Should Happen?
When generating Filament code, Claude should detect
the Filament version from the project (via
composer.json, existing code patterns, or explicit
documentation like CLAUDE.md) and generate
version-appropriate code. For Filament v4 projects,
Claude should use the correct v4 import paths and
method signatures instead of defaulting to v3
patterns.
Additionally, when corrected within a conversation,
Claude should apply that correction consistently
to all subsequent code generation in the same
session rather than repeating the same mistake.
Error Messages/Logs
Error
app/Filament/Admin/Resources/RegisteredDomainResource.php:221
Class "Filament\Schemas\Components\TextEntry" not found
Steps to Reproduce
Here's the steps to reproduce:
---
- Create a Laravel project with Filament v4
installed
- Add a CLAUDE.md file documenting Filament v4
patterns (optional but shows even explicit
documentation doesn't prevent the issue):
## Filament v4 (CRITICAL)
This project uses Filament v4. Use these patterns:
- Infolist entries:
Filament\Infolists\Components\TextEntry
- Schema method:
infolist(Schema $schema): Schema - Outer schema uses
->schema([...]) - Section uses
->components([...])
- Ask Claude to create a Filament resource with an
infolist:
Create a Filament resource for a User model with a
view page that shows an infolist with name, email,
and status fields
- Claude generates code with v3 patterns:
use Filament\Schemas\Components\TextEntry; //
WRONG - class doesn't exist in v4
public static function infolist(Schema $schema):
Schema
{
return $schema
->components([ // WRONG - should be
->schema()
Section::make('User')
->schema([ // WRONG - should be
->components()
TextEntry::make('name'), //
WRONG - needs InfolistComponents\ prefix
]),
]);
}
- Application crashes with:
Class "Filament\Schemas\Components\TextEntry" not
found
- Correct Claude and ask it to fix the issue
- Ask Claude to create another resource with an
infolist
- Claude generates the same incorrect v3 patterns
again, despite the previous correction
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.62 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Warp
Additional Information
_No response_
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗