HitchhikersAI.org

Vibe Coding for Scientists

AI-Assisted Development for Scientific Workflows

"There's a new kind of coding I call 'vibe coding', where you fully give in to the vibes, embrace exponentials, and forget that the code even exists."
— Andrej Karpathy

Scope Clarification: This guide teaches vibe coding—using AI tools (Claude, Cursor AI) to build applications. It is not about building LLM-focused applications or agentic AI systems. That is a separate, more advanced topic requiring different approaches and infrastructure. Note: This guide reflects my personal approach to vibe coding on a MacBook Pro M4. The principles apply universally, but you're welcome to use different tools, platforms, or technology stacks that suit your workflow.

Raminderpal Singh | raminderpal@hitchhikersai.org
What Is Vibe Coding?

Vibe coding is an AI-assisted development approach where you orchestrate two specialized tools: Claude for strategic thinking and architecture, and Cursor AI for code implementation. This isn't about writing less code—it's about having AI partners handle implementation details while you focus on scientific logic and workflow design.

The Workflow Dynamics

Claude Design & Thinking Sonnet 4.5 Cursor AI Code Generation Multi-model File System Project Directory You Orchestrating the flow Data Flow Orchestration
This diagram represents the core method: You orchestrate information flow between Claude (strategic thinking), Cursor AI (code execution), and your project's file system. Solid arrows show data flow—specifications move from Claude to files, code moves from Cursor to files. Dashed arrows show your orchestration role—you manually move information between tools based on their strengths. This separation creates an effective development loop where each component operates in its optimal domain.
⚠️

A Lighthearted Caution About Foundations

Comparison of AI Vibe Coding vs Engineer-Guided AI foundations

The honest metaphor: Vibe coding builds functional applications quickly, but they're constructed on rocky foundations—just like the house on the left. Everything works, the rooms are livable, but the structural integrity beneath isn't engineered for permanence.

What This Means in Practice:

  • Your code may have hidden edge cases you haven't discovered
  • Error handling exists where AI thought to add it, not systematically
  • Dependencies might not be pinned to specific versions
  • Test coverage is limited to what you manually verified
  • Scaling to production would require significant refactoring

The house on the right? That's engineer-guided AI development—proper foundation, load-bearing walls, engineered for longevity. It takes longer to build, requires more expertise, but it's designed to last and scale.

For scientists: If you're building research tools for personal use or small teams, the rocky foundation is often perfectly acceptable. The house stands, it serves its purpose, and you can always rebuild with better foundations later if needed. Just be aware of what you're building on, and don't be surprised when production deployment requires more engineering rigor than vibe coding provides.

7-Step Development Workflow
1
📍 Claude
Define Application Architecture
Describe your scientific workflow in plain language to Claude
What to Provide:
  • Scientific problem and workflow requirements
  • Input data formats and expected outputs
  • Any constraints (performance, dependencies, platform)
What Claude Delivers:
  • Recommended architecture and design patterns
  • Component breakdown with responsibilities
  • Technology stack suggestions
  • Potential challenges and alternatives
Model Selection:
Always use Claude Sonnet 4.5 for architecture decisions
2
📍 Claude
Generate Detailed Specifications
Request file structure, dependencies, and implementation specifications
Request from Claude:
  • Complete directory structure
  • requirements.txt or package dependencies
  • Per-file specifications with responsibilities
  • Data flow and integration points
Export Format:
Download specifications as Markdown files to import into Cursor
Token Management:
Create separate chats within your Project for complex components
3
📍 Cursor AI
Initial Code Generation
Import specifications into Cursor and generate implementation code
Setup Process:
  • Create project directory structure manually
  • Set up virtual environment (python -m venv venv)
  • Import Claude's specification files
Model Selection in Cursor:
Use Sonnet 4.5 for initial code generation—accuracy over speed
Generation Strategy:
  • Generate one component at a time
  • Reference specifications explicitly
  • Request inline comments for complex logic
4
📍 Cursor AI
Test & Debug Locally
Run code, identify errors, and use Cursor for quick fixes
Testing Approach:
  • Install dependencies from requirements.txt
  • Run main application or test scripts
  • Document all error messages
Cursor Debugging:
  • Copy error messages directly into Cursor chat
  • Switch to auto mode for simple syntax fixes
  • Use Sonnet 4.5 for logic errors or complex bugs
When Cursor Struggles:
Export error context to Claude for architectural review
5
📍 Cursor AI
When to Escalate to Claude
Recognize problems that need strategic rethinking vs quick fixes
Escalation Triggers:
  • Repeated failures on the same error
  • Architectural mismatches or conflicts
  • Unclear implementation approach
  • Performance or scalability concerns
  • Educational understanding of code behavior
6
📍 Claude
Conceptual Review & Guidance
Import issues into Claude for high-level analysis and strategic guidance
Questions to Ask:
  • "Does this implementation approach make sense?"
  • "Why is this pattern causing issues?"
  • "What's actually happening in this code?"
  • "Is there a better architectural approach?"
