Setting Up AI in Your Development Workflow
A practical guide to integrating AI into your IDE, terminal, and git workflow. Four layers, concrete setup steps, and an opinionated stack recommendation.
The Goal
The measure of a good AI development setup is not how many tools you have installed — it is how often you reach for AI without thinking. When using AI feels like friction, you do not use it consistently. When it is embedded in tools you already have open all day, you use it automatically.
This guide covers four layers: IDE, terminal, git workflow, and code review. Set up the layers that match your workflow. You do not need all four.
Layer 1 — IDE Integration
Cursor vs GitHub Copilot vs Claude in VS Code
┌─────────────────────┬──────────────────────┬───────────────────────┬────────────────────┐ │ │ Cursor │ GitHub Copilot │ Claude for VS Code │ ├─────────────────────┼──────────────────────┼───────────────────────┼────────────────────┤ │ Price │ $20/month (Pro) │ $10/month │ Free (with API key)│ │ Model │ GPT-4o / Claude │ GPT-4o │ Claude (your key) │ │ Inline completion │ ✓ Best in class │ ✓ Good │ ✗ │ │ Chat (whole file) │ ✓ Excellent │ ✓ Good │ ✓ Good │ │ Codebase context │ ✓ Full codebase │ ✓ Full codebase │ ✗ (current file) │ │ Multi-file edits │ ✓ Composer │ ✓ Workspace edits │ ✗ │ │ Terminal integration│ ✓ │ ✓ │ ✗ │ │ Best for │ Full-time AI dev │ Copilot already fans │ Occasional use │ └─────────────────────┴──────────────────────┴───────────────────────┴────────────────────┘
Setting Up Cursor
- 1Download Cursor from cursor.sh — it is a fork of VS Code, so your extensions and settings migrate automatically
- 2On first launch, import your VS Code settings via Settings > General > VS Code Import
- 3Go to Settings > Models — set your default model (Claude Sonnet is the best balance of speed and quality)
- 4Open settings.json and add the configuration below
- 5Use Cmd+K (inline edit), Cmd+L (chat sidebar), or Cmd+Shift+I (Composer for multi-file changes)
{
// Cursor-specific settings
"cursor.general.enableShadowWorkspace": true,
"cursor.cpp.enablePartialAccepts": true,
// Keep your code private — disable telemetry
"cursor.privacy.telemetryLevel": "off",
// Enable indexing for full codebase context
"cursor.indexing.enabled": true,
"cursor.indexing.excludePatterns": [
"**/node_modules/**",
"**/.git/**",
"**/dist/**",
"**/.next/**"
],
// Accept completions with Tab, dismiss with Escape
"editor.tabCompletion": "on",
// Recommended: turn off auto-save, review AI changes manually
"files.autoSave": "off"
}Layer 2 — Terminal
A shell function that wraps the Claude API gives you AI in your terminal without switching context. Add this to your ~/.zshrc or ~/.bashrc:
# AI helper — call Claude from the terminal
# Usage: ai "explain what this does" < file.py
# ai "write a one-liner to find all .log files over 100MB"
# git diff | ai "summarise these changes for a commit message"
ai() {
local prompt="$*"
# Read stdin if available (allows piping)
if [ ! -t 0 ]; then
local stdin_content
stdin_content=$(cat)
prompt="$prompt
$stdin_content"
fi
curl -s https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d "{
"model": "claude-haiku-4-5",
"max_tokens": 1024,
"messages": [{"role": "user", "content": "$prompt"}]
}" | python3 -c "import sys, json; print(json.load(sys.stdin)['content'][0]['text'])"
}# Explain a command you don't know ai "what does this git command do: git rebase -i HEAD~3" # Explain an error cat error.log | ai "what is causing this error and how do I fix it" # Generate a command ai "write a find command to locate all .env files not in .gitignore" # Code review a file cat src/auth.js | ai "review this for security issues"
Layer 3 — Git Workflow
AI-assisted commit messages eliminate the blank commit message problem. A git hook that generates a draft message from your staged diff takes 10 minutes to set up.
#!/bin/bash
# AI-assisted commit message generator
# Generates a draft commit message from the staged diff
# You can edit or replace it before confirming
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
# Only run on blank commit messages (not amends, merges, etc.)
if [ -n "$COMMIT_SOURCE" ]; then
exit 0
fi
# Get the staged diff
DIFF=$(git diff --cached --stat)
if [ -z "$DIFF" ]; then
exit 0
fi
echo "Generating commit message..." >&2
# Call Claude with the diff
GENERATED=$(git diff --cached | curl -s https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d @- <<EOF
{
"model": "claude-haiku-4-5",
"max_tokens": 200,
"system": "You write git commit messages. Output ONLY the commit message. First line: imperative verb, 50 chars max. Optional body after blank line. No markdown.",
"messages": [{"role": "user", "content": "Write a commit message for this diff:
$(cat)"}]
}
EOF
| python3 -c "import sys, json; print(json.load(sys.stdin)['content'][0]['text'])")
# Prepend generated message (user can edit before confirming)
echo "$GENERATED" > "$COMMIT_MSG_FILE"# Make the hook executable chmod +x .git/hooks/prepare-commit-msg # Test it: stage a change and run git commit git add -p git commit # editor opens with AI-generated message — edit or accept
Layer 4 — Pre-Commit AI Review
A pre-commit hook that runs a lightweight AI review on staged changes catches obvious issues before they hit the repo. This is not a substitute for proper code review — it is a first-pass sanity check.
#!/bin/bash
# Lightweight AI pre-commit review
# Flags Critical issues only — won't block on style suggestions
DIFF=$(git diff --cached)
if [ -z "$DIFF" ]; then
exit 0
fi
echo "Running AI pre-commit review..."
REVIEW=$(echo "$DIFF" | curl -s https://api.anthropic.com/v1/messages -H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" -d @- <<EOF
{
"model": "claude-haiku-4-5",
"max_tokens": 512,
"system": "You do quick pre-commit reviews. Look ONLY for: obvious bugs, hardcoded secrets or credentials, SQL injection risks, and syntax errors. If nothing critical found, respond with exactly: OK. Otherwise list only Critical issues — one per line, with line number.",
"messages": [{"role": "user", "content": "Review this diff:
$(cat)"}]
}
EOF
| python3 -c "import sys, json; print(json.load(sys.stdin)['content'][0]['text'])")
if [ "$REVIEW" = "OK" ]; then
echo "AI review: clean"
exit 0
else
echo ""
echo "⚠️ AI review flagged potential issues:"
echo "$REVIEW"
echo ""
echo "Commit anyway? (y/N)"
read -r response
if [[ "$response" =~ ^[Yy]$ ]]; then
exit 0
else
exit 1
fi
fiThe .env Pattern for API Keys
All four layers above rely on the ANTHROPIC_API_KEY environment variable. Here is the correct setup:
# 1. Add to ~/.zshrc or ~/.bashrc (global — works in all projects) export ANTHROPIC_API_KEY="sk-ant-..." # 2. For project-specific keys (e.g. different accounts for different clients) # Create a .env.local file in the project root: ANTHROPIC_API_KEY=sk-ant-... # 3. Add .env.local to .gitignore (critical — never commit API keys) echo ".env.local" >> .gitignore echo ".env" >> .gitignore # 4. Load project .env when entering the directory (add to ~/.zshrc) # Using direnv (brew install direnv): eval "$(direnv hook zsh)" # Then create .envrc in your project: # dotenv .env.local # 5. Verify your key is set: echo $ANTHROPIC_API_KEY | head -c 20 # shows first 20 chars only
What NOT to Use AI for in Your Dev Workflow
- Security-critical code paths — AI-generated auth and encryption code is a common source of subtle vulnerabilities
- Database migrations — always write and review migrations manually; AI can misread your schema intent
- Dependency selection — AI will confidently recommend deprecated or abandoned packages; check npm/PyPI directly
- Performance-critical hot paths — AI does not know your specific performance profile; profile first, optimise second
- Anything the AI says it's "not sure about" — if the AI hedges, go to the documentation
Recommended Stack
- IDE: Cursor (cursor.sh) for full-time AI-assisted development, or GitHub Copilot (github.com/features/copilot) if you prefer to stay in VS Code
- Terminal: The shell function above — quick queries without leaving the terminal
- Commit messages: The prepare-commit-msg git hook — saves 2 minutes per commit, adds up fast
- Pre-commit review: Optional — useful for solo work; skip for team projects where PR review handles this
- API calls in scripts: anthropic Python SDK or @anthropic-ai/sdk for Node.js — official, typed, actively maintained
Ready to go further?
Take the interactive course — daily lessons, real exercises, XP and streaks. Turn reading into lasting skills.
