Skip to content

Environment Setup

Setting up your local environment for AI-assisted development involves configuring tools, API keys, and project settings.

Prerequisites

Before starting, ensure you have:

  • [ ] A code editor or IDE
  • [ ] Terminal/command line access
  • [ ] Git installed
  • [ ] API keys for your chosen AI services

API Keys

Most AI tools require API keys. Here's how to set them up:

Anthropic (Claude)

  1. Create account at console.anthropic.com
  2. Generate API key
  3. Set environment variable:
export ANTHROPIC_API_KEY="sk-ant-..."

OpenAI

  1. Create account at platform.openai.com
  2. Generate API key and set up billing
  3. Set environment variable:
export OPENAI_API_KEY="sk-..."

Google (Gemini)

  1. Go to Google AI Studio
  2. Generate API key
  3. Set environment variable:
export GOOGLE_API_KEY="..."

Persisting Environment Variables

Add keys to your shell profile so they persist:

# Add to ~/.zshrc
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

# Reload
source ~/.zshrc
# Add to ~/.bashrc or ~/.bash_profile
export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

# Reload
source ~/.bashrc
# Add to ~/.config/fish/config.fish
set -gx ANTHROPIC_API_KEY "sk-ant-..."
set -gx OPENAI_API_KEY "sk-..."
# Add to $PROFILE
$env:ANTHROPIC_API_KEY = "sk-ant-..."
$env:OPENAI_API_KEY = "sk-..."

# Or set system-wide via System Properties

Security Note

Never commit API keys to git. Use environment variables or .env files (and add .env to .gitignore).

Tool Installation

IDEs

# Download from cursor.com
# Or via Homebrew (macOS)
brew install --cask cursor
# Install VS Code
brew install --cask visual-studio-code

# Install Copilot extension from marketplace
# Download from codeium.com/windsurf

CLI Tools

# Install via npm
npm install -g @anthropic-ai/claude-code

# Or via Homebrew
brew install anthropic/tap/claude-code
# Install via pip
pip install aider-chat

# Or via pipx (recommended)
pipx install aider-chat
# Install via npm
npm install -g @openai/codex-cli

Configuration Directories

After installation, create your configuration directories:

# Create config directories
mkdir -p ~/.claude
mkdir -p ~/.cursor/rules

# Create global instructions
touch ~/.claude/CLAUDE.md

Config Directory Reference

Project Setup

Initialize a Project

# Create project directory
mkdir my-project && cd my-project

# Initialize git
git init

# Create AI instructions
touch CLAUDE.md  # For Claude Code
mkdir -p .cursor/rules  # For Cursor

Project Instructions Template

Create a CLAUDE.md (or similar) in your project root:

# Project: My App

## Tech Stack
- Next.js 14 with App Router
- TypeScript (strict mode)
- Prisma + PostgreSQL
- Tailwind CSS

## Conventions
- Use functional components with hooks
- Prefer server components where possible
- Follow existing code patterns

## Important Files
- `src/app/` - App router pages
- `src/lib/` - Shared utilities
- `prisma/schema.prisma` - Database schema

Verification

Test your setup:

Test API Keys

# Test Anthropic
curl 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-3-haiku-20240307","max_tokens":10,"messages":[{"role":"user","content":"Hi"}]}'

Test Tools

# Test Claude Code
claude --version

# Test Aider
aider --version

# Open Cursor
cursor .

Troubleshooting

"API key not found"

  1. Verify the key is set: echo $ANTHROPIC_API_KEY
  2. Check for typos in variable name
  3. Reload shell config: source ~/.zshrc

"Command not found"

  1. Verify installation: which claude or which aider
  2. Check PATH includes install location
  3. Try reinstalling the tool

"Permission denied"

  1. Check file permissions: ls -la ~/.claude/
  2. Fix if needed: chmod 755 ~/.claude/

Next Steps