Claude's Strengths:
  • Explaining conceptual problems
  • Suggesting alternative approaches
  • Educational explanations of code behavior
  • Strategic thinking about architecture
Token Management:
Create new chats in your Project when approaching token limits
7
🔄 Iterate
Repeat Until Complete
Continue the loop: Claude for thinking, Cursor for implementation
The Reality:
This is not a one-pass process. Expect multiple iterations, especially for complex applications. Each cycle refines understanding and implementation.
When to Stop:
  • Tests pass consistently
  • Code meets original specifications
  • No critical issues remain
  • You understand how it works
Tool Strengths & Limitations

Claude Strengths

  • Conceptual thinking and design
  • Explaining complex patterns
  • Evaluating multiple approaches
  • Educational explanations
  • Strategic architecture decisions

Limitations

  • Token limits per chat
  • Cannot directly execute code
  • Requires manual file export
  • Can hallucinate implementation details

Cursor AI Strengths

  • Direct code generation and editing
  • Integrated testing environment
  • Model switching for efficiency
  • Real-time error detection
  • File system integration

Limitations

  • Weaker at conceptual discussions
  • Token usage can be expensive
  • Less effective for architecture decisions
  • May not question approach validity
💡 Honest Assessment: What This Really Means
You're the orchestrator: This isn't autopilot. You decide what goes where, when to switch tools, and which outputs to trust. Manual file management is required.
Knowledge gaps remain acceptable: You don't need to understand every Python library or design pattern. But you DO need to understand your scientific problem and be able to judge if implementations make sense.
AIs make mistakes: Both Claude and Cursor will confidently suggest wrong approaches. Cross-checking between them helps, but critical thinking is essential.
Token limits are real constraints: Complex projects will hit limits. Projects feature in Claude helps. But expect to manage multiple related chats.
File management is manual: No seamless integration exists. You'll copy markdown files, export error logs, and manage documentation. This is tedious but necessary.
Learning still happens: This approach reduces the learning curve but doesn't eliminate it. You'll gradually understand more about code structure, debugging, and patterns.
Not all problems suit this workflow: Simple scripts might be overkill. Highly specialized scientific algorithms may require domain expertise that AIs lack.
Cost accumulates: Claude subscription, Cursor costs, and time investment add up. Budget for this realistically.
Success requires iteration: First attempts often fail. Expect 3-5+ cycles through the workflow for complex features. This is normal, not a sign of failure.
Click workflow steps above to explore each phase in detail
Recommended Technology Stack
🐍
Python 3.12+
Programming Language
Latest Python version with improved performance and type hints. Best support from AI tools.
📦
venv
Virtual Environment
Built-in Python virtual environment manager. Keeps project dependencies isolated.
📊
NumPy & pandas
Data Processing
Core scientific computing libraries. Essential for data manipulation and analysis.
🧪
pytest
Testing Framework
Standard Python testing framework. Essential for validating scientific workflows.
🤖
LangChain / LangGraph
LLM Framework
For building LLM applications and agents. Well-supported by AI code generators.
🔍
FAISS
Vector Database
Fast similarity search for embeddings. Standard for RAG implementations.
🕸️
Neo4j
Graph Database
Native graph database for knowledge graphs. Ideal for relationship-heavy scientific data and ontologies.
Vercel
Web Deployment Platform
Zero-config deployment for static sites and serverless functions. Free tier perfect for prototypes and demos.
Additional Considerations
Version Control: Git is assumed but not covered here. Use it. Even for solo projects.
API Keys: Store in .env files. Never commit them. Use python-dotenv for loading.
Platform: This stack works on macOS, Linux, and Windows. Some adjustments needed for Windows paths.
Scientific Libraries: Additional domain-specific libraries (BioPython, RDKit, etc.) work well with this approach.
Neo4j Setup: Can run locally via Docker or use Neo4j Aura cloud service. Python driver: neo4j-driver. Excellent for ontologies, chemical structures, biological pathways, and citation networks.
Vercel Deployment: Free tier perfect for static sites and simple demos. 250MB uncompressed serverless function limit means heavy Python ML apps (PyTorch, scikit-image with full dependencies) often need alternative deployment (Railway, Render, Fly.io). See "Deploying webapps" tab for details.

Vibe Coding: Your Entry Point to AI Engineering

Vibe coding is deliberate scaffolding. It's designed to get scientists building functional applications quickly, but it's also the foundation for more sophisticated AI engineering practices. Think of it as training wheels that teach you the terrain before you need to navigate it independently.

What Is AI Engineering?

AI Engineering is the discipline of building production-grade systems that leverage large language models and other AI capabilities. Unlike vibe coding, which focuses on rapid prototyping with heavy AI assistance, AI engineering emphasizes:

Production Systems

Reliability, monitoring, error handling, logging, deployment pipelines

Cost Management

Token optimization, caching strategies, model selection, budget tracking

Evaluation & Testing

