Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions .claude/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Claude Code Configuration

This directory contains configuration for using this project with Claude Code, particularly in the online environment.

## SessionStart Hook

The `hooks/SessionStart` script automatically runs when a new Claude Code session begins. It:

1. **Installs pixi** (if not already installed) - The package and environment manager
2. **Installs project dependencies** - All Python packages and tools defined in `pyproject.toml`
3. **Sets up pre-commit hooks** - For automatic code quality checks
4. **Configures git** - Sets up merge drivers for lockfiles

## Usage with Claude Code Online

When you start a Claude Code online session, the SessionStart hook will automatically run and set up your environment. You'll see output indicating the setup progress.

### Available Commands

Once setup is complete, Claude can use these pixi tasks:

#### Testing & Quality
- `pixi run test` - Run pytest tests
- `pixi run coverage` - Run tests with coverage report
- `pixi run lint` - Run ruff and pylint linters
- `pixi run format` - Format code with ruff

#### CI Tasks
- `pixi run ci` - Run full CI pipeline (format, lint, test, coverage)
- `pixi run fix` - Auto-fix common issues (update lock, format, lint)

#### Pre-commit
- `pixi run pre-commit` - Run all pre-commit hooks
- `pixi run pre-commit-update` - Update pre-commit hook versions

### How It Works

1. **First session**: The hook installs pixi and all dependencies (may take a few minutes)
2. **Subsequent sessions**: The hook verifies the environment is ready (much faster)
3. **Environment activated**: All pixi commands are available to Claude

### Troubleshooting

If you encounter issues:

1. **Dependencies not found**: Run `pixi install` manually
2. **Lockfile conflicts**: Run `pixi run update-lock`
3. **Pre-commit issues**: Run `pixi run pre-commit-update`
4. **Full reset**: Delete `.pixi` directory and restart session

### Customization

You can modify `hooks/SessionStart` to:
- Install additional tools
- Run custom setup scripts
- Configure environment variables
- Set up external services

## Learn More

- [Claude Code Documentation](https://docs.claude.com/claude-code)
- [Pixi Documentation](https://pixi.sh)
- [Project README](../README.md)
19 changes: 19 additions & 0 deletions .claude/activate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# Source this file to activate the pixi environment in your current shell
# Usage: source .claude/activate.sh

# Add pixi to PATH
export PATH="$HOME/.pixi/bin:$PATH"

# Optional: Activate pixi shell if available
if command -v pixi &> /dev/null; then
echo "✅ Pixi environment activated"
echo "💡 Available commands:"
echo " pixi run test - Run tests"
echo " pixi run lint - Run linters"
echo " pixi run format - Format code"
echo " pixi run ci - Run full CI"
pixi task list --summary 2>/dev/null || true
else
echo "⚠️ Pixi not found. Please run .claude/hooks/SessionStart first."
fi
50 changes: 50 additions & 0 deletions .claude/hooks/SessionStart
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# SessionStart hook for Claude Code online environment
# This script sets up the Python development environment using pixi

set -e

echo "🚀 Setting up Python Template environment..."

# Check if pixi is installed
if ! command -v pixi &> /dev/null; then
echo "📦 Installing pixi..."
curl -fsSL https://pixi.sh/install.sh | bash

# Add pixi to PATH for current session
export PATH="$HOME/.pixi/bin:$PATH"

# Source bashrc to get pixi in PATH (if bashrc was updated)
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"

echo "✅ Pixi installed successfully"
else
echo "✅ Pixi already installed"
fi

# Ensure pixi is in PATH for this session
export PATH="$HOME/.pixi/bin:$PATH"

# Install project dependencies
echo "📦 Installing project dependencies..."
pixi install

# Run pre-commit installation
echo "🔧 Setting up pre-commit hooks..."
pixi run pre-commit install || echo "⚠️ Pre-commit installation skipped (optional)"

# Set up git merge driver for lockfiles
echo "🔧 Configuring git merge driver..."
pixi run setup-git-merge-driver || true

echo "✅ Environment setup complete!"
echo ""
echo "Available pixi tasks:"
pixi task list
echo ""
echo "💡 Common commands:"
echo " pixi run test - Run tests"
echo " pixi run lint - Run linters"
echo " pixi run format - Format code"
echo " pixi run ci - Run full CI pipeline"
echo ""
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ If you want to use docker you may want to run the `scripts/setup_host.sh` script

If you are using pixi, look at the available tasks in pyproject.toml If you are new to pixi follow the instructions on the pixi [website](https://prefix.dev/)

# Claude Code Online Support

This template includes built-in support for [Claude Code](https://docs.claude.com/claude-code) online environment! The `.claude/hooks/SessionStart` script automatically:

- Installs pixi package manager
- Sets up all project dependencies
- Configures pre-commit hooks
- Prepares the development environment

**Quick Start with Claude Code:**
1. Open this repository in Claude Code online
2. The environment sets up automatically via the SessionStart hook
3. Claude can immediately run commands like `pixi run test`, `pixi run lint`, etc.

**Manual activation (if needed):**
```bash
source .claude/activate.sh
```

See [.claude/README.md](.claude/README.md) for detailed information about the Claude Code configuration.

# Github setup

There are github workflows for CI, codecov and automated pypi publishing in `ci.yml` and `publish.yml`.
Expand Down