Use ← → arrow keys or Space to navigate

Code with AI

Tool-Agnostic Best Practices for Modern Development
Sergey Kurdin
Senior Developer at Charles River Labs (Apollo SA project) • 30+ years building software
Built and shipped at Marriott.com, Ski.com, It.com, Amazon, NIH, startups
PasteBar App Maintainer — Free Clipboard Manager for Mac & Windows (1.7k★)
Presentation Link Git Repo
1 / 29

Agenda

💡 Tip: Click any topic to jump directly to that section

2 / 29

Evolution of AI-Assisted Coding

3 / 29

Why AI for Developers — Now

✓ You guide, review, and accept
✓ AI accelerates mechanics
✓ You own design and code quality

💡 Pro Tip: Generate and reuse AGENTS.md with repo-specific instructions.

4 / 29

Current Tooling Landscape

✓ Focus on patterns, not brands — most agents support similar flows.
5 / 29

The Mindset Shift

6 / 29

What is AI? (LLMs in 2 Minutes)

⚠️ Think “autocomplete on steroids,” not a truth engine.
7 / 29

How LLMs Generate Code

✓ Ask for plans first → apply small steps → compile → test.
8 / 29

Understanding Models & Context Windows

✓ Code models: strong patterns • General models: strong explanations.
9 / 29

Why Context Matters

✓ Mantra: Curate → Confirm → Constrain → Verify
10 / 29

The Confidence Calibration Problem

⚠️ Example: non-existent useState2(), Array.prototype.contains()
11 / 29

Mental Model: Architecting with AI

⚠️ Review diffs visually; never rely only on passing output.
12 / 29

General Best Practices

Before Code

  • Clarify intent & constraints
  • Provide only relevant context

During Code

  • Plan → review → implement
  • Request small diffs
  • Compile early; iterate

After Code

  • Review/ask AI to explain its diff
  • Lint, typecheck, build, test
  • Manual tests + unit tests
  • Security & performance checks
✓ Workflow: Plan → Implement → Test → Review
13 / 29

Prompt Patterns That Work (CLI Agents)

Example Prompt (Refactor, Diff-Applied): 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
14 / 29

Version Control & AI Patterns

The Incremental Staging Pattern

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)
15 / 29

Planning-First for Big Features

Plan upfront → Break into manageable subtasks → Reduce risk

Step 1: Describe the Feature

"As a product architect, summarize this feature spec: [details]"

Step 2: Request Implementation Plan

"Create plan: subtasks, dependencies, tests; save as [feature]-plan.md"

Step 3: Review & Approve

"Start implementation of subtask 1 from [feature]-plan.md"
16 / 29

Essential Git Commands for AI Work

⚠️ Avoid reset --hard
17 / 29

Testing AI-Generated Code

AI code needs extra testing — it makes creative mistakes

18 / 29

Performance Awareness & AI-Assisted Reviews

AI code is often correct but not optimal — profile and review

Perf Issues to Watch

  • N+1 DB queries
  • Nested loops
  • Blocking I/O
  • Memory leaks

AI Double-Loop Reviews

  • Risk analysis (security/perf)
  • Missing test cases
  • Draft PR descriptions
  • Edge case reviews
"Find 3 issues in this diff and suggest fixes"
⚠️ Never skip human review—assume AI is wrong until tests & profiling say otherwise
19 / 29

Data & Safety Guardrails

Protect customer data, secrets, and IP

20 / 29

CLI-First AI Workflow (Tool-Agnostic)

Automation, consistency, CI/CD-friendly

Why CLI?

  • Scriptable: wrap prompts in bash/python
  • Portable: terminals, servers, remote
  • Standardize: share configs & aliases

Common Agent Capabilities

  • Plan / Review / Diff / Apply
  • Mention files or folders
  • Search or fuzzy-find files
  • Resume sessions, compact/summarize
✓ Flow: Plan → Diff preview → Apply small step → Test → Commit
21 / 29

Common CLI Agent Commands (Generic)

Session & Config

  • /init — generate AGENTS.md / set context
  • /status — show settings
  • /model — pick model/effort level
  • /new or /resume — session control

Workflow

  • /plan — propose steps
  • /diff — preview changes
  • /apply — apply edits
  • /review — critique changes
  • /mention — add files to context
  • @ — fuzzy file search

About AGENTS.md Files

📚 CLI-Specific References: Claude Code CheatsheetOpenAI Codex Cheatsheet
22 / 29

CLI Agent Workflow Example

1) Start & Create Plan

$ claude | codex → Plan retry logic with exponential backoff; save to retry-plan.md

2) Review Plan

$ cat retry-plan.md ← Approve before applying

3) Execute Approved Step

claude | codex → Implement step 1 from retry-plan.md; run tests after changes

4) Stage & Commit

$ git add -p $ git commit -m "[AI]: Implement retry logic step 1"

5) Test & Push

$ npm test $ git push -u origin ai/retry-logic → Open PR for review
23 / 29

The Context Switching Cost

💡 Provide a minimal snippet instead of the whole file for specific edits

⚠️ If the session gets long/noisy, summarize or start fresh
24 / 29

Bad Patterns in AI Code

⚠️ Catch & fix these before opening a PR
25 / 29

Human Skills That Matter More

⚠️ AI amplifies both good and bad practices
26 / 29

Key Takeaways

27 / 29

Practical AI Workflow

Effective Prompts

Planning:
"Create plan for [feature]. Save to [feature].md for review"
Bugfix:
"Fix [bug] in [file]. Include test."
Refactor:
"Extract [logic] to [target dir]."
Testing:
"Add tests for [file] edge cases."
Docs:
"Document [API] with examples."

Git Safety Flow

  1. Start with clean dir
  2. Have AI make one small change
  3. git add -p → review
  4. Test locally first
  5. Pass? → commit
  6. Fail? → git restore --staged
  7. Iterate with a better prompt

Golden Rule: Smaller changes = Easier rollbacks

28 / 29

Thank You!

AI Coding Best Practices & Patterns — Tool-Agnostic
Sergey Kurdin
CRL: sergey.kurdin@crl.com

LinkedIn: linkedin.com/in/kurdin | GitHub: @sergeykurdin
Project: PasteBar — Free Clipboard Manager for Mac & Windows

Resources: OpenAI Codex CLI Cheatsheet | Claude Code CLI Cheatsheet
Presentation Link Git Repo
29 / 29
1 / 29