Systematic prompt testing, output validation, regression testing, performance benchmarks

Architecture Patterns

RAG implementations, agent frameworks, multi-model orchestration, state management

The Progression: Vibe Coding → AI Engineering
Vibe Coding Heavy AI assistance Manual orchestration Rapid prototyping Learning fundamentals Transition Phase Understanding patterns Adding evaluation Productionizing code Reducing AI dependency AI Engineering Strategic AI use Systematic evaluation Production systems Independent debugging Weeks 1-4 Months 2-6 6+ Months
Major Differences: Side-by-Side Comparison
Aspect Vibe Coding AI Engineering
Primary Goal Get working prototype quickly Build production-ready systems
AI Role Generate most of the code Assist with specific components
Code Understanding High-level comprehension acceptable Deep understanding required
Testing Approach Manual testing, "does it work?" Automated tests, evaluation frameworks
Error Handling Basic try/catch, ask AI to fix Comprehensive error strategies, logging
Prompt Management Ad-hoc, conversational Versioned, tested, optimized
Cost Awareness Subscription-based, limited tracking Per-token budgets, optimization strategies
Debugging Copy errors to AI, iterate Systematic debugging, root cause analysis
Documentation AI-generated, often outdated Actively maintained, up-to-date
Deployment Local or simple hosting CI/CD pipelines, monitoring
Time to First Version Hours to days Days to weeks
Scalability Single user, prototype scale Multi-user, production scale
What Transfers from Vibe Coding

Vibe coding isn't wasted time. These skills and knowledge directly transfer to AI engineering:

✓ Understanding AI Capabilities & Limits

You've learned what LLMs can and cannot do reliably through direct experience

✓ Prompt Engineering Fundamentals

Clear communication with LLMs, context management, specification clarity

✓ Application Architecture Patterns

FastAPI structures, data flow, API design from generated applications

✓ Debugging Intuition

Pattern recognition for common errors, understanding stack traces

✓ Python Ecosystem Familiarity

Package management, virtual environments, common libraries

✓ Scientific Domain Knowledge

Your research problem understanding—this doesn't change

When to Make the Transition

Honest assessment: Most scientists don't need to become AI engineers. Vibe coding is sufficient for research tools, internal applications, and proof-of-concept work. Consider the transition when:

Multiple Users

Your tool needs to serve colleagues or external users reliably

High Frequency Use

Running hundreds or thousands of times per day with cost implications

Critical Research Path

Failures would significantly impact research outcomes or timelines

Publication/Reproducibility

Need to publish methods or share with the scientific community

Complex LLM Workflows

Multi-step agent systems, RAG implementations, or custom fine-tuning

Career Direction

Moving toward computational roles or building AI-powered products

💡 Honest Reality Check
The gap is significant: Moving from vibe coding to AI engineering is a months-long learning curve, not a weekend project. Expect to invest 100+ hours learning deployment, testing, monitoring, and optimization.
You don't need to become an engineer: Many successful research applications stay at the vibe coding level indefinitely. If it works for your needs, there's no requirement to "graduate" to production engineering.
Hybrid approaches exist: You can use vibe coding for rapid development, then hire or collaborate with engineers for production deployment. This division of labor is often more efficient than learning everything yourself.
The skills compound: Time spent on vibe coding makes AI engineering easier later, but it doesn't eliminate the learning curve. You'll still need to learn testing frameworks, deployment tools, and production best practices.
Cost models change dramatically: Vibe coding uses flat subscription pricing. AI engineering requires detailed token tracking, optimization, and budgeting. Be prepared for this mental shift.
Not all vibe-coded apps should be productionized: Some prototypes prove a concept or answer a question, then get discarded. That's a successful outcome—not everything needs to scale.

The Path Forward

Start with vibe coding. Build working tools for your research. Understand what's possible and what's difficult. Then, if your needs grow beyond prototypes, you'll have the foundation to either learn AI engineering yourself or effectively collaborate with engineers who can take your vision to production.

Getting Started: Setup Instructions
🤖
Claude Setup
1
Create account at claude.ai
2
Subscribe to Claude Pro ($20/month) for access to Sonnet 4.5 and higher usage limits
3
In Settings, verify your model is set to Claude Sonnet 4.5
4
Create a Project for your vibe coding work to manage multiple chats
5
Enable "Artifacts" feature in settings for receiving structured outputs
Reality: Free tier has severe usage limits. Pro subscription is necessary for serious development work.
⌨️
Cursor AI Setup
1
Download and install Cursor for your platform (macOS, Linux, Windows)
2
Create account and sign in
3
In Settings → Models, configure access to Claude Sonnet 4.5
4
Familiarize yourself with Cmd+K (inline generation) and Cmd+L (chat panel)
5
Set up auto mode for efficient token usage during maintenance
Reality: Free trial is limited. Paid tier required for serious use. Monitor token consumption carefully.
🐍
Python Environment
1
Install Python 3.12+ from python.org or use package manager
2
Verify installation: python --version
3
Create project directory and navigate to it
4
Create virtual environment: python -m venv venv
5
Activate environment: source venv/bin/activate (macOS/Linux) or venv\Scripts\activate (Windows)
6
Install dependencies: pip install -r requirements.txt
Reality: Virtual environments are not optional. They prevent dependency conflicts and make projects reproducible.

