-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4-quick-reference.html
More file actions
419 lines (407 loc) Β· 16.5 KB
/
4-quick-reference.html
File metadata and controls
419 lines (407 loc) Β· 16.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quick Reference Cards - Claude Integration Guide</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.6; color: #333; background: #f5f7fa;
}
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white; padding: 30px 20px; border-radius: 8px; margin-bottom: 40px;
}
header h1 { font-size: 2em; margin-bottom: 10px; }
.breadcrumb { margin-bottom: 20px; color: #666; }
.breadcrumb a { color: #667eea; text-decoration: none; }
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
gap: 20px;
margin-bottom: 30px;
}
.card {
background: white; padding: 20px; border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.05);
border-left: 4px solid #667eea;
}
.card h3 {
color: #667eea; margin-bottom: 15px; margin-top: 0;
}
.card code {
display: block; background: #f5f5f5; padding: 10px;
border-radius: 4px; margin: 10px 0; font-size: 0.9em;
overflow-x: auto;
}
.card p { margin: 10px 0; color: #666; }
.card ul { margin-left: 20px; line-height: 1.8; }
code { background: #f5f5f5; padding: 2px 6px; border-radius: 3px; color: #d63384; }
pre {
background: #2d2d2d; color: #f8f8f2; padding: 15px; border-radius: 6px;
overflow-x: auto; font-size: 0.9em; margin: 15px 0;
}
section {
background: white; padding: 30px; border-radius: 8px;
margin-bottom: 20px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
h2 {
color: #667eea; margin-top: 0; margin-bottom: 20px;
border-bottom: 2px solid #667eea; padding-bottom: 10px;
}
.nav-links {
display: flex; justify-content: space-between; margin-top: 40px; gap: 10px;
}
.nav-links a {
flex: 1; padding: 12px; background: #667eea; color: white;
text-decoration: none; border-radius: 6px; text-align: center; transition: background 0.3s;
}
.nav-links a:hover { background: #764ba2; }
footer { text-align: center; color: #666; margin-top: 40px; padding: 20px; border-top: 1px solid #ddd; }
</style>
</head>
<body>
<div class="container">
<div class="breadcrumb">
<a href="ai-guide-index.html">Home</a> / Quick Reference
</div>
<header>
<h1>β‘ Quick Reference Cards</h1>
<p>Copy-paste cheat sheets for common tasks and patterns</p>
</header>
<section>
<h2>Claude Code Commands</h2>
<div class="card-grid">
<div class="card">
<h3>π Getting Started</h3>
<code>claude-code</code>
<p>Start Claude Code in current directory</p>
</div>
<div class="card">
<h3>πΎ Create Commit</h3>
<code>/commit</code>
<p>Auto-generate commit message with changes</p>
</div>
<div class="card">
<h3>π Review PR</h3>
<code>/review-pr [PR_NUMBER]</code>
<p>Review GitHub pull request</p>
</div>
<div class="card">
<h3>β‘ Fast Mode</h3>
<code>/fast</code>
<p>Toggle fast mode (quicker responses)</p>
</div>
<div class="card">
<h3>π Focus File</h3>
<code>/file path/to/file.js</code>
<p>Focus Claude's context on specific file</p>
</div>
<div class="card">
<h3>π§Ή Clear History</h3>
<code>/clear</code>
<p>Reset conversation history</p>
</div>
</div>
</section>
<section>
<h2>React Common Patterns</h2>
<div class="card-grid">
<div class="card">
<h3>π¦ useState Hook</h3>
<code>const [state, setState] = useState(initialValue)</code>
<p>Manage component state in functional components</p>
</div>
<div class="card">
<h3>π useEffect Hook</h3>
<code>useEffect(() => { /* effect */ }, [dependencies])</code>
<p>Handle side effects (API calls, subscriptions)</p>
</div>
<div class="card">
<h3>π£ useCallback Hook</h3>
<code>const memoized = useCallback(() => {}, [deps])</code>
<p>Memoize function to prevent unnecessary re-renders</p>
</div>
<div class="card">
<h3>πΎ useContext Hook</h3>
<code>const value = useContext(MyContext)</code>
<p>Access context value in component</p>
</div>
<div class="card">
<h3>π― useReducer Hook</h3>
<code>const [state, dispatch] = useReducer(reducer, init)</code>
<p>Complex state management in components</p>
</div>
<div class="card">
<h3>π Conditional Render</h3>
<code>{condition ? <ComponentA /> : <ComponentB />}</code>
<p>Render different components based on condition</p>
</div>
</div>
</section>
<section>
<h2>Laravel Common Patterns</h2>
<div class="card-grid">
<div class="card">
<h3>π Create Model</h3>
<pre>php artisan make:model Post -mrc</pre>
<p>Create Model with migration, controller, and resource</p>
</div>
<div class="card">
<h3>π Eloquent Relationships</h3>
<pre>// One-to-Many
public function posts() {
return $this->hasMany(Post::class);
}</pre>
<p>Define relationships between models</p>
</div>
<div class="card">
<h3>β
Form Validation</h3>
<pre>$request->validate([
'email' => 'required|email|unique:users'
]);</pre>
<p>Validate incoming request data</p>
</div>
<div class="card">
<h3>π Authorization</h3>
<pre>$this->authorize('update', $post);
// or Gate::authorize('name')</pre>
<p>Check user permissions</p>
</div>
<div class="card">
<h3>π Query Builder</h3>
<pre>User::where('active', 1)
->orderBy('created_at', 'desc')
->paginate(15)</pre>
<p>Build complex queries</p>
</div>
<div class="card">
<h3>π Eager Loading</h3>
<pre>$users = User::with('posts', 'comments')->get();</pre>
<p>Prevent N+1 query problems</p>
</div>
</div>
</section>
<section>
<h2>Testing Quick Commands</h2>
<div class="card-grid">
<div class="card">
<h3>π§ͺ Run Jest Tests</h3>
<code>npm test</code>
<p>Run all Jest test suites</p>
</div>
<div class="card">
<h3>π― Run Specific Test</h3>
<code>npm test Button.test.js</code>
<p>Run single test file</p>
</div>
<div class="card">
<h3>π Coverage Report</h3>
<code>npm test -- --coverage</code>
<p>Generate code coverage report</p>
</div>
<div class="card">
<h3>βΆοΈ Run PHPUnit</h3>
<code>php artisan test</code>
<p>Run Laravel tests</p>
</div>
<div class="card">
<h3>π Playwright Tests</h3>
<code>npx playwright test</code>
<p>Run all Playwright E2E tests</p>
</div>
<div class="card">
<h3>π Debug Test</h3>
<code>npx playwright test --debug</code>
<p>Run tests in debug mode</p>
</div>
</div>
</section>
<section>
<h2>Git Commands Cheat Sheet</h2>
<div class="card-grid">
<div class="card">
<h3>π Create Branch</h3>
<code>git checkout -b feature/name</code>
<p>Create and switch to new branch</p>
</div>
<div class="card">
<h3>π Stage Changes</h3>
<code>git add filename.js</code>
<p>Stage specific file for commit</p>
</div>
<div class="card">
<h3>β
Commit</h3>
<code>git commit -m "feat: description"</code>
<p>Create commit with message</p>
</div>
<div class="card">
<h3>π Push to Remote</h3>
<code>git push origin feature/name</code>
<p>Push branch to remote repository</p>
</div>
<div class="card">
<h3>π Pull Latest</h3>
<code>git pull origin main</code>
<p>Get latest changes from main branch</p>
</div>
<div class="card">
<h3>π View Status</h3>
<code>git status</code>
<p>Check working tree status</p>
</div>
</div>
</section>
<section>
<h2>npm / Yarn Quick Commands</h2>
<div class="card-grid">
<div class="card">
<h3>π¦ Install Dependencies</h3>
<code>npm install</code>
<p>Install packages from package.json</p>
</div>
<div class="card">
<h3>β Add Package</h3>
<code>npm install react-query</code>
<p>Add new package to project</p>
</div>
<div class="card">
<h3>π Run Script</h3>
<code>npm run dev</code>
<p>Run npm script from package.json</p>
</div>
<div class="card">
<h3>π§Ή Lint Code</h3>
<code>npm run lint</code>
<p>Run ESLint to check code quality</p>
</div>
<div class="card">
<h3>π
Format Code</h3>
<code>npm run format</code>
<p>Format code with Prettier</p>
</div>
<div class="card">
<h3>ποΈ Build Project</h3>
<code>npm run build</code>
<p>Build for production</p>
</div>
</div>
</section>
<section>
<h2>Docker Quick Commands</h2>
<div class="card-grid">
<div class="card">
<h3>π³ Start Containers</h3>
<code>docker-compose up -d</code>
<p>Start services in background</p>
</div>
<div class="card">
<h3>π Stop Containers</h3>
<code>docker-compose down</code>
<p>Stop and remove containers</p>
</div>
<div class="card">
<h3>π View Logs</h3>
<code>docker-compose logs -f app</code>
<p>View container logs (follow)</p>
</div>
<div class="card">
<h3>π§ Build Image</h3>
<code>docker build -t myapp:1.0 .</code>
<p>Build Docker image</p>
</div>
<div class="card">
<h3>π Run Container</h3>
<code>docker run -p 3000:3000 myapp:1.0</code>
<p>Run container with port mapping</p>
</div>
<div class="card">
<h3>π List Images</h3>
<code>docker images</code>
<p>View all local Docker images</p>
</div>
</div>
</section>
<section>
<h2>Useful Prompt Prefixes</h2>
<div class="card-grid">
<div class="card">
<h3>π Analyze</h3>
<code>"Analyze this code for..."</code>
<p>Review code for issues, patterns, or improvements</p>
</div>
<div class="card">
<h3>π οΈ Fix</h3>
<code>"Fix this bug: [error]"</code>
<p>Identify and resolve issues</p>
</div>
<div class="card">
<h3>π Explain</h3>
<code>"Explain how this code works..."</code>
<p>Get detailed explanation of code logic</p>
</div>
<div class="card">
<h3>π Create</h3>
<code>"Create a [component/function] that..."</code>
<p>Generate new code from scratch</p>
</div>
<div class="card">
<h3>β»οΈ Refactor</h3>
<code>"Refactor this code to..."</code>
<p>Improve code quality and structure</p>
</div>
<div class="card">
<h3>β
Test</h3>
<code>"Write tests for this function..."</code>
<p>Generate test cases and suites</p>
</div>
</div>
</section>
<section>
<h2>Effective Prompt Modifiers</h2>
<div class="card-grid">
<div class="card">
<h3>Step by Step</h3>
<code>"...step by step"</code>
<p>Get detailed explanations for each step</p>
</div>
<div class="card">
<h3>With Examples</h3>
<code>"...with examples"</code>
<p>Include practical examples in response</p>
</div>
<div class="card">
<h3>Using Pattern</h3>
<code>"...using [pattern/library]"</code>
<p>Follow specific patterns or use libraries</p>
</div>
<div class="card">
<h3>Include Tests</h3>
<code>"...including tests"</code>
<p>Generate tests along with code</p>
</div>
<div class="card">
<h3>With Comments</h3>
<code>"...with inline comments"</code>
<p>Add explanatory comments to code</p>
</div>
<div class="card">
<h3>For Beginners</h3>
<code>"...for someone learning [language]"</code>
<p>Explain like you're teaching</p>
</div>
</div>
</section>
<div class="nav-links">
<a href="3-best-practices.html">β Best Practices</a>
<a href="5-integrations.html">Integrations β</a>
</div>
<footer>
<p>Keep these cheat sheets handy for rapid development and quick reference.</p>
</footer>
</div>
</body>
</html>