Claude Skills Guide

Claude Code for Rye Python Project Workflow Guide

Rye is a modern Python project management tool created by Armin Ronacher (the creator of Flask and Sphinx). It provides an all-in-one solution for managing virtual environments, dependencies, toolchains, and publishing packages. When combined with Claude Code, you get a powerful AI-assisted development workflow that can automate repetitive tasks, generate code, and help debug issues. This guide shows you how to integrate Claude Code into your Rye-based Python projects for maximum productivity.

Understanding Rye and Claude Code

Before diving into workflows, let’s clarify what each tool brings to your development process.

Rye handles:

Claude Code contributes:

Together, they form a comprehensive development environment where Claude Code understands your project’s structure (via Rye’s configuration) and can take actions using appropriate tools.

Setting Up Your Rye Project with Claude Code

The first step is creating a new Rye project and ensuring Claude Code can work with it effectively.

Creating a New Project

# Install Rye if you haven't already
curl -sSf https://rye-up.com/get | bash

# Initialize a new project
rye init my-project
cd my-project

# Sync dependencies and create virtual environment
rye sync

When you run rye init, it generates several configuration files that Claude Code can read to understand your project structure:

Configuring Claude Code for Rye Projects

Create a CLAUDE.md file in your project root to help Claude understand your Rye setup:

# Claude Code Project Context

This is a Rye-managed Python project. Key information:

- Python version: See .python-version file
- Dependencies: See pyproject.toml
- Virtual environment: Managed by Rye in .rye/
- Run tests: rye test
- Format code: rye fmt
- Lint: rye lint

Always use rye commands instead of raw python/pip commands.

This file ensures Claude Code always uses Rye commands for project operations, maintaining consistency across your team.

Daily Development Workflow

Starting a New Feature

When beginning new work, Claude Code can help you follow a structured approach:

  1. Review existing code - Ask Claude to summarize relevant files
  2. Plan implementation - Describe your goal and request a code plan
  3. Generate code - Have Claude write the implementation
  4. Run tests - Use rye test to verify functionality

Example interaction:

User: I need to add user authentication to this project. Can you first look at the current structure and then propose a plan?

Claude: I'll examine your project structure and current code to understand what we're working with...

Dependency Management

Rye makes dependency management straightforward, and Claude Code can help you add and manage dependencies intelligently:

# Add a new dependency
rye add requests

# Add a dev dependency
rye add --dev pytest

# Sync after adding
rye sync

When you ask Claude to add a dependency, it will:

  1. Check your existing dependencies to avoid duplicates
  2. Use rye add with appropriate flags (–dev for test/development tools)
  3. Run rye sync to update the virtual environment
  4. Verify the installation works

Running and Debugging

Claude Code excels at debugging. When you encounter errors:

# Run your application
rye run python src/main.py

Share the error output with Claude and ask for debugging help. Claude will analyze the stack trace, examine relevant code, and suggest fixes.

Automated Testing Workflow

Testing is essential for maintainable code. Here’s how to use Claude Code with Rye’s testing tools.

Setting Up Tests

# Add pytest as a dev dependency
rye add --dev pytest

# Create test file
mkdir -p tests
touch tests/test_main.py

# Run tests
rye test

Working with Claude on Test-Driven Development

You can ask Claude to implement TDD workflows:

User: Can you write a test first for a new function that calculates Fibonacci numbers, then implement the function to make it pass?

Claude will:

  1. Write a test in tests/test_math.py
  2. Implement the function in src/math.py
  3. Run rye test to verify
  4. Refactor as needed

Test Coverage Analysis

Ask Claude to analyze your test coverage:

User: What's our current test coverage? Are there any critical functions lacking tests?

Claude will run coverage reports and identify gaps in your test suite.

Code Quality and Maintenance

Formatting and Linting

Rye includes tool management for formatters and linters:

# Add formatting and linting tools
rye add --dev black ruff

# Format code
rye fmt

# Run linter
rye lint

Configure these tools in your pyproject.toml:

[tool.ruff]
line-length = 88
target-version = "py311"

[tool.black]
line-length = 88

Automated Code Review

Use Claude Code for code review:

User: Can you review the changes in this branch and suggest improvements?

Claude will examine your code and provide feedback on:

Building and Publishing

When you’re ready to release your package:

# Build the package
rye build

# Publish to PyPI
rye publish

Claude can help you:

Advanced Workflows

Multi-Python Version Testing

Rye supports multiple Python versions. Test your code against different versions:

# Add another Python version
rye pin 3.10

# Sync with new version
rye sync

# Run tests with specific version
rye run --python 3.10 pytest

Using Claude Skills with Rye

Create custom Claude skills for your Rye workflow. For example, a skill that always runs tests after generating code:

---
name: rye-tdd
description: Generate code and automatically run tests
---

# Rye TDD Workflow

When asked to write code:
1. First write or update tests
2. Implement the code
3. Run `rye test` to verify
4. Report results and any failures

Best Practices

  1. Always use Rye commands - Don’t use raw python or pip. Use rye run, rye add, etc.
  2. Keep CLAUDE.md updated - Document project-specific context
  3. Run tests frequently - Use rye test after every significant change
  4. Leverage Claude for refactoring - Don’t manually rewrite code when Claude can help
  5. Use locked dependencies - Commit requirements.lock for reproducible builds

Conclusion

Combining Claude Code with Rye gives you the best of both worlds: a powerful Python project management tool and an intelligent AI assistant. By following this workflow guide, you can significantly improve your development productivity, maintain higher code quality, and streamline your entire Python development process.

The key is to let Claude Code handle the cognitive heavy lifting—planning, writing, debugging, and reviewing—while Rye manages the mechanical aspects of Python project management. This separation of concerns allows you to focus on solving problems rather than managing tools.

Built by theluckystrike — More at zovo.one