💬 Claude Is Your Setup Assistant!

Stuck on a setup step? Encountering errors? Not sure what a command does? Ask Claude for help!

Example Questions to Ask Claude:

  • "I'm getting 'command not found' when running python3 -m venv venv. What does this mean?"
  • "How do I activate the virtual environment on Windows instead of macOS?"
  • "What's the difference between pip and pip3?"
  • "Claude is installed but Cursor can't find it. How do I verify the path?"
  • "I'm on Linux—do I need to change any of these commands?"
  • "Can you explain what uvicorn does in step 5?"

Claude can provide platform-specific guidance, debug errors, explain technical terms, and walk you through setup challenges step-by-step. This is exactly the kind of assistance Claude excels at—don't hesitate to use it!

First Project Workflow

Step 1: Open Claude and describe your scientific problem in a new chat within a Project

Step 2: Request architecture and file specifications

Step 3: Export specifications as Markdown

Step 4: Open Cursor, create project structure, import specifications

Step 5: Use Cursor to generate initial code with Sonnet 4.5

Step 6: Test locally, debug with Cursor

Step 7: Escalate conceptual issues back to Claude

Practice Exercise: Build a Cell Confluence Analyzer

This is a real vibe coding example. The Confluence Analyzer application was built using exactly this workflow. Follow these steps to replicate the process and build your own version.

Expected Time: 2-4 hours for complete implementation | Difficulty: Intermediate | Technologies: FastAPI, HTMX, Tailwind CSS, scikit-image

Step 1: Craft Your Initial Prompt to Claude

This is YOUR step. You need to describe your scientific application in a way that Claude can understand and design. The quality of your initial prompt directly impacts the quality of Claude's architectural output.

Essential Components of a Good Prompt:

1. Clear Objective

What does your app need to do?

  • State the core function plainly
  • Use domain-specific terminology
  • Avoid vague language
2. Scientific Context

Why does this exist?

  • Reference established methods
  • Link to protocols or papers
  • Specify your research domain
3. Honest Constraints

What are you handling manually?

  • Environment setup (venv, etc.)
  • Package installation
  • Platform specifics (macOS, Linux)

Prompt Template Structure:

Create a [platform] [language] application that implements [core function] for [scientific domain].

Here is the method/protocol to follow:
[URL to reference methodology, paper, or protocol]
[Optional: additional context or requirements]

[Optional: Example data or inputs]

Notes:
- I will handle [manual step 1] myself
- [Platform-specific constraint]
- [Any other limitations or preferences]

Example: Cell Confluence Analyzer Prompt

This is what was actually used for the Confluence Analyzer:

create a local Py app that implements Confluence Assessment for cells in life sciences.

Here is the method to follow:
https://www.thermofisher.com/blog/life-in-the-lab/how-to-measure-cell-confluency/

Notes:
- I will setup and activate a venv, and install requirement.txt manually.

Why this worked:

  • Clear objective: "Confluence Assessment for cells"
  • Domain specified: "life sciences"
  • Reference provided: Thermo Fisher methodology URL
  • Honest about manual steps: venv and requirements handled separately
  • Platform implied: "local" means not cloud/web-based
⚠️ Common Mistakes to Avoid
  • Too vague: "Build something to analyze cells" → Missing: what kind of analysis?
  • Too prescriptive: "Use FastAPI with HTMX and Tailwind" → Let Claude recommend the stack
  • No context: "I need an image analyzer" → Missing: what domain, what methodology?
  • Hiding constraints: Not mentioning manual setup leads to Claude suggesting automation you can't use
  • Asking for code: This step is about design, not implementation
✓ Good Practice Tips
  • Start broad, let Claude ask clarifying questions
  • Reference URLs to protocols/papers directly in the prompt
  • Be honest about your skill level and what you can manage
  • Ask for mockups and diagrams explicitly if you want visual artifacts
  • Create a Claude Project for this work to manage multiple related chats

Your Task: Write Your Own Prompt

Before moving to Step 2, craft your initial prompt following the template above. Think about your scientific problem, find reference methodology, and be honest about constraints.

Example Input Images (Cell Microscopy)

These are the types of images the Confluence Analyzer application needs to process:

Example cell microscopy images at different confluence levels

Four microscopy images showing cells at varying confluence levels (approximately 10%, 40%, 60%, and 90% coverage)

Step 2: Claude's Strategic Output

Claude provided comprehensive design artifacts:

📋 UI Mockups

Interactive HTML viewer showing main window, settings panel, batch processing interface

🔄 Data Flow Diagram

SVG showing 7-step processing pipeline with timing estimates

