This document covers the development workflow, testing structure, and automation hooks for campus-cli.
- Python 3.11
- Poetry (for dependency management)
- Git
# Install dependencies
poetry install
# Activate virtual environment (optional)
poetry shellThis project uses ruff for formatting and linting. Formatting is automated via Claude Code hooks (see Hooks below).
Manual formatting commands:
# Format a file
poetry run ruff format <file>
# Format all files
poetry run ruff format .
# Check formatting without making changes
poetry run ruff format --check .# Run linter
poetry run ruff check .
# Fix auto-fixable issues
poetry run ruff check --fix .tests/
├── smoke/ # Quick smoke tests (run before commits)
├── integration/ # Integration tests
└── unit/ # Unit tests
# Run smoke tests only (fast)
poetry run pytest tests/smoke -q
# Run all tests
poetry run pytest
# Run with verbose output
poetry run pytest -v
# Run specific test file
poetry run pytest tests/unit/test_config.py
# Run with coverage
poetry run pytest --cov=campus_cli --cov-report=html| Level | Command | When it runs |
|---|---|---|
| Smoke | poetry run pytest tests/smoke -q |
Before git commit (via hook) |
| Full | poetry run pytest -q |
Before git push (via hook) |
This project uses Claude Code hooks to automate quality checks. These are configured in .claude/settings.local.json.
| Hook | Trigger | Command | Purpose |
|---|---|---|---|
| post-edit | After file write/edit | poetry run ruff format "$FILE" |
Auto-format Python files |
| pre-commit | Before git commit |
poetry run pytest tests/smoke -q |
Run quick smoke tests |
| pre-push | Before git push |
poetry run pytest -q |
Run full test suite |
- post-edit: Runs immediately after any file is written or edited. Formats the file using ruff.
- pre-commit: Blocks commit if smoke tests fail. Tests run quietly (
-qflag). - pre-push: Blocks push if any test fails. Full test suite runs quietly.
If you need to bypass hooks temporarily:
# Skip pre-commit hook
git commit --no-verify
# Skip pre-push hook
git push --no-verifyUse --no-verify sparingly and only when you have a good reason (e.g., documentation-only commits).
campus-cli/
├── campus_cli/ # Main package
│ ├── __init__.py
│ ├── cli.py # CLI entry point (Typer app)
│ ├── config.py # Configuration management
│ └── credentials.py # Credential storage
├── tests/ # Test suite
├── docs/ # Documentation
├── .claude/ # Claude Code configuration
│ └── settings.local.json # Hooks and permissions
├── pyproject.toml # Poetry configuration
└── README.md
- Define the command in
campus_cli/cli.pyusing Typer decorators - Add unit tests in
tests/unit/ - Add integration tests in
tests/integration/(if applicable) - Run
poetry run ruff format .to format new code - Run
poetry run pytestto verify tests pass
# Update a specific dependency
poetry add package_name@latest
# Update all dependencies
poetry update
# Lock file changes (commit poetry.lock)
git add poetry.lock pyproject.toml
git commit -m "chore: update dependencies"# Run with pdb debugger
poetry run pytest --pdb
# Show print output
poetry run pytest -s
# Stop on first failure
poetry run pytest -x
# Run specific test with verbose output
poetry run pytest -v tests/unit/test_config.py::test_function_name