Claude Code and Cursor: Developing with AI Coding Agents
After completing this topic
You will learn how the principles of agents, discussed in Episode 9, are applied in the most mature and practical application: AI coding agents. This includes practical usage of Claude Code, Cursor, Windsurf, and GitHub Copilot, outlining the strengths of each tool, and how they can be utilized in a biology research lab.
This is the third installment in the Tools Phase 3 series, focusing on tools that are fundamentally changing the way software is developed by 2025. By leveraging these tools, biology research labs can dramatically accelerate data analysis, pipeline construction, and code reproduction for publications.
What AI Coding Agents Do
As discussed in Episode 9, an agent is defined as LLM + Tools + Loop + Memory. AI coding agents are a specialized form of this structure, tailored for the development environment.
Essential Tools:
- File System: Reading, writing, and searching files.
- Terminal Execution: Running shell commands and tests.
- Git: Checking status, committing, and diffing.
- Web Access: Retrieving documents and library information.
- Editor Integration: Recognizing cursor position and selected code.
These tools enable the agent to actually write, execute, and debug code.
Typical Tasks:
- Implementing new features.
- Fixing bugs.
- Writing tests.
- Refactoring.
- Writing documentation.
- Conducting code reviews.
- Performing migrations.
Biology-Specific Tasks:
- Writing scripts for scRNA-seq analysis pipelines.
- Visualizing experimental data (matplotlib, plotly).
- Integrating with APIs (PubMed, UniProt, ClinicalTrials.gov).
- Creating Snakemake and Nextflow workflows.
- Analyzing Jupyter notebooks.
Key Tool Landscape
Claude Code
Anthropic's CLI coding agent, allowing direct interaction from the terminal.
# From the project folderclaude
# Start the conversation> "Refactor the data parsing section in src/analysis.py"Features:
- Terminal Native: No separate GUI, can be combined with any editor.
- Powerful Tool Usage: Well-integrated Bash, file system, Git, and web tools.
- Long Sessions: Automatically manages context (compaction, offloading) as described in Episode 10.
- Skills & Plugins: Allows for custom logic extensions on a per-project basis.
- MCP Support: Connects to the MCP server described in Episode 9.
Biology Use Cases:
- Processing large files in an experimental data folder.
- Developing analysis pipelines using the CLI instead of Jupyter notebooks.
- Directly interacting with a remote server (HPC) via an SSH session.
Cursor
A VS Code fork, an IDE specialized for AI pair programming.
Key Features:
- Tab Autocompletion: Inline completion that understands the context of the file.
- Cmd+K: Natural language command for code editing.
- Cmd+L (Chat): Sidebar conversation.
- Cmd+I (Composer): Agent for editing multiple files.
- Codebase Indexing: Indexes the entire project for semantic search.
- Rules for AI: Allows specifying project-specific rules (coding style, architecture).
Features:
- Visual IDE: Users familiar with VS Code can adapt quickly.
- Inline Editing: Select a specific code block and edit it using natural language.
- Model Selection: Choose from Claude, GPT-4o, Gemini, and its own fast model.
Windsurf (Codeium)
A competing IDE in the Cursor family, known for its Cascade agent mode.
Differentiators:
- Flows: Automatically plans and executes large changes across multiple files.
- Windsurf Cascade: Proactively understands code (referencing related files in addition to what the user selects).
- Price Competitiveness: Generally less expensive than Cursor.
GitHub Copilot
Copilot Chat: Sidebar conversation. Copilot Workspace: Automates issue β plan β implementation β PR. Copilot Agent Mode: Recently added agent functionality similar to Cursor and Claude Code.
Supported by Microsoft and OpenAI, with strong VS Code integration and mature enterprise-scale infrastructure.
Others
- Zed: Performance-focused editor with recent AI feature enhancements.
- Continue.dev: Open-source coding extension (VS Code, JetBrains).
- Aider: CLI-based open-source agent.
- Devin (Cognition): Fully autonomous agent, runs in the cloud.
Claude Code Practical Workflow
A concrete example of how to use Claude Code in a biology setting.
Getting Started
cd ~/lab_projectclaudeIn the initial conversation, the agent references the CLAUDE.md file to learn about the project. This file contains the project's rules and structure.
Task Delegation
Example 1: scRNA-seq data analysis script:
"There are 5 new scRNA-seq h5ad files in the
data/samples/folder. Create a script that performs QC, filtering, normalization, UMAP, and Leiden clustering for each sample, and saves the results in theresults/{sample_id}/folder. Also, create a summary table of the results for each sample."
The agent will:
- Check the folder structure (
ls,find). - Review the sample files (file size, extension).
- Write a Scanpy standard pipeline script.
- Identify and install necessary libraries.
- Test the script on a small sample.
- Fix any issues that arise.
- Return the final script and usage instructions.
Code Review
Example 2: PR code review:
"Review the changes in this branch, paying particular attention to whether there is any missing multiple testing correction in the statistical testing section."
The agent will use git diff main to check the changes, identify the statistical sections, and point out the missing p_adjusted processing, suggesting the use of FDR correction from statsmodels.
Debugging
Example 3: Debugging a failed pipeline:
"Running
run_analysis.pycrashes on the 3rd sample. The logs are inlogs/error.log. Find the cause and fix it."
The agent will read the logs, examine the problem file, identify the specific situation of the 3rd sample (e.g., 0 cell size), add exception handling code, and verify the fix by re-running the script.
Document Generation
Example 4: README and tutorials:
"Create a README for this repository, including installation, data preparation, execution, and result interpretation. Include all the information a new lab member would need to get started."
The agent will scan the project, create a comprehensive README, and extract actual usage examples from existing scripts.
Cursor Practical Workflow
A different style of using Cursor.
Inline Editing (Cmd+K)
Select a specific function and press Cmd+K.
"Apply NumPy vectorization to this function to remove the for loop."
Cursor will suggest editing the function, which can be accepted or rejected.
Sidebar Conversation (Cmd+L)
"I want to change the color of the UMAP visualization in the currently open notebook to be based on cell type."
Cursor Chat will understand the notebook context and suggest code snippets.
Composer (Cmd+I)
For large changes across multiple files.
"@src/utils.py @src/analysis.py: Refactor config management from hardcode to a pydantic Settings class."
Composer will simultaneously modify the two files, and the changes can be reviewed using a diff.
Rules for AI
In the project root, create a .cursorrules file.
- Always use type hints.
- Docstrings should follow the Google style.
- Scanpy-related functions should be isolated in the `utils.scanpy_helpers` module.
- Tests should be written using pytest, with 80% code coverage.
- Use English for biological domain terms, and Korean for comments.These rules will be automatically included in the system prompt for each conversation.
Vibe Coding: A New Workflow
Vibe Coding is a workflow where developers express their intent and feeling in natural language, and the agent implements the code, rather than writing detailed code. This workflow is becoming increasingly popular.
Traditional Development:
Read documentation β Write code β Execute β Debug β RepeatVibe Coding:
Natural language request β Agent execution β Review results β AdjustBiology Example:
"Create a seaborn heatmap of the expression of 8 genes. The genes should be hierarchically clustered, the samples should maintain their original order, the color scheme should be diverging with the center at the mean, and missing values should be gray."
This single sentence can be instantly implemented into 20-30 lines of code. If the result is not satisfactory, it can be modified again using natural language.
Suitable Cases:
- Repetitive analysis scripts (explore-plot-refine cycle).
- Temporary visualizations and data exploration.
- Prototypes and MVPs.
- Script automation.
Unsuitable Cases:
- Critical Accuracy: Clinical and regulatory applications. Code review is essential.
- Architectural Decisions: Human judgment should be central to system design.
- Security Sensitive: Authentication, encryption, and injection prevention.
Key Principle: Always execute and test the code generated by the agent and review the results. Do not rely solely on the "vibe." As discussed in Episode 11, hallucinations can occur in the code as well.
Project Context Management
It is important to ensure that the agent understands the overall context of a large project.
CLAUDE.md (Claude Code)
Create a CLAUDE.md file in the project root. The agent will automatically reference this file at the beginning of each session.
Example Content:
# Project Context
## Project Purpose
This repository contains an automated pipeline for analyzing single-cell RNA sequencing data.
## Main Structure
- `data/`: Raw h5ad files (excluded from Git).
- `src/`: Pipeline code.
- `notebooks/`: Exploratory analysis.
- `results/`: Execution results.
## Coding Style
- Type hints are mandatory.
- Docstrings: Google style.
- New scripts should be placed in `src/scripts/`.
## Data Conventions
- Cell type labels should prioritize the CellTypist nomenclature.
- Gene symbols should use the latest HGNC.
## Common Tasks
- Adding a new sample: `python src/scripts/add_sample.py {sample_id}`.
- Re-generating QC reports: `snakemake qc_report`.
## Precautions
- Do not modify the contents of `data/raw/`.
- Always run pre-commit before pushing to Git.The agent will reference this document to adhere to the project's conventions.
.cursorrules (Cursor)
Cursor uses a .cursorrules file. The format is slightly different, but the purpose is the same.
Other Tools
Windsurf(.windsurfrules), Continue(config.json), etc. Each tool has its own rules file. The project context file can be considered an extension of the system prompt from Episode 7, making it persistent for the project.
MCP Server Integration
As discussed in Part #9, MCPs are particularly useful in coding agents.
Useful MCP Servers
Filesystem: Access to the file system (default). GitHub: Manipulating repositories, issues, and pull requests. Slack: Team communication. Postgres: Database queries. Puppeteer: Web browser automation. Memory: Persisting knowledge across sessions. Notion: Reading and writing to Notion pages.
Bio-Specific MCP Servers (Custom).
- PubMed MCP: Searching and retrieving paper details.
- UniProt MCP: Protein information.
- PDB MCP: Structural data.
- Laboratory LIMS MCP: Internal experiment management.
MCP Server Configuration (Claude Code Example)
~/.claude/mcp.json:
{
"mcpServers": {
"pubmed": {
"command": "python",
"args": ["/path/to/pubmed_mcp_server.py"]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
}
}
}The agent automatically recognizes and uses the tools from these servers.
Best Practices
Good Conversation Patterns
1. Clear Objectives.
Bad: "Can you review this code?" Good: "I think this function has a time complexity of O(n^2). Can you check if it can be improved to O(n log n)?"
2. Provide Context.
Bad: "Why doesn't it work?" Good: "This script crashes on the 3rd sample. The logs are here: (paste)"
3. Request Verification.
Bad: "Refactor it."
Good: "After refactoring, make sure it passes the existing tests: pytest tests/."
4. Plan First.
Bad: "Implement a new feature." Good: "First, create a plan for implementing the new feature. Then, I will approve it and you can proceed."
Claude Code's Plan mode enforces this. The plan is approved before execution.
Preventing Mistakes
1. Confirm Destructive Operations. Explicitly confirm file deletions, git force pushes, and data deletions.
2. Automatically Run Tests. Automatically run tests after code changes. Human intervention is required if tests fail.
3. Git Commit Review. Review the diff before the agent commits.
4. Cost Awareness. Claude Opus and GPT-4o have a cost per token. Check the estimated cost for large sessions.
Team Usage
Shared Rules: Manage CLAUDE.md and .cursorrules in Git.
Session Logs: Document important decisions.
Training: Share good conversation patterns with team members.
Auditing: Human review of code created by the agent is essential.
When to Use Which Tool
Personal Experimentation/Analysis: Cursor + Claude Sonnet or Windsurf. Convenient if you are familiar with IDEs. Large-Scale Automation/CLI Workflows: Claude Code. Maintains a terminal session. Team Collaborative Coding: Cursor or Copilot. IDE collaboration features. MLE/Research: Cursor + Claude Code combination. Combines notebooks and CLI. Bio Pipelines (Snakemake/Nextflow): Claude Code. In an HPC SSH session. Rapid Prototyping: Windsurf Cascade or Cursor Composer. Large Refactorings: Cursor Composer or Claude Code plan mode.
Bio Application Scenarios
Scenario 1: Automating a Snakemake Workflow
Building a new experimental pipeline for the lab using Snakemake.
Using Claude Code:
- Specify the lab's standards (input format, output specifications, resource limits) in
CLAUDE.md. - "Create a Snakemake workflow based on this sample sheet. The rules should include QC, alignment, variant calling, and annotation. Support cluster submission."
- The agent generates the rules file,
config.yaml, and the cluster configuration. - Validate with a test run.
- Write documentation.
Scenario 2: Kaggle Bio Competition
Participating in a Kaggle bio image classification competition.
Using Cursor:
- Data exploration (Jupyter + Cursor).
- Baseline model (
torchvisionResNet + fine-tuning). - Data augmentation experiments (try multiple augmentation combinations using Cmd+K).
- Implement ensemble and TTA.
- Create a submission pipeline.
Combines the PyTorch knowledge from Part #12 with Cursor's real-time editing.
Scenario 3: Reproducing a Paper's Code
Applying the method from a recent paper to your own data.
Claude Code + WebFetch:
- Check the GitHub link in the paper.
- Clone the code repository.
- Set up the environment (requirements, conda environment).
- Adapt the code to your data.
- Verify the results.
The agent reads the method section of the paper and compares it to the code. If differences are found, it also refers to issues and pull requests from the paper's authors.
Key Takeaways
- AI coding agents = specialized applications of the agent from Part #9 in a development environment.
- Key tools: Claude Code (CLI), Cursor (IDE), Windsurf, GitHub Copilot.
- Choose between terminal vs. IDE workflows. Depends on the project's nature and personal preference.
- Vibe Coding: Express intent in natural language. Always verify the results.
- Maintain conventions with a project context file (
CLAUDE.md,.cursorrules). - Integrate custom tools with MCP servers. Build bio-specific servers.
- Best practices: clear objectives, context, verification requests, and planning first. Confirm destructive operations.
- Bio applications: use in Snakemake pipelines, Kaggle competitions, and reproducing papers.
π Appendix: Practical Tips for Experts
Difficulty: Very Hard Target Audience: Readers with experience in operating and deploying AI coding agents in production.
A.1 Agent Context Management (Claude Code Perspective)
Claude Code's context applies the principles from Part #10.
Session Compression. Automatically compact conversations when they become long. Replace old tool results with summaries.
Skills. Define domain-specific logic as custom project skills. For example, a bio-analysis skill could include knowledge of standard scRNA-seq pipelines.
Subagents. Delegate large tasks to sub-agents. Each sub-agent has its own context window. This is the multi-agent pattern from Part #9.
A.2 Cursor's Codebase Indexing
Index the entire project.
Procedure:
- Divide each file into chunks (using the chunking principles from Part #8).
- Calculate embeddings (using Cursor's own model or OpenAI).
- Store in a vector database (local or cloud).
- Automatically search for and insert relevant code into the context when chatting.
@ Syntax. Use @file.py, @Codebase, and @Docs for explicit references.
A.3 Utilizing Prompt Caching
Prompt caching, discussed in Part #10 A.4, is particularly useful in coding agents.
- Cache
CLAUDE.mdand system prompts, as they are repeated in every session. - Cache large files that are read repeatedly.
- Anthropic's ephemeral cache is automatically applied.
Effect: Reduces the cost and latency of large project sessions.
A.4 Optimizing the Tool Use Loop
The cost of each agent step multiplies. This is a key area for optimization.
- Parallel tool calls: Parallelize independent tool calls. Claude has recently supported this.
- Tool result compression: Summarize large results (e.g., a list of files) and include them in the context.
- Early exit: Break the loop when sufficient information has been collected.
- Retry with backoff: Use exponential backoff when a tool fails.
A.5 Code Safety Validation
A layer of automatic validation is essential for code created by the agent.
Static analysis: pyright, ruff, mypy. Checks for type errors, style issues, and potential bugs.
Test execution: pytest. Verify that existing tests pass.
Security scan: bandit, safety. Check for vulnerabilities.
Diff review: A human should perform a final review of large changes.
Automate this with Claude Code's hooks and pre-commit.
A.6 Multi-Repo vs. Monorepo Strategies
Monorepo: Standard for large organizations. Bazel, Nx, Turborepo. Use .gitignore and .cursorignore to ensure that the agent indexes only the relevant parts.
Multi-Repo: Create a separate session for each repository. Process cross-repository changes sequentially.
A.7 Defending Against Prompt Injection (Code Context)
The risk of prompt injection, discussed in Part #7, also exists in code.
- Malicious instructions embedded in READMEs, issues, and comments.
- Injection from web search results.
- Instructions in the code of open-source dependencies.
Defense:
- Clearly distinguish between user requests and file content.
- Train the agent to ignore "system instructions" in file content.
- Treat shell execution results as data only.
Claude Code and Cursor are trained to recognize and defend against these threats.
A.8 Performance Benchmarking
SWE-Bench: Percentage of GitHub issues successfully resolved. Part #9 A.10. HumanEval and MBPP: Percentage of correct function implementations. Code Reasoning Benchmarks: Tasks involving code understanding and refactoring.
As of 2025, Claude Sonnet, Opus, GPT-4o, and GPT-3, and Gemini 2.5 and 3 are among the top performers. However, actual user satisfaction may differ from benchmark rankings.
A.9 Team Adoption Strategy
Phase 1: Individual use (1-2 people). Start with Cursor and Copilot. Phase 2: Team pilot (5-10 people). Define shared rules and workflows. Phase 3: Organization-wide deployment. Manage licenses, governance, and auditing.
Risk Management:
- Prevent IP leakage (using enterprise plans).
- Prevent the deployment of incorrect code (enforce mandatory reviews).
- Prevent skill degradation (provide ongoing training and pairing).
A.10 Future Directions
Autonomous engineering agents: Autonomously complete tasks from issue to pull request (like Devin).
Long-horizon planning: Autonomously manage projects over days or weeks.
Multi-modal understanding: Understand screenshots, diagrams, and videos.
Self-improvement: Repeatedly review and improve its own code.
Bio-specific agents: Embed bio-domain knowledge. Integrate experiment design, analysis, and paper writing.
References
All the content, scenarios, analogies, and figures in this article are developed by BioPlayground. The following are external references that can help with understanding the concepts.
- Claude Code: claude.com/claude-code (Anthropic official)
- Cursor: cursor.com
- Windsurf: codeium.com/windsurf
- GitHub Copilot: github.com/features/copilot
- Zed: zed.dev
- Continue.dev: continue.dev
- Aider: aider.chat
- Devin (Cognition): cognition.ai
- MCP: modelcontextprotocol.io
- SWE-Bench: swebench.com
- AI Coding Best Practices: Anthropic, Cursor, and GitHub official guides
- Simon Willison Blog: simonwillison.net/tags/llms β AI coding trends newsletter
The landscape of AI coding agents is summarized in Part #14. Part #15 will summarize how to integrate all the previous parts into the actual workflow of a bio research lab.
Next concept
- Ep. #15
bio-ai-integrationβ Phase 4. Integrate episodes #1 to #14 into a practical workflow for a bio research lab.