🏗️ Architecture Design

Technology stack recommendations and system architecture

Example: Data Flow Diagram
Single Image Analysis Flow 1. User Uploads Image file (PNG/JPEG/TIFF) 2. Validate Input • Check format • Verify dimensions 3. Preprocess • Convert grayscale • Correct illumination 4. Threshold • Otsu or adaptive • Binary mask 5. Clean Mask • Remove debris 6. Calculate • Confluence % 7. Return Results • JSON + overlay Total: ~130ms
Step 3: Transition to Cursor AI

Critical Orchestration Step: The mockups and diagrams from Claude were saved as files, then referenced in the Cursor AI prompt.

This is the manual file management that makes vibe coding work—you move specifications from Claude to Cursor.

Cursor AI Prompt (with file references):

create a local Py app that implements Confluence Assessment for cells in life sciences.

Here is the method to follow:
https://www.thermofisher.com/blog/life-in-the-lab/how-to-measure-cell-confluency/
/Users/raminderpal/.../mockups_viewer.html
/Users/raminderpal/.../05_data_flow_diagram.svg

Here are example input images:
/Users/raminderpal/.../example_images.png

Notes:
- I will setup and activate a venv, and install requirement.txt manually.

Referenced: example_images.png

Example input images

Key Differences from Claude Prompt: Same core request, but now includes absolute file paths to Claude's outputs AND the example images. Cursor uses all of these to generate implementation code that matches the design specifications and handles the expected input format.

Step 4: The Final Result

Cursor AI Generated Complete Application:

📁 Project Structure
confluence-assessment/
├── src/
│   ├── main.py
│   ├── config.py
│   ├── image_processing.py
│   ├── batch_processor.py
│   └── models.py
├── templates/
│   ├── index.html
│   ├── results.html
│   └── batch.html
├── uploads/
├── outputs/
└── requirements.txt
📊 Performance Achieved
  • ⚡ ~130ms processing time
  • 🎯 85-95% accuracy vs manual
  • 📦 FastAPI + HTMX + Tailwind
  • ✅ Batch processing capable
Application Screenshots
Initial upload interface

Initial State

Clean upload interface with drag-and-drop zone

Analysis results with metrics

After Analysis

16.5% confluence with detailed metrics and processing time

✓ README.md Generated Automatically

Cursor also generated comprehensive documentation including installation steps, usage instructions, API endpoints, and troubleshooting guides. This wasn't requested—it followed best practices automatically.

Try It Yourself: Replication Steps

🤖 In Claude

  1. Create a new Project for this work
  2. Copy the initial prompt (from Step 1 above)
  3. Request UI mockups and architecture diagrams
  4. Download artifacts as HTML/SVG files
  5. Ask Claude to refine specifications if needed

⌨️ In Cursor AI

  1. Create project directory structure
  2. Set up venv: python3 -m venv venv
  3. Reference Claude's files in Cursor prompt
  4. Generate code with Sonnet 4.5
  5. Test, debug, iterate with Cursor

Expected total development time: 2-4 hours from prompt to working application

💡 Honest Lessons from This Build
The mockups weren't perfect: Claude's initial UI design had some HTMX implementation details wrong. Cursor corrected these during code generation.
Image processing took multiple iterations: The Otsu thresholding worked immediately, but debris removal required 3-4 rounds of debugging in Cursor.
Documentation was better than expected: The auto-generated README was actually production-ready with minimal edits.
File paths matter: Using absolute paths (not relative) when referencing Claude's outputs in Cursor prevented confusion.
Model selection impacted speed: Initial generation with Sonnet 4.5 took ~15 minutes. Subsequent debugging with auto mode was much faster.

Building ML Systems: The Two-Brain Approach

This guide extends vibe coding to machine learning and drug discovery workflows. The core principle: separate strategic thinking from implementation using Claude Opus for reasoning and Cursor Sonnet for building.

The Two-Brain Hybrid Approach

🧠 Brain 1: The Scientist (Claude Opus)

Purpose: High-level reasoning and scientific strategy

"Design a feature engineering strategy for small molecule binding affinity."

Why Opus?

  • Better at "holding the whole problem in its head"
  • Spots subtle scientific flaws (data leakage, biological violations)
  • Provides nuanced analysis of algorithm implications

Output: Text specification or detailed blueprint

⚙️ Brain 2: The Builder (Cursor Sonnet)

Purpose: Implementation and code generation

"Here is the spec for the feature engineering class. Write the PyTorch implementation."

Why Sonnet?

  • Superior at coding mechanics (imports, syntax, refactoring)
  • Better file management and multi-file edits
  • Fewer syntax errors, better edge case handling

Output: Production-ready code

5-Step Workflow: The Architect & The Mason

Scenario: You need to build a new graph neural network (GNN) layer for molecular property prediction.

Step 1: The "Deep Think" (Claude Opus)

Time: 5-10 minutes

