-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-coding-best-practices.html
More file actions
788 lines (740 loc) · 41.7 KB
/
ai-coding-best-practices.html
File metadata and controls
788 lines (740 loc) · 41.7 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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Code with AI — Tool-Agnostic Best Practices</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; overflow:hidden; background:#1a1a2e; }
.slide { width:100vw; height:100vh; padding:80px; display:none; background:linear-gradient(135deg,#ffffff 0%,#f5f5f5 100%); position:relative; overflow:auto; }
.slide.active { display:flex; flex-direction:column; }
.slide-number { position: fixed; bottom:30px; right:40px; color:#666; font-size:16px; font-weight:500; }
h1 { color:#2c3e50; font-size:56px; margin-bottom:30px; font-weight:600; line-height:1.2; }
h2 { color:#0047BA; font-size:48px; margin-bottom:40px; font-weight:500; border-bottom:4px solid #0047BA; padding-bottom:15px; }
h3 { color:#2c3e50; font-size:32px; margin-bottom:25px; margin-top:35px; font-weight:500; }
.subtitle { color:#7f8c8d; font-size:32px; margin-bottom:20px; font-weight:300; }
.presenter { color:#34495e; font-size:22px; margin-top:20px; font-style:italic; line-height:1.6; }
ul { list-style:none; padding-left:0; flex-grow:1; }
li { color:#2c3e50; font-size:28px; margin-bottom:20px; padding-left:45px; position:relative; line-height:1.4; }
li:before { content:"▸"; position:absolute; left:0; color:#0047BA; font-weight:bold; font-size:32px; }
li ul { margin-top:15px; }
li ul li { font-size:24px; padding-left:35px; color:#555; margin-bottom:12px; }
li ul li:before { content:"•"; font-size:24px; color:#9b59b6; }
.code-block { background:#2c3e50; color:#ecf0f1; padding:25px; margin:30px 0; font-family:'Consolas','Monaco',monospace; font-size:20px; border-radius:8px; overflow-x:auto; box-shadow:0 4px 6px rgba(0,0,0,0.1); }
.highlight { background:#fff3cd; padding:4px 10px; border-radius:4px; font-weight:600; color:#856404; }
.emphasis { background:#0047BA; color:white; font-weight:700; padding:2px 8px; border-radius:4px; }
.warning { background:#fee; border-left:5px solid #dc3545; padding:20px; margin:30px 0; border-radius:4px; font-size:24px; color:#721c24; }
.success { background:#d4edda; border-left:5px solid #28a745; padding:20px; margin:30px 0; border-radius:4px; font-size:24px; color:#155724; }
.controls { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:rgba(0,0,0,0.8); padding:15px 30px; border-radius:30px; display:flex; align-items:center; gap:20px; z-index:1000; opacity:0; transition:opacity .4s ease-in-out; pointer-events:none; }
.controls.visible { opacity:1; pointer-events:auto; }
.controls:hover { opacity:1 !important; }
.controls-trigger { position:fixed; bottom:0; left:0; right:0; height:120px; z-index:999; }
.controls-trigger:hover ~ .controls { opacity:1; pointer-events:auto; }
button { background:#0047BA; color:white; border:none; padding:10px 20px; border-radius:20px; cursor:pointer; font-size:16px; transition:all .3s; }
button:hover { background:#5a67d8; transform:scale(1.05); }
button:disabled { background:#4a5568; cursor:not-allowed; transform:scale(1); }
.slide-counter { color:white; font-size:16px; font-weight:500; }
.title-slide { text-align:center; justify-content:center; align-items:center; background:linear-gradient(135deg,#0047BA 0%, #0047BA 100%); }
.title-slide h1 { font-size:72px; color:white; text-shadow:2px 2px 4px rgba(0,0,0,0.2); }
.title-slide .subtitle { color:#e0e0e0; font-size:36px; }
.title-slide .presenter { color:white; font-size:24px; margin-top:10px; }
.title-slide li { color:white; }
.two-column { display:grid; grid-template-columns:1fr 1fr; gap:50px; align-items:start; }
.compact li { font-size:24px; margin-bottom:12px; }
.compact li ul li { font-size:20px; margin-bottom:8px; }
code { background:#e0e0e0; padding:2px 8px; border-radius:3px; font-family:'Consolas','Monaco',monospace; font-size:.9em; }
.keyboard-hint { position:fixed; top:20px; right:20px; background:rgba(0,0,0,0.7); color:white; padding:10px 15px; border-radius:20px; font-size:14px; opacity:0; transition:opacity .3s; }
.keyboard-hint.visible { opacity:1; }
@media print {
.controls,.controls-trigger,.keyboard-hint { display:none; }
.slide { page-break-after:always; display:block !important; height:auto; padding:40px; }
}
@media (max-width:768px) {
.slide { padding:40px; }
h1 { font-size:36px; } h2 { font-size:32px; }
li { font-size:20px; } li ul li { font-size:18px; }
.two-column { grid-template-columns:1fr; }
}
</style>
</head>
<body>
<!-- Keyboard hint -->
<div class="keyboard-hint" id="keyboardHint">Use ← → arrow keys or Space to navigate</div>
<!-- Slide 1 -->
<div class="slide active title-slide">
<h1>Code with AI</h1>
<div class="subtitle">Tool-Agnostic Best Practices for Modern Development</div>
<div class="presenter">
<strong>Sergey Kurdin</strong><br/>
Senior Developer at Charles River Labs (Apollo SA project) • 30+ years building software<br/>
Built and shipped at Marriott.com, Ski.com, It.com, Amazon, NIH, startups<br/>
<a href="https://github.com/PasteBar/PasteBarApp" target="_blank" style="color:inherit; text-decoration:underline;">PasteBar App</a> Maintainer — Free Clipboard Manager for Mac & Windows (1.7k★)
</div>
<div style="margin-top:30px;">
<a href="https://kurdin.github.io/ai-coding-best-practices-for-modern-development/" target="_blank" style="display:inline-block; padding:10px 20px; background:white; color:#0047BA; border-radius:25px; text-decoration:none; font-weight:600; font-size:18px; box-shadow:0 2px 4px rgba(0,0,0,0.2);">
Presentation Link
</a>
<a href="https://github.com/kurdin/ai-coding-best-practices-for-modern-development" target="_blank" style="background:transparent; color:white; padding:10px 20px; font-size:18px; border:2px solid white; border-radius:25px; text-decoration:none; font-weight:600; box-shadow:0 2px 4px rgba(0,0,0,0.2); margin-left:15px;">
Git Repo
</a>
</div>
<div class="slide-number">1 / 29</div>
</div>
<!-- Slide 2: Agenda -->
<div class="slide">
<h2>Agenda</h2>
<ul style="cursor: pointer;">
<li onclick="currentSlide = 3; showSlide(3);"><strong>Foundation:</strong> Why AI coding now & mindset shift <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 3-6</span></li>
<li onclick="currentSlide = 7; showSlide(7);"><strong>Understanding AI:</strong> How LLMs work & context windows <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 7-12</span></li>
<li onclick="currentSlide = 13; showSlide(13);"><strong>Best Practices:</strong> Prompt patterns & planning-first approach <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 13-16</span></li>
<li onclick="currentSlide = 15; showSlide(15);"><strong>Git Workflow:</strong> Safe version control & incremental commits <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 15, 17</span></li>
<li onclick="currentSlide = 21; showSlide(21);"><strong>CLI-first Agents:</strong> Common commands & workflow (tool-agnostic) <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 21-23</span></li>
<li onclick="currentSlide = 18; showSlide(18);"><strong>Quality Control:</strong> Testing, reviews & catching bad patterns <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 18-19, 25</span></li>
<li onclick="currentSlide = 20; showSlide(20);"><strong>Limits & Safety:</strong> AI security guardrails <span style="color:#0047BA; float:right; font-size:20px;">→ Slide 20</span></li>
<li onclick="currentSlide = 26; showSlide(26);"><strong>Human Skills:</strong> What matters MORE with AI <span style="color:#0047BA; float:right; font-size:20px;">→ Slide 26</span></li>
<li onclick="currentSlide = 27; showSlide(27);"><strong>Key Takeaways:</strong> Start small, verify everything <span style="color:#0047BA; float:right; font-size:20px;">→ Slides 27-28</span></li>
</ul>
<div style="background:#f0f9ff; padding:15px; border-radius:8px; margin-top:30px; border:1px solid #3b82f6;">
<p style="margin:0; font-size:20px; color:#1e40af; text-align:center;">💡 <strong>Tip:</strong> Click any topic to jump directly to that section</p>
</div>
<div class="slide-number">2 / 29</div>
</div>
<!-- Slide 3: Short History -->
<div class="slide">
<h2>Evolution of AI-Assisted Coding</h2>
<ul>
<li><strong>Early Tools</strong>
<ul><li>Syntax highlighting → readability</li><li>Linting & type checking → fewer mistakes</li></ul>
</li>
<li><strong>AI Breakthrough</strong>
<ul><li>Natural-language Q&A</li><li>Inline autocomplete in IDEs</li></ul>
</li>
<li><strong>Modern Coding Agents</strong>
<ul>
<li>Repo-aware (understand structure & context)</li>
<li><span class="emphasis">Plan first</span>, then implementation</li>
<li>Plan → apply small step → test → iterate (reviewable diffs)</li>
</ul>
</li>
</ul>
<div class="slide-number">3 / 29</div>
</div>
<!-- Slide 4: Why now -->
<div class="slide">
<h2>Why AI for Developers — Now</h2>
<ul>
<li><span class="emphasis">Less typing, more steering</span></li>
<li>Fast refactors and unit tests; iterate on variants</li>
<li>Faster docs and code reviews</li>
<li>Learns and follows your repo’s patterns</li>
<li>Produces code aligned with project style</li>
</ul>
<div class="success">
✓ You guide, review, and accept<br/>✓ AI accelerates mechanics<br/>✓ You own design and code quality
</div>
<div style="background:#d4f4dd; padding:15px; border-radius:8px; margin-top:20px; border:1px solid #22c55e;">
<p style="margin:0; font-size:18px; color:#166534;"><strong>💡 Pro Tip:</strong> Generate and reuse <code>AGENTS.md</code> with repo-specific instructions.</p>
</div>
<div class="slide-number">4 / 29</div>
</div>
<!-- Slide 5: Landscape -->
<div class="slide">
<h2>Current Tooling Landscape</h2>
<ul>
<li><strong>Autocomplete copilots</strong> — inline suggestions</li>
<li><strong>Chat assistants</strong> — design, code, docs, Q&A</li>
<li><strong>CLI-first coding agents</strong> <span class="emphasis">Most Powerful</span>
<ul>
<li>Understand the repo</li><li>Plan → Review → Implement workflow</li><li>Direct file editing with reviewable changes</li>
</ul>
</li>
</ul>
<div class="success">✓ Focus on patterns, not brands — most agents support similar flows.</div>
<div class="slide-number">5 / 29</div>
</div>
<!-- Slide 6: Mindset -->
<div class="slide">
<h2>The Mindset Shift</h2>
<ul>
<li>Build <span class="emphasis">systems that solve problems</span></li>
<li>Shift from <strong>coder → architect</strong></li>
<li>AI suggests; you guide & control</li>
<li><strong>Your responsibilities:</strong>
<ul><li>Define the problem clearly</li><li>Curate context</li><li>Review changes thoroughly</li><li>Enforce quality gates</li></ul>
</li>
<li>Result: <span class="highlight">Fewer keystrokes, more impact</span></li>
</ul>
<div class="slide-number">6 / 29</div>
</div>
<!-- Slide 7: What is AI -->
<div class="slide">
<h2>What is AI? (LLMs in 2 Minutes)</h2>
<ul>
<li><span class="emphasis">LLMs</span> are trained on text/code patterns</li>
<li>They are <span class="highlight">not databases</span> or compilers</li>
<li>They <span class="emphasis">predict the next token</span></li>
<li><strong>Strengths:</strong> recall, mimicry, scaffolding, breadth</li>
<li><strong>Weaknesses:</strong> hallucinations, no runtime awareness</li>
</ul>
<div class="warning">⚠️ Think “autocomplete on steroids,” not a truth engine.</div>
<div class="slide-number">7 / 29</div>
</div>
<!-- Slide 8: How LLMs code -->
<div class="slide">
<h2>How LLMs Generate Code</h2>
<ul>
<li><span class="emphasis">Tokenization → Probabilities → Decoding</span></li>
<li>Output quality depends on: prompt clarity, curated context, explicit constraints</li>
<li><span class="highlight">Temperature</span> controls creativity vs. safety</li>
<li>Always validate with build/run/tests</li>
</ul>
<div class="success">✓ Ask for plans first → apply small steps → compile → test.</div>
<div class="slide-number">8 / 29</div>
</div>
<!-- Slide 9: Context windows -->
<div class="slide">
<h2>Understanding Models & Context Windows</h2>
<ul>
<li><strong>Limits vary</strong> by provider; effective window < advertised</li>
<li>Specialization: general vs. code-tuned models</li>
<li>Choose model by task: coding vs. explaining</li>
</ul>
<div class="success">✓ Code models: strong patterns • General models: strong explanations.</div>
<div class="slide-number">9 / 29</div>
</div>
<!-- Slide 10: Why context matters -->
<div class="slide">
<h2>Why Context Matters</h2>
<ul>
<li>Models only see a <span class="emphasis">limited window</span></li>
<li>Too much context → <span class="highlight">truncation</span></li>
<li>Provide minimal relevant files + explicit acceptance criteria</li>
<li><strong>Priority:</strong> 1) error & stack 2) target files & imports 3) types/interfaces 4) tests 5) project config</li>
</ul>
<div class="success">✓ Mantra: Curate → Confirm → Constrain → Verify</div>
<div class="slide-number">10 / 29</div>
</div>
<!-- Slide 11: Confidence calibration -->
<div class="slide">
<h2>The Confidence Calibration Problem</h2>
<ul>
<li>LLMs are <span class="highlight">confident</span> even when wrong</li>
<li>Red flags: invented APIs, deprecated methods, odd features</li>
<li>Mitigate: cross-check docs, be strict with new libs, track recurring hallucinations</li>
</ul>
<div class="warning">⚠️ Example: non-existent <code>useState2()</code>, <code>Array.prototype.contains()</code></div>
<div class="slide-number">11 / 29</div>
</div>
<!-- Slide 12: Mental model -->
<div class="slide">
<h2>Mental Model: Architecting with AI</h2>
<ul>
<li>Decompose → write acceptance criteria</li>
<li>Constrain scope → request <span class="emphasis">small changes</span></li>
<li>Iterate quickly → run, test, review each step</li>
<li>Treat AI like a <strong>junior dev</strong>: plan first, ask “why,” request alternatives</li>
</ul>
<div class="warning">⚠️ Review diffs visually; never rely only on passing output.</div>
<div class="slide-number">12 / 29</div>
</div>
<!-- Slide 13: Best practices -->
<div class="slide">
<h2>General Best Practices</h2>
<div class="two-column">
<div>
<h3>Before Code</h3>
<ul>
<li>Clarify intent & constraints</li>
<li>Provide only relevant context</li>
</ul>
<h3>During Code</h3>
<ul>
<li>Plan → review → implement</li>
<li>Request small diffs</li>
<li>Compile early; iterate</li>
</ul>
</div>
<div>
<h3>After Code</h3>
<ul>
<li>Review/ask AI to explain its diff</li>
<li>Lint, typecheck, build, test</li>
<li>Manual tests + unit tests</li>
<li>Security & performance checks</li>
</ul>
</div>
</div>
<div class="success">✓ Workflow: Plan → Implement → Test → Review</div>
<div class="slide-number">13 / 29</div>
</div>
<!-- Slide 14: Prompt patterns -->
<div class="slide">
<h2>Prompt Patterns That Work (CLI Agents)</h2>
<ul>
<li><strong>Structure:</strong> Role • Context • Task • Constraints • Verification</li>
<li>Be explicit about files/scope, runtime/versions, safety expectations</li>
<li>Prefer plan → apply; keep steps small & reviewable</li>
<li>Keep outputs focused (commands, concise summaries)</li>
</ul>
<div class="code-block">
<strong>Example Prompt (Refactor, Diff-Applied):</strong>
Role: Senior TypeScript engineer.
Context: Node 20, Jest; repo uses src/ and test/.
Target: src/auth/token.ts#getUserToken duplicates retry/backoff logic.
Task: Extract retry/backoff into src/utils/retry.ts and reuse it in getUserToken
without changing external behavior.
Constraints:
• Keep public signatures stable
• Do not change unrelated modules
• Update test/auth/token.spec.ts to cover 429/503 with exponential backoff (max 3 attempts)
Verification:
• build passes (Node 20)
• npm run typecheck
• npm test -- test/auth/token.spec.ts
Out of scope:
• Do not modify unrelated modules or configuration files
</div>
<div class="slide-number">14 / 29</div>
</div>
<!-- Slide 15: Version control pattern -->
<div class="slide compact">
<h2>Version Control & AI Patterns</h2>
<h3>The Incremental Staging Pattern</h3>
<ul>
<li>1) New branch: <code>git switch -c ai/<feature></code></li>
<li>2) Clean working dir: <code>git status</code></li>
<li>3) Ask AI for a plan → approve small, focused changes</li>
<li>4) Stage incrementally: <code>git add -p</code> (review hunks)</li>
<li>5) Test locally (lint, typecheck, compile, unit tests)</li>
<li>6) Good → commit: <code>git commit -m "[AI]: Extract retry logic"</code></li>
<li>7) Bad → <code>git restore</code>/<code>git revert</code> and retry</li>
<li>8) Repeat small steps</li>
</ul>
<div class="code-block">
git switch -c ai/refactor-retry
git add -p # Review hunks interactively
git commit -m "[AI]: Extract retry logic"
git restore --staged . # Unstage if needed (avoid reset --hard)
</div>
<div class="slide-number">15 / 29</div>
</div>
<!-- Slide 16: Planning-first -->
<div class="slide">
<h2>Planning-First for Big Features</h2>
<div style="background:#e8f4f8; padding:12px; border-radius:8px; margin-bottom:20px;">
<p style="margin:0; font-size:20px; color:#2c3e50; text-align:center;"><strong>Plan upfront → Break into manageable subtasks → Reduce risk</strong></p>
</div>
<div style="background:#f0f9ff; border-left:5px solid #3b82f6; padding:20px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#3b82f6; font-size:28px;">Step 1: Describe the Feature</h3>
<ul style="margin:10px 0; padding-left:25px;"><li>Current state, requirements, constraints, screenshots/wireframes</li></ul>
<div style="background:#fff; padding:10px; border-radius:4px; margin-top:10px;"><code style="font-size:16px; color:#555;">"As a product architect, summarize this feature spec: [details]"</code></div>
</div>
<div style="background:#f0fdf4; border-left:5px solid #10b981; padding:20px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#10b981; font-size:28px;">Step 2: Request Implementation Plan</h3>
<ul style="margin:0; padding-left:25px;"><li>Break into subtasks (<100 LOC each)</li></ul>
<div style="background:#fff; padding:10px; border-radius:4px; margin-top:10px;"><code style="font-size:16px; color:#555;">"Create plan: subtasks, dependencies, tests; save as [feature]-plan.md"</code></div>
</div>
<div style="background:#fef3c7; border-left:5px solid #f59e0b; padding:20px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#f59e0b; font-size:28px;">Step 3: Review & Approve</h3>
<ul style="margin:10px 0; padding-left:25px;"><li>Approve plan or request changes; then implement subtask 1</li></ul>
<div style="background:#fff; padding:10px; border-radius:4px; margin-top:10px;"><code style="font-size:16px; color:#555;">"Start implementation of subtask 1 from [feature]-plan.md"</code></div>
</div>
<div class="slide-number">16 / 29</div>
</div>
<!-- Slide 17: Essential git -->
<div class="slide compact">
<h2>Essential Git Commands for AI Work</h2>
<ul>
<li><code>git switch -c ai/<feature></code> — Dedicated branch</li>
<li><code>git add -p</code> — Stage hunks</li>
<li><code>git restore --staged .</code> — Unstage to retry</li>
<li><code>git diff --staged</code> — Verify staged changes</li>
<li><code>git stash</code> — Quick save when off-track</li>
<li><code>git commit -m "[AI] checkpoint: desc"</code></li>
<li><code>git revert HEAD</code> — Safe undo</li>
<li><code>git log --grep="[AI]"</code> — Track AI commits</li>
<li><code>git rebase -i</code> — Clean before PR</li>
<li>pre-commit hooks — auto-lint/format</li>
</ul>
<div style="background:#fff3cd; border-left:5px solid #f39c12; padding:20px; margin:30px 0; border-radius:4px; font-size:24px; color:#856404;">
⚠️ Avoid <code>reset --hard</code>
</div>
<div class="slide-number">17 / 29</div>
</div>
<!-- Slide 18: Testing -->
<div class="slide">
<h2>Testing AI-Generated Code</h2>
<div style="background:#e8f4f8; padding:12px; border-radius:8px; margin-bottom:20px;">
<p style="margin:0; font-size:22px; color:#2c3e50; text-align:center;"><strong>AI code needs extra testing — it makes creative mistakes</strong></p>
</div>
<ul>
<li><strong>Property-based testing:</strong> define invariants; auto-generate inputs</li>
<li><strong>Mutation testing:</strong> ensure tests catch injected bugs</li>
<li><strong>Weakness detection:</strong> ask AI to break its own code (edge cases)</li>
<li><strong>Browser testing via tools/APIs:</strong> scripted navigation & assertions</li>
<li><span class="emphasis">Golden Rule:</span> <span class="highlight">AI code → Human tests | Human reviews → AI tests</span></li>
</ul>
<div class="slide-number">18 / 29</div>
</div>
<!-- Slide 19: Performance -->
<div class="slide">
<h2>Performance Awareness & AI-Assisted Reviews</h2>
<div style="background:#e8f4f8; padding:12px; border-radius:8px; margin-bottom:20px;">
<p style="margin:0; font-size:22px; color:#2c3e50; text-align:center;"><strong>AI code is often correct but not optimal — profile and review</strong></p>
</div>
<div class="two-column">
<div>
<h3>Perf Issues to Watch</h3>
<ul style="font-size:22px;">
<li>N+1 DB queries</li><li>Nested loops</li><li>Blocking I/O</li><li>Memory leaks</li>
</ul>
</div>
<div>
<h3>AI Double-Loop Reviews</h3>
<ul style="font-size:22px;">
<li>Risk analysis (security/perf)</li><li>Missing test cases</li><li>Draft PR descriptions</li><li>Edge case reviews</li>
</ul>
<div style="margin-top:15px;"><code style="font-size:18px;">"Find 3 issues in this diff and suggest fixes"</code></div>
</div>
</div>
<div class="warning" style="margin-top:20px;">⚠️ Never skip human review—assume AI is wrong until tests & profiling say otherwise</div>
<div class="slide-number">19 / 29</div>
</div>
<!-- Slide 20: Safety -->
<div class="slide">
<h2>Data & Safety Guardrails</h2>
<div style="background:#e8f4f8; padding:12px; border-radius:8px; margin-bottom:20px;">
<p style="margin:0; font-size:20px; color:#2c3e50; text-align:center;"><strong>Protect customer data, secrets, and IP</strong></p>
</div>
<ul>
<li><strong>Never paste secrets</strong> — use placeholders or env vars; configure redaction</li>
<li><strong>Mask customer data</strong> — use synthetic examples</li>
<li><strong>Tag AI commits</strong> — prefix <code>[AI]</code></li>
<li><strong>Review licenses</strong> for generated code/deps</li>
<li><strong>Enterprise/local models</strong> for private repos</li>
</ul>
<div class="slide-number">20 / 29</div>
</div>
<!-- Slide 21: CLI-first (why) -->
<div class="slide">
<h2>CLI-First AI Workflow (Tool-Agnostic)</h2>
<div style="background:#e8f4f8; padding:12px; border-radius:8px; margin-bottom:15px;">
<p style="margin:0; font-size:20px; color:#2c3e50; text-align:center;"><strong>Automation, consistency, CI/CD-friendly</strong></p>
</div>
<div class="two-column">
<div>
<h3>Why CLI?</h3>
<ul style="font-size:20px;">
<li><strong>Scriptable:</strong> wrap prompts in bash/python</li>
<li><strong>Portable:</strong> terminals, servers, remote</li>
<li><strong>Standardize:</strong> share configs & aliases</li>
</ul>
</div>
<div>
<h3>Common Agent Capabilities</h3>
<ul style="font-size:20px;">
<li>Plan / Review / Diff / Apply</li>
<li>Mention files or folders</li>
<li>Search or fuzzy-find files</li>
<li>Resume sessions, compact/summarize</li>
</ul>
</div>
</div>
<div class="success" style="margin-top:20px;">✓ Flow: Plan → Diff preview → Apply small step → Test → Commit</div>
<div class="slide-number">21 / 29</div>
</div>
<!-- Slide 22: Common commands (generic) -->
<div class="slide">
<h2>Common CLI Agent Commands (Generic)</h2>
<div class="two-column">
<div>
<h3>Session & Config</h3>
<ul style="font-size:20px;">
<li><code>/init</code> — generate <code>AGENTS.md</code> / set context</li>
<li><code>/status</code> — show settings</li>
<li><code>/model</code> — pick model/effort level</li>
<li><code>/new</code> or <code>/resume</code> — session control</li>
</ul>
</div>
<div>
<h3>Workflow</h3>
<ul style="font-size:20px;">
<li><code>/plan</code> — propose steps</li>
<li><code>/diff</code> — preview changes</li>
<li><code>/apply</code> — apply edits</li>
<li><code>/review</code> — critique changes</li>
<li><code>/mention</code> — add files to context</li>
<li><code>@</code> — fuzzy file search</li>
</ul>
</div>
</div>
<div style="background:#e8f4f8; padding:20px; border-radius:8px; margin-top:25px; border:1px solid #0047BA;">
<h3 style="margin:0 0 10px; color:#0047BA; font-size:24px;">About AGENTS.md Files</h3>
<ul style="font-size:20px; margin-bottom:15px;">
<li>CLI agents automatically detect and use <code>AGENTS.md</code> files for context</li>
<li>Use <strong>multiple AGENTS.md files</strong> for different repo areas:
<ul style="font-size:18px; margin-top:8px;">
<li><code>backend/AGENTS.md</code> — API-specific patterns & rules</li>
<li><code>frontend/AGENTS.md</code> — UI conventions & components</li>
<li><code>libs/AGENTS.md</code> — Component library guidelines</li>
</ul>
</li>
<li>Each file provides <span class="emphasis">domain-specific context</span> to guide AI behavior</li>
</ul>
<div style="background:#fff; padding:12px; border-radius:6px;">
<strong style="color:#0047BA;">📚 CLI-Specific References:</strong>
<a href="Claude%20Code%20CLI%20Cheatsheet.md" style="color:#0047BA; margin:0 10px;">Claude Code Cheatsheet</a> •
<a href="OpenAI%20Codex%20CLI%20Cheatsheet.md" style="color:#0047BA; margin:0 10px;">OpenAI Codex Cheatsheet</a>
</div>
</div>
<div class="slide-number">22 / 29</div>
</div>
<!-- Slide 23: CLI workflow example (generic) -->
<div class="slide">
<h2>CLI Agent Workflow Example</h2>
<div style="background:#f8f9fa; border-left:4px solid #0047BA; padding:15px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#0047BA;">1) Start & Create Plan</h3>
<code style="font-size:20px; display:block;">$ claude | codex</span></code>
<code style="font-size:20px; display:block; margin-top:5px;">→ Plan retry logic with exponential backoff; save to retry-plan.md</code>
</div>
<div style="background:#f8f9fa; border-left:4px solid #0047BA; padding:15px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#0047BA;">2) Review Plan</h3>
<code style="font-size:20px; display:block;">$ cat retry-plan.md</code>
<span style="color:#7f8c8d; font-style:italic;">← Approve before applying</span>
</div>
<div style="background:#f8f9fa; border-left:4px solid #0047BA; padding:15px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#0047BA;">3) Execute Approved Step</h3>
<code style="font-size:20px; display:block;">claude | codex</code>
<code style="font-size:20px; display:block; margin-top:5px;">→ Implement step 1 from retry-plan.md; run tests after changes</code>
</div>
<div style="background:#f8f9fa; border-left:4px solid #0047BA; padding:15px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#0047BA;">4) Stage & Commit</h3>
<code style="font-size:20px; display:block;">$ git add -p</code>
<code style="font-size:20px; display:block; margin-top:5px;">$ git commit -m "[AI]: Implement retry logic step 1"</code>
</div>
<div style="background:#f8f9fa; border-left:4px solid #0047BA; padding:15px; margin:15px 0; border-radius:4px;">
<h3 style="margin:0 0 10px; color:#0047BA;">5) Test & Push</h3>
<code style="font-size:20px; display:block;">$ npm test</code>
<code style="font-size:20px; display:block; margin-top:5px;">$ git push -u origin ai/retry-logic</code>
<span style="color:#7f8c8d; font-style:italic;">→ Open PR for review</span>
</div>
<div class="slide-number">23 / 29</div>
</div>
<!-- Slide 24: Context switching -->
<div class="slide">
<h2>The Context Switching Cost</h2>
<ul>
<li><strong>Batch similar tasks</strong> (tests → refactors)</li>
<li><strong>Save successful prompts</strong> in team KB</li>
<li><strong>Build context once</strong> and reuse</li>
<li><strong>When stuck:</strong> clear context, simplify, provide a working example</li>
<li><strong>15-minute rule:</strong> change approach or restart</li>
</ul>
<div style="background:#d4f4dd; padding:20px; border-radius:8px; margin:20px 0; border:1px solid #22c55e;">
<p style="margin:0; font-size:22px; color:#166534; font-weight:500;">💡 Provide a minimal snippet instead of the whole file for specific edits</p>
</div>
<div class="warning">⚠️ If the session gets long/noisy, summarize or start fresh</div>
<div class="slide-number">24 / 29</div>
</div>
<!-- Slide 25: Code smells -->
<div class="slide">
<h2>Bad Patterns in AI Code</h2>
<ul>
<li><strong>Generic names:</strong> <code>data</code>, <code>item</code>, <code>result</code></li>
<li><strong>Structure issues:</strong> deep nesting, clever one-liners, unnecessary indirection</li>
<li><strong>Missing safeguards:</strong> no error boundaries, hardcoded values, swallowed errors</li>
<li><strong>Debug artifacts:</strong> stray logs, redundant imports, overused type assertions</li>
</ul>
<div class="warning">⚠️ Catch & fix these before opening a PR</div>
<div class="slide-number">25 / 29</div>
</div>
<!-- Slide 26: Human skills -->
<div class="slide">
<h2>Human Skills That Matter More</h2>
<ul>
<li><span class="emphasis">System design</span> (AI can’t architect)</li>
<li><span class="emphasis">Code review</span> (3× more important)</li>
<li><span class="emphasis">Specification writing</span> is the new programming</li>
<li><span class="emphasis">Domain expertise</span> differentiates you</li>
<li><span class="emphasis">Debugging intuition</span></li>
</ul>
<div class="warning">⚠️ AI amplifies both good and bad practices</div>
<div class="slide-number">26 / 29</div>
</div>
<!-- Slide 27: Key takeaways -->
<div class="slide">
<h2>Key Takeaways</h2>
<ul>
<li>AI is a <span class="emphasis">tool, not a replacement</span></li>
<li>Small, verifiable changes win</li>
<li>Context is everything</li>
<li>Don’t trust — verify</li>
<li>Your skills become <span class="emphasis">more valuable</span></li>
<li>Plan, guide, review — you stay in control</li>
<li>Start small. Ship safely. Measure impact.</li>
</ul>
<div class="slide-number">27 / 29</div>
</div>
<!-- Slide 28: Practical workflow -->
<div class="slide">
<h2>Practical AI Workflow</h2>
<div class="two-column" style="gap:30px;">
<div style="flex:1;">
<h3 style="margin-bottom:15px; font-size:26px;">Effective Prompts</h3>
<div style="background:#f8f9fa; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
<div style="margin-bottom:15px;">
<strong style="font-size:20px;">Planning:</strong>
<div style="background:#fff; padding:8px; border-radius:4px; margin-top:5px; font-size:18px; border:1px solid #e2e8f0;">"Create plan for [feature]. Save to [feature].md for review"</div>
</div>
<div style="margin-bottom:15px;">
<strong style="font-size:20px;">Bugfix:</strong>
<div style="background:#fff; padding:8px; border-radius:4px; margin-top:5px; font-size:18px; border:1px solid #e2e8f0;">"Fix [bug] in [file]. Include test."</div>
</div>
<div style="margin-bottom:15px;">
<strong style="font-size:20px;">Refactor:</strong>
<div style="background:#fff; padding:8px; border-radius:4px; margin-top:5px; font-size:18px; border:1px solid #e2e8f0;">"Extract [logic] to [target dir]."</div>
</div>
<div style="margin-bottom:15px;">
<strong style="font-size:20px;">Testing:</strong>
<div style="background:#fff; padding:8px; border-radius:4px; margin-top:5px; font-size:18px; border:1px solid #e2e8f0;">"Add tests for [file] edge cases."</div>
</div>
<div>
<strong style="font-size:20px;">Docs:</strong>
<div style="background:#fff; padding:8px; border-radius:4px; margin-top:5px; font-size:18px; border:1px solid #e2e8f0;">"Document [API] with examples."</div>
</div>
</div>
</div>
<div style="flex:1;">
<h3 style="margin-bottom:15px; font-size:26px;">Git Safety Flow</h3>
<div style="background:#f8f9fa; padding:20px; border-radius:12px; border:1px solid #e2e8f0;">
<ol style="margin:0; padding-left:20px; font-size:19px; line-height:1.8;">
<li>Start with <strong>clean dir</strong></li>
<li>Have AI make <strong>one small change</strong></li>
<li><code style="background:#fff; padding:2px 6px; border-radius:3px; border:1px solid #e2e8f0;">git add -p</code> → review</li>
<li><strong>Test locally</strong> first</li>
<li>Pass? → <strong>commit</strong></li>
<li>Fail? → <code style="background:#fff; padding:2px 6px; border-radius:3px; border:1px solid #e2e8f0;">git restore --staged</code></li>
<li><strong>Iterate</strong> with a better prompt</li>
</ol>
<div style="background:#fef3c7; padding:15px; border-radius:8px; margin-top:15px; border:1px solid #fbbf24;">
<p style="margin:0; font-size:20px; color:#92400e; text-align:center; font-weight:600;"><strong>Golden Rule:</strong> Smaller changes = Easier rollbacks</p>
</div>
</div>
</div>
</div>
<div class="slide-number">28 / 29</div>
</div>
<!-- Slide 29: Thank you + resources -->
<div class="slide title-slide">
<h1>Thank You!</h1>
<div class="subtitle">AI Coding Best Practices & Patterns — Tool-Agnostic</div>
<div class="presenter">
<strong>Sergey Kurdin</strong><br/>
CRL: sergey.kurdin@crl.com<br/><br/>
LinkedIn: <a href="https://www.linkedin.com/in/kurdin/" target="_blank" style="color:white; text-decoration:underline;">linkedin.com/in/kurdin</a> |
GitHub: <a href="https://github.com/sergeykurdin" target="_blank" style="color:white; text-decoration:underline;">@sergeykurdin</a><br/>
Project: <a href="https://github.com/PasteBar/PasteBarApp" target="_blank" style="color:white; text-decoration:underline;">PasteBar</a> — Free Clipboard Manager for Mac & Windows<br/><br/>
<span style="font-weight:600;">Resources:</span>
<a href="OpenAI%20Codex%20CLI%20Cheatsheet.md" target="_blank" style="color:white; text-decoration:underline;">OpenAI Codex CLI Cheatsheet</a> |
<a href="Claude%20Code%20CLI%20Cheatsheet.md" target="_blank" style="color:white; text-decoration:underline;">Claude Code CLI Cheatsheet</a>
</div>
<div style="margin-top:30px;">
<a href="https://kurdin.github.io/ai-coding-best-practices-for-modern-development/" target="_blank" style="display:inline-block; padding:10px 20px; background:white; color:#0047BA; border-radius:25px; text-decoration:none; font-weight:600; font-size:18px; box-shadow:0 2px 4px rgba(0,0,0,0.2); margin-right:15px;">
Presentation Link
</a>
<a href="https://github.com/kurdin/ai-coding-best-practices-for-modern-development" target="_blank" style="display:inline-block; padding:10px 20px; background:white; color:#0047BA; border-radius:25px; text-decoration:none; font-weight:600; font-size:18px; box-shadow:0 2px 4px rgba(0,0,0,0.2); margin-right:15px;">
Git Repo
</a>
<button onclick="currentSlide = 1; showSlide(1);" style="background:transparent; color:white; padding:10px 20px; font-size:18px; border:2px solid white; border-radius:25px;">↻ Start Over</button>
</div>
<div class="slide-number">29 / 29</div>
</div>
<!-- Controls -->
<div class="controls-trigger"></div>
<div class="controls">
<button id="prevBtn" onclick="changeSlide(-1)">← Previous</button>
<span class="slide-counter"><span id="currentSlide">1</span> / <span id="totalSlides">29</span></span>
<button id="nextBtn" onclick="changeSlide(1)">Next →</button>
</div>
<script>
let currentSlide = 1;
const totalSlides = 29;
let controlsTimeout;
let mouseTimeout;
function updateURL() { window.location.hash = `slide-${currentSlide}`; }
function loadSlideFromURL() {
const hash = window.location.hash;
if (hash) {
const slideNum = parseInt(hash.replace('#slide-',''));
if (slideNum && slideNum >= 1 && slideNum <= totalSlides) { currentSlide = slideNum; return true; }
}
return false;
}
function showSlide(n) {
const slides = document.getElementsByClassName('slide');
if (n > totalSlides) currentSlide = 1;
if (n < 1) currentSlide = totalSlides;
for (let i=0; i<slides.length; i++) slides[i].classList.remove('active');
slides[currentSlide - 1].classList.add('active');
document.getElementById('currentSlide').textContent = currentSlide;
document.getElementById('prevBtn').disabled = currentSlide === 1;
document.getElementById('nextBtn').disabled = currentSlide === totalSlides;
updateURL();
}
function changeSlide(n) { currentSlide += n; showSlide(currentSlide); showControlsTemporarily(); }
function showControlsTemporarily() {
const controls = document.querySelector('.controls');
controls.classList.add('visible');
if (controlsTimeout) clearTimeout(controlsTimeout);
controlsTimeout = setTimeout(() => { controls.classList.remove('visible'); }, 2000);
}
document.addEventListener('keydown', function(e) {
if (e.key === 'ArrowLeft') changeSlide(-1);
if (e.key === 'ArrowRight' || e.key === ' ') { e.preventDefault(); changeSlide(1); }
if (e.key === 'Home') { currentSlide = 1; showSlide(1); showControlsTemporarily(); }
if (e.key === 'End') { currentSlide = totalSlides; showSlide(totalSlides); showControlsTemporarily(); }
const hint = document.getElementById('keyboardHint');
hint.classList.add('visible'); setTimeout(() => hint.classList.remove('visible'), 2000);
});
document.addEventListener('mousemove', function(e) {
const controls = document.querySelector('.controls');
if (e.clientY > window.innerHeight - 150) {
controls.classList.add('visible');
if (mouseTimeout) clearTimeout(mouseTimeout);
} else {
if (mouseTimeout) clearTimeout(mouseTimeout);
mouseTimeout = setTimeout(() => {
if (!controls.matches(':hover')) controls.classList.remove('visible');
}, 1500);
}
});
document.querySelector('.controls').addEventListener('mouseenter', function() {
if (mouseTimeout) clearTimeout(mouseTimeout);
});
document.querySelector('.controls').addEventListener('mouseleave', function() {
const controls = this;
mouseTimeout = setTimeout(() => { controls.classList.remove('visible'); }, 500);
});
// Touch support
let touchStartX = 0, touchEndX = 0;
document.addEventListener('touchstart', function(e){ touchStartX = e.changedTouches[0].screenX; showControlsTemporarily(); });
document.addEventListener('touchend', function(e){ touchEndX = e.changedTouches[0].screenX; handleSwipe(); });
function handleSwipe(){ if (touchEndX < touchStartX - 50) changeSlide(1); if (touchEndX > touchStartX + 50) changeSlide(-1); }
// Init
if (!loadSlideFromURL()) currentSlide = 1;
showSlide(currentSlide);
window.addEventListener('hashchange', function(){ if (loadSlideFromURL()) showSlide(currentSlide); });
setTimeout(() => {
const controls = document.querySelector('.controls');
controls.classList.add('visible');
setTimeout(() => { controls.classList.remove('visible'); }, 3000);
}, 500);
setTimeout(() => {
const hint = document.getElementById('keyboardHint');
hint.classList.add('visible');
setTimeout(() => hint.classList.remove('visible'), 3000);
}, 1000);
</script>
</body>
</html>