You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+43-43Lines changed: 43 additions & 43 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,36 +6,36 @@ This document provides guidance for AI assistants helping users work with Larave
6
6
7
7
Laravel Blaze is a performance optimization package that pre-renders static portions of Blade components at compile-time, dramatically reducing runtime overhead. It works by:
8
8
9
-
1. Identifying components marked with the `@pure` directive in their source
9
+
1. Identifying components marked with the `@blaze` directive in their source
10
10
2. Analyzing component source for runtime dependencies
11
11
3. Pre-rendering eligible components during Blade compilation
12
12
4. Falling back to normal rendering for unsafe components
13
13
14
14
## Core Concepts
15
15
16
-
### The @pure Directive
16
+
### The @blaze Directive
17
17
18
-
The `@pure` directive tells Blaze that a component has no runtime dependencies and can be safely optimized. It must be placed at the top of a component file:
18
+
The `@blaze` directive tells Blaze that a component has no runtime dependencies and can be safely optimized. It must be placed at the top of a component file:
19
19
20
20
```blade
21
-
@pure
21
+
@blaze
22
22
23
23
@props(['title'])
24
24
25
25
<h1 class="text-2xl font-bold">{{ $title }}</h1>
26
26
```
27
27
28
-
The `@pure` directive supports optional parameters to control different optimization strategies:
28
+
The `@blaze` directive supports optional parameters to control different optimization strategies:
29
29
30
30
```blade
31
31
{{-- All optimizations enabled (default) --}}
32
-
@pure
32
+
@blaze
33
33
34
34
{{-- Explicitly enable all optimizations --}}
35
-
@pure(fold: true, memo: true, aware: true)
35
+
@blaze(fold: true, memo: true, aware: true)
36
36
37
37
{{-- Disable specific optimizations --}}
38
-
@pure(fold: false, memo: true, aware: false)
38
+
@blaze(fold: false, memo: true, aware: false)
39
39
```
40
40
41
41
**Parameters:**
@@ -45,7 +45,7 @@ The `@pure` directive supports optional parameters to control different optimiza
45
45
46
46
### Code Folding Process
47
47
48
-
When a `@pure` component is encountered, Blaze:
48
+
When a `@blaze` component is encountered, Blaze:
49
49
1. Replaces dynamic content being passed in via attributes or slots with placeholders
50
50
2. Renders the component with placeholders
51
51
3. Validates that placeholders are preserved
@@ -58,7 +58,7 @@ When a component can't be folded (due to dynamic content), Blaze automatically f
58
58
59
59
## Helping Users Analyze Components
60
60
61
-
When a user asks about adding `@pure` to a component or wants you to analyze their components, follow this process:
61
+
When a user asks about adding `@blaze` to a component or wants you to analyze their components, follow this process:
- Components that contain other components which use runtime data
139
-
- Parent components can't be `@pure` if any child component is dynamic
140
-
- Watch for `<x-*>` tags inside the component that might be non-pure
139
+
- Parent components can't be `@blaze` if any child component is dynamic
140
+
- Watch for `<x-*>` tags inside the component that might be non-foldable
141
141
142
142
### 4. Analysis Process
143
143
144
144
When analyzing a component:
145
145
146
146
1.**Scan for unsafe patterns** using the lists above
147
-
2.**Check for child components** - look for any `<x-*>` tags and verify they are also pure
147
+
2.**Check for child components** - look for any `<x-*>` tags and verify they are also foldable
148
148
3.**Check for indirect dependencies** - props that might contain dynamic data (like paginator objects)
149
149
4.**Consider context** - how the component is typically used
150
150
5.**Test edge cases** - what happens with different prop values
151
151
152
152
#### Special Case: Nested Components
153
153
154
-
When a component directly renders other Blade components in its template (not via slots), verify those are also pure:
154
+
When a component directly renders other Blade components in its template (not via slots), verify those are also foldable:
155
155
156
156
```blade
157
157
{{-- Parent component --}}
158
-
@pure <!-- ⚠️ Only safe if directly rendered child components are pure -->
158
+
@blaze <!-- ⚠️ Only safe if directly rendered child components are foldable -->
159
159
160
160
<div class="data-table">
161
-
<x-table-header /> <!-- Must be pure -->
161
+
<x-table-header /> <!-- Must be foldable -->
162
162
{{ $slot }} <!-- ✅ Slot content is handled separately, can be dynamic -->
163
-
<x-table-footer /> <!-- Must be pure -->
164
-
<x-table-pagination /> <!-- ❌ If this uses paginator, parent can't be @pure -->
163
+
<x-table-footer /> <!-- Must be foldable -->
164
+
<x-table-pagination /> <!-- ❌ If this uses paginator, parent can't be @blaze -->
165
165
</div>
166
166
```
167
167
168
168
**Key distinction**:
169
-
- Components **hardcoded in the template** must be pure for the parent to be @pure
169
+
- Components **hardcoded in the template** must be foldable for the parent to be @blaze
170
170
- Content **passed through slots** is handled separately and can be dynamic
171
171
172
172
### 5. Making Recommendations
173
173
174
174
**For safe components:**
175
175
```
176
-
This component is safe for @pure because it only renders static HTML and passed props. Add @pure at the top of the file.
176
+
This component is safe for @blaze because it only renders static HTML and passed props. Add @blaze at the top of the file.
177
177
```
178
178
179
179
**For unsafe components:**
180
180
```
181
-
This component cannot use @pure because it contains [specific pattern]. The [pattern] changes at runtime and would be frozen at compile-time, causing incorrect behavior.
181
+
This component cannot use @blaze because it contains [specific pattern]. The [pattern] changes at runtime and would be frozen at compile-time, causing incorrect behavior.
182
182
```
183
183
184
184
**For borderline cases:**
185
185
```
186
-
This component might be safe for @pure, but consider if [specific concern]. Test thoroughly after adding @pure to ensure it behaves correctly across different requests. If folding isn't possible, memoization will still provide performance benefits.
186
+
This component might be safe for @blaze, but consider if [specific concern]. Test thoroughly after adding @blaze to ensure it behaves correctly across different requests. If folding isn't possible, memoization will still provide performance benefits.
187
187
```
188
188
189
189
## Common User Requests
190
190
191
-
### "Can I add @pure to this component?"
191
+
### "Can I add @blaze to this component?"
192
192
193
193
1. Read the component file
194
194
2. Analyze for unsafe patterns
195
195
3. Provide a clear yes/no with explanation
196
196
4. If no, suggest alternatives or modifications
197
197
198
-
### "Add @pure to my components"
198
+
### "Add @blaze to my components"
199
199
200
200
1. Find all component files (`resources/views/components/**/*.blade.php`)
201
201
2. Analyze each component individually
202
-
3. Add `@pure` only to safe components (include a line break after `@pure` )
202
+
3. Add `@blaze` only to safe components (include a line break after `@blaze` )
203
203
4. Report which components were modified and which were skipped with reasons
204
204
205
205
### "Optimize my Blade components"
206
206
207
-
1. Audit existing components for @pure eligibility
208
-
2. Identify components that could be refactored to be pure
207
+
1. Audit existing components for @blaze eligibility
208
+
2. Identify components that could be refactored to be foldable
209
209
3. Suggest architectural improvements for better optimization
210
210
4. Provide before/after examples
211
211
212
212
## Implementation Guidelines
213
213
214
-
### Adding @pure to Components
214
+
### Adding @blaze to Components
215
215
216
-
When adding `@pure` to a component:
216
+
When adding `@blaze` to a component:
217
217
218
218
1.**Always read the component first** to understand its structure
219
-
2.**Add @pure as the very first line** of the component file
219
+
2.**Add @blaze as the very first line** of the component file
0 commit comments