Skip to content

Commit 94fab02

Browse files
authored
Merge pull request #103 from blooop/claude/setup-claude-template-018pEspHaNhB7a1XgjDiMd1B
Set up template for Claude integration
2 parents c4fc62c + 46b2e99 commit 94fab02

File tree

4 files changed

+153
-0
lines changed

4 files changed

+153
-0
lines changed

.claude/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Claude Code Configuration
2+
3+
This directory contains configuration for using this project with Claude Code, particularly in the online environment.
4+
5+
## SessionStart Hook
6+
7+
The `hooks/SessionStart` script automatically runs when a new Claude Code session begins. It:
8+
9+
1. **Installs pixi** (if not already installed) - The package and environment manager
10+
2. **Installs project dependencies** - All Python packages and tools defined in `pyproject.toml`
11+
3. **Sets up pre-commit hooks** - For automatic code quality checks
12+
4. **Configures git** - Sets up merge drivers for lockfiles
13+
14+
## Usage with Claude Code Online
15+
16+
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.
17+
18+
### Available Commands
19+
20+
Once setup is complete, Claude can use these pixi tasks:
21+
22+
#### Testing & Quality
23+
- `pixi run test` - Run pytest tests
24+
- `pixi run coverage` - Run tests with coverage report
25+
- `pixi run lint` - Run ruff and pylint linters
26+
- `pixi run format` - Format code with ruff
27+
28+
#### CI Tasks
29+
- `pixi run ci` - Run full CI pipeline (format, lint, test, coverage)
30+
- `pixi run fix` - Auto-fix common issues (update lock, format, lint)
31+
32+
#### Pre-commit
33+
- `pixi run pre-commit` - Run all pre-commit hooks
34+
- `pixi run pre-commit-update` - Update pre-commit hook versions
35+
36+
### How It Works
37+
38+
1. **First session**: The hook installs pixi and all dependencies (may take a few minutes)
39+
2. **Subsequent sessions**: The hook verifies the environment is ready (much faster)
40+
3. **Environment activated**: All pixi commands are available to Claude
41+
42+
### Troubleshooting
43+
44+
If you encounter issues:
45+
46+
1. **Dependencies not found**: Run `pixi install` manually
47+
2. **Lockfile conflicts**: Run `pixi run update-lock`
48+
3. **Pre-commit issues**: Run `pixi run pre-commit-update`
49+
4. **Full reset**: Delete `.pixi` directory and restart session
50+
51+
### Customization
52+
53+
You can modify `hooks/SessionStart` to:
54+
- Install additional tools
55+
- Run custom setup scripts
56+
- Configure environment variables
57+
- Set up external services
58+
59+
## Learn More
60+
61+
- [Claude Code Documentation](https://docs.claude.com/claude-code)
62+
- [Pixi Documentation](https://pixi.sh)
63+
- [Project README](../README.md)

.claude/activate.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
# Source this file to activate the pixi environment in your current shell
3+
# Usage: source .claude/activate.sh
4+
5+
# Add pixi to PATH
6+
export PATH="$HOME/.pixi/bin:$PATH"
7+
8+
# Optional: Activate pixi shell if available
9+
if command -v pixi &> /dev/null; then
10+
echo "✅ Pixi environment activated"
11+
echo "💡 Available commands:"
12+
echo " pixi run test - Run tests"
13+
echo " pixi run lint - Run linters"
14+
echo " pixi run format - Format code"
15+
echo " pixi run ci - Run full CI"
16+
pixi task list --summary 2>/dev/null || true
17+
else
18+
echo "⚠️ Pixi not found. Please run .claude/hooks/SessionStart first."
19+
fi

.claude/hooks/SessionStart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# SessionStart hook for Claude Code online environment
3+
# This script sets up the Python development environment using pixi
4+
5+
set -e
6+
7+
echo "🚀 Setting up Python Template environment..."
8+
9+
# Check if pixi is installed
10+
if ! command -v pixi &> /dev/null; then
11+
echo "📦 Installing pixi..."
12+
curl -fsSL https://pixi.sh/install.sh | bash
13+
14+
# Add pixi to PATH for current session
15+
export PATH="$HOME/.pixi/bin:$PATH"
16+
17+
# Source bashrc to get pixi in PATH (if bashrc was updated)
18+
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"
19+
20+
echo "✅ Pixi installed successfully"
21+
else
22+
echo "✅ Pixi already installed"
23+
fi
24+
25+
# Ensure pixi is in PATH for this session
26+
export PATH="$HOME/.pixi/bin:$PATH"
27+
28+
# Install project dependencies
29+
echo "📦 Installing project dependencies..."
30+
pixi install
31+
32+
# Run pre-commit installation
33+
echo "🔧 Setting up pre-commit hooks..."
34+
pixi run pre-commit install || echo "⚠️ Pre-commit installation skipped (optional)"
35+
36+
# Set up git merge driver for lockfiles
37+
echo "🔧 Configuring git merge driver..."
38+
pixi run setup-git-merge-driver || true
39+
40+
echo "✅ Environment setup complete!"
41+
echo ""
42+
echo "Available pixi tasks:"
43+
pixi task list
44+
echo ""
45+
echo "💡 Common commands:"
46+
echo " pixi run test - Run tests"
47+
echo " pixi run lint - Run linters"
48+
echo " pixi run format - Format code"
49+
echo " pixi run ci - Run full CI pipeline"
50+
echo ""

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ If you want to use docker you may want to run the `scripts/setup_host.sh` script
3636

3737
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/)
3838

39+
# Claude Code Online Support
40+
41+
This template includes built-in support for [Claude Code](https://docs.claude.com/claude-code) online environment! The `.claude/hooks/SessionStart` script automatically:
42+
43+
- Installs pixi package manager
44+
- Sets up all project dependencies
45+
- Configures pre-commit hooks
46+
- Prepares the development environment
47+
48+
**Quick Start with Claude Code:**
49+
1. Open this repository in Claude Code online
50+
2. The environment sets up automatically via the SessionStart hook
51+
3. Claude can immediately run commands like `pixi run test`, `pixi run lint`, etc.
52+
53+
**Manual activation (if needed):**
54+
```bash
55+
source .claude/activate.sh
56+
```
57+
58+
See [.claude/README.md](.claude/README.md) for detailed information about the Claude Code configuration.
59+
3960
# Github setup
4061

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

0 commit comments

Comments
 (0)