I am designing a GNN for drug discovery. I need to engineer edge features
based on bond type and stereochemistry. Review standard literature (like RDKit
conventions) and propose a robust JSON schema for these features. Warn me about
potential edge cases with disconnected graphs.

What to expect: Detailed analytical plan, JSON/text specification, edge case warnings, literature references

Action: Copy the summary and key specifications into a text file

Step 2: The "Spec Transfer" (You)

Create a new file in Cursor (e.g., specs/edge_features_spec.md)

Why this matters: You are feeding the "smart" reasoning into the "fast" coder. This grounds Cursor and prevents naive implementation mistakes.

# Edge Features Specification

## Feature Schema
[JSON or structured description]

## Constraints
- No null values in bond types
- Must handle disconnected atoms
- Stereochemistry: must preserve 3D orientation

## Edge Cases
- Aromatic bonds: treat as hybrid sp2
- Implicit hydrogens: RDKit convention

Step 3: The "Build" (Cursor Sonnet)

Tool: Cursor Composer (Cmd+I / Ctrl+I) | Time: 5-15 minutes

Model verification: Go to Cursor Settings → Models → Confirm "Claude 3.5 Sonnet" (NOT cursor-small)

Read `specs/edge_features_spec.md`. Create a new file `features/bond_processing.py`.
Implement the `BondFeaturizer` class described in the spec. Use `rdkit` and
`torch_geometric`. Ensure strict typing.

Expected: 90%+ correct first attempt (following high-quality blueprint)

Step 4: Review & Refine (Cursor Chat)

Tool: Cursor Chat (Cmd+K / Ctrl+K) | Time: 5-10 minutes (iterative)

Run the generated code, highlight problematic blocks, ask for specific fixes:

  • "This loop looks slow for large molecules. Vectorize it using RDKit operations."
  • "Add handling for molecules with 100+ atoms—current implementation times out."
  • "The current approach loses stereochemistry. Integrate CIP rules for priorities."

Each refinement cycle: 2-3 prompts until convergence

Step 5: Integration (Cursor Chat)

Time: 5 minutes

Integrate the BondFeaturizer into `data/molecule_loader.py`.
Update the `__getitem__` method to use the new edge features.
Also update `config/train_config.yaml` with new feature dimensions.
Quick Reference: Which Tool for What?
Task Best Tool/Model Why?
Scientific Strategy Claude App (Opus) Deepest reasoning; catches scientific logic errors
System Architecture Claude App (Opus) Better at "big picture" component design
Writing Code Cursor (Sonnet 3.5) Faster, fewer syntax errors, better file management
Refactoring Cursor (Sonnet 3.5) Composer feature unmatched for multi-file edits
Quick Fixes Cursor (Sonnet 3.5) Instant context awareness of your repo
Algorithm Debugging Cursor Chat (Sonnet 3.5) Understands your entire codebase
New Module Design Claude App (Opus) Handles abstract design better than Sonnet
Key Principles
1. Separate Strategy from Execution

Opus = "What and Why" | Sonnet = "How and When"

2. Use Specs as Bridges

Write down Opus reasoning before asking Sonnet to code. Reduces iteration cycles by 50%+

3. Cursor Composer is Your Multiplier

Use Cmd+I to edit multiple files at once. Perfect for features that span multiple modules

4. Always Review Output

Sonnet is "too agreeable"—check for data leakage, silent column drops, assumption mismatches

5. Iterate Rapidly

Each cycle takes 5-10 minutes. 4 cycles = polished, production-ready module

Time Estimates

For a typical ML feature engineering module (300-500 lines):

10-15 min
Brain 1 (Opus)
5 min
Spec Transfer
10-15 min
Brain 2 (Sonnet)
10-15 min
Review & Testing
~45-60 minutes
Total per module
vs. 2-4 hours manual coding + debugging
⚠️ Common Pitfalls to Avoid
Don't ask Sonnet for the overall strategy: It will produce code-like pseudocode, not strategic thinking.
Don't skip the spec file: Sonnet performs 40% better when given a written specification.
Don't assume Sonnet understands your data: Tell it explicitly: "This dataset has N rows, M features, and is imbalanced 90/10."
Don't trust first-pass code for data science: Always run it on a small subset first to verify correctness.
Don't forget to update tests: Ask Sonnet to write tests after writing the feature module.

Deploying webapps to Vercel

Vercel offers zero-configuration deployment for static sites and serverless functions. It's ideal for getting vibe-coded prototypes online quickly. This guide focuses on practical deployment, not production engineering—these are demos and prototypes, not enterprise applications.

What Vercel Is Good For
✓ Static HTML/CSS/JS sites

Single-page apps, documentation, visualizations, interactive demos

✓ Serverless Python/Node APIs

Simple REST endpoints, data processing, file conversions (max 10s execution)

✓ Prototype sharing

Get a live URL in minutes to share with collaborators or supervisors

✓ Free tier generous

100GB bandwidth, unlimited deployments, automatic HTTPS, custom domains

What Vercel Is NOT Good For
✗ Long-running computations

Serverless functions timeout at 10s (hobby) or 60s (pro). No overnight model training.

✗ Large file storage

Blob storage free tier: 1GB total. Not for datasets, images, or user uploads at scale.

✗ Stateful applications

Every request gets a fresh container. No persistent in-memory state.

✗ Heavy Python dependencies

250MB uncompressed limit (50MB compressed). PyTorch, TensorFlow, full scipy stacks often exceed this with all dependencies.

Vercel Blob Storage Overview

Vercel Blob is an S3-compatible object storage for files. It's useful for storing user uploads, generated images, or processed data files.

Free Tier Limits

  • 1GB total storage
  • 1,000 read requests per month
  • 1,000 write requests per month
  • 1GB bandwidth per month
Basic Usage (Python):
from vercel_blob import put, get, list_blobs

# Upload file
blob = await put('data.csv', file_content, token=BLOB_TOKEN)
# Returns: {'url': 'https://...', 'pathname': 'data.csv'}

# Download file
data = await get('data.csv', token=BLOB_TOKEN)

# List all files
files = await list_blobs(token=BLOB_TOKEN)

Reality: For scientific prototypes, 1GB is enough for demo purposes but not for production datasets. Use external storage (S3, Dropbox, Google Drive) for larger files.

Deploying the Confluence Analyzer (Practice Exercise)

Important limitation: The Confluence Analyzer uses FastAPI with image processing (scikit-image, NumPy). While individual libraries might seem manageable, their transitive dependencies (scipy, joblib, etc.) can push the total beyond Vercel's 250MB uncompressed serverless limit. This walkthrough demonstrates the process, but you'd likely need to either: (a) significantly simplify dependencies, (b) use Vercel Edge Functions with WebAssembly, or (c) deploy the full app elsewhere (Railway, Render, Fly.io).

Modified Deployment: Static HTML Frontend Only

For demonstration, we'll deploy a simplified version: just the static HTML interface without the Python backend. Users can upload images, but analysis would require a separate backend deployment.

Step 1: Prepare Your Project

Create a simple project structure:

confluence-demo/
├── index.html          # Your main HTML file
├── assets/
│   ├── logo.png       # Any images
│   └── styles.css     # Optional CSS
└── vercel.json        # Optional config

Step 2: Create Vercel Account

  1. Go to vercel.com
  2. Sign up with GitHub (recommended) or email
  3. Connect your GitHub account for automatic deployments

Step 3: Initialize Git Repository

cd confluence-demo
git init
git add .
git commit -m "Initial commit"

# Create GitHub repo and push
git remote add origin https://github.com/yourusername/confluence-demo.git
git push -u origin main

Step 4: Deploy to Vercel

Option A: Via Vercel Dashboard (Easiest)

  1. Go to vercel.com dashboard
  2. Click "Add New Project"
  3. Import your GitHub repository
  4. Vercel auto-detects it's a static site
  5. Click "Deploy"
  6. Wait 30-60 seconds
  7. Get live URL: https://confluence-demo.vercel.app

Option B: Via Vercel CLI

# Install Vercel CLI
npm install -g vercel

# Login
vercel login

# Deploy (from project directory)
vercel

# Follow prompts:
# - Link to existing project? No
# - Project name? confluence-demo
# - Directory to deploy? ./
# - Auto-detected settings okay? Yes

# Deploy to production
vercel --prod

Step 5: Configure Custom Domain (Optional)

  1. Go to Project Settings → Domains
  2. Add your domain (e.g., confluence.yourdomain.com)
  3. Update DNS records as instructed by Vercel
  4. Vercel automatically provisions SSL certificate

Step 6: Automatic Deployments

Every push to your GitHub main branch triggers automatic deployment:

# Make changes
echo "Updated content" >> index.html

# Commit and push
git add .
git commit -m "Update content"
git push

# Vercel automatically deploys within 30-60 seconds
# Preview URL: https://confluence-demo-git-main.vercel.app
# Production URL: https://confluence-demo.vercel.app
Deploying with Python Backend (Alternative Approach)

For FastAPI apps like the Confluence Analyzer, you'll need to adapt for serverless constraints:

Project Structure for Serverless

api/
├── index.py           # Main FastAPI app
└── requirements.txt   # Python dependencies

public/
└── index.html         # Static frontend

vercel.json            # Deployment config

vercel.json Configuration

{
  "builds": [
    {
      "src": "api/index.py",
      "use": "@vercel/python"
    }
  ],
  "routes": [
    {
      "src": "/api/(.*)",
      "dest": "api/index.py"
    }
  ]
}

Reality check: The Confluence Analyzer requires scikit-image (~40MB) + NumPy (~15MB) + Pillow (~3MB) = ~58MB for the core libraries, which fits within the 250MB uncompressed limit. However, scikit-image pulls in scipy (~100MB), joblib, and other transitive dependencies that can push the total deployment size to 200MB+.

💡 Use Claude & Cursor AI to Optimize Package Size

If your deployment approaches the 250MB limit, use the two-brain approach to optimize:

Step 1: Ask Claude for Strategy

Prompt example:

"My FastAPI app with scikit-image is ~200MB uncompressed. I need to deploy to Vercel (250MB limit). Analyze my requirements.txt and suggest: (1) lighter alternatives for image processing, (2) dependencies I can remove, (3) architecture changes to reduce bundle size."

Claude will identify heavy dependencies, suggest alternatives (e.g., PIL instead of scikit-image for basic operations), and propose architectural changes.

Step 2: Implement with Cursor AI

Take Claude's recommendations to Cursor:

"Refactor the image processing module to use Pillow instead of scikit-image. Replace the gaussian_filter function with PIL's ImageFilter.GaussianBlur. Update requirements.txt and all affected functions."

Cursor will handle the refactoring, update imports, and modify your requirements.txt file.

Step 3: Verify Size Reduction

After optimization, check your deployment size locally:

# Install dependencies and check size
pip install -r requirements.txt --target ./package
du -sh ./package
# Compare before and after

This iterative approach often reduces deployment size by 40-60% while maintaining functionality.

Python Essentials Cheatsheet

Variables and Types

# Variables (dynamic typing)
name = "experiment_01"
temperature = 37.5
is_valid = True
samples = [1, 2, 3, 4, 5]

# Type checking
type(temperature)  # <class 'float'>

Control Flow

# If statements
if temperature > 35:
    print("High temperature")
elif temperature > 25:
    print("Normal temperature")
else:
    print("Low temperature")

# For loops
for sample in samples:
    print(f"Processing sample {sample}")

# While loops
count = 0
while count < 5:
    count += 1

Functions

# Basic function
def calculate_average(values):
    return sum(values) / len(values)

# With type hints
def process_data(data: list[float]) -> float:
    """Process data and return average."""
    return sum(data) / len(data)

# Lambda functions
square = lambda x: x ** 2

Lists

# Creating and manipulating lists
samples = [1, 2, 3, 4, 5]
samples.append(6)
samples.extend([7, 8])
first = samples[0]
last = samples[-1]
subset = samples[1:4]  # Slicing

# List comprehension
squared = [x**2 for x in samples]
filtered = [x for x in samples if x > 3]

Dictionaries

# Creating and using dictionaries
experiment = {
    "name": "test_01",
    "temperature": 37.5,
    "duration": 120
}

# Accessing values
temp = experiment["temperature"]
temp = experiment.get("temperature", 25)  # With default

# Iterating
for key, value in experiment.items():
    print(f"{key}: {value}")

NumPy Arrays

import numpy as np

# Creating arrays
arr = np.array([1, 2, 3, 4, 5])
zeros = np.zeros((3, 3))
ones = np.ones((2, 4))
random = np.random.rand(5)

# Operations
mean = arr.mean()
std = arr.std()
normalized = (arr - arr.mean()) / arr.std()
NumPy is essential for scientific computing

Reading Files

# Text files
with open('data.txt', 'r') as f:
    content = f.read()
    lines = f.readlines()

# CSV files with pandas
import pandas as pd
df = pd.read_csv('data.csv')

# JSON files
import json
with open('config.json', 'r') as f:
    config = json.load(f)

Writing Files

# Text files
with open('output.txt', 'w') as f:
    f.write('Results\n')
    f.writelines(['line1\n', 'line2\n'])

# CSV with pandas
df.to_csv('output.csv', index=False)

# JSON
data = {"experiment": "test_01", "result": 42}
with open('results.json', 'w') as f:
    json.dump(data, f, indent=2)

Path Handling

from pathlib import Path

# Modern path handling
data_dir = Path('data')
file_path = data_dir / 'experiment.csv'

# Check existence
if file_path.exists():
    print("File found")

# Create directories
output_dir = Path('output')
output_dir.mkdir(exist_ok=True)
Use pathlib for cross-platform compatibility

Virtual Environment

# Create virtual environment
python -m venv venv

# Activate (macOS/Linux)
source venv/bin/activate

# Activate (Windows)
venv\Scripts\activate

# Deactivate
deactivate

Package Management

# Install package
pip install numpy

# Install from requirements
pip install -r requirements.txt

# Create requirements file
pip freeze > requirements.txt

# Install specific version
pip install numpy==1.24.0

Environment Variables

# .env file
API_KEY=your_api_key_here
DATABASE_URL=postgresql://localhost/db

# Loading in Python
from dotenv import load_dotenv
import os

load_dotenv()
api_key = os.getenv('API_KEY')
Never commit .env files to version control

Project Structure

project/
├── venv/              # Virtual environment
├── src/               # Source code
│   ├── __init__.py
│   ├── main.py
│   └── utils.py
├── tests/             # Test files
│   └── test_main.py
├── data/              # Data files
├── .env               # Environment variables
├── .gitignore
├── requirements.txt
└── README.md