This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
DevKit is a Python CLI tool for daily development routines (Rails + Postgres), designed with a GitHub-like UX and documentation friendly for agents/LLMs. It manages Rails applications and their database workflows with structured JSON output for automation.
Setup:
poetry install # Install dependenciesTesting and Quality:
pytest -q # Run tests
ruff check devkit # Lint code
ruff format devkit # Format code
ruff format --check devkit # Check formattingBuild and Install:
poetry build # Build package
pipx install . # Install locallyDocumentation:
python scripts/generate_reference.py > docs/commands.md # Generate command reference
mkdocs build # Build documentation
mkdocs serve -a localhost:8000 # Serve docs locally-
CLI Entry Point:
devkit/cli.py- Main Typer application with three sub-commands:service- Manage Rails app services and their configurationsdb- Database operations (reset, restore from backups)meta- Introspection/metadata commands for agents
-
Configuration:
devkit/config_model.py+devkit/services.py- Config stored in
~/.devkit/config.yml - Services define Rails app paths, backup locations, DB connection details
- Uses Pydantic models for validation
- Config stored in
-
Rails Integration:
devkit/rails.py- Detects Rails binary (rails/bin/rails)
- Infers database names from Rails configuration
-
Database Operations:
devkit/postgres.py- Supports both pg_restore and psql for backups
- Auto-detects backup format and chooses appropriate tool
context.py- Global context for CLI options (format, verbosity, etc.)iofmt.py- JSON envelope format for structured outputux.py- Rich console utilities for tables and confirmationsshell.py- Command execution utilitiesdoctor.py- System diagnosticsintrospect.py- CLI metadata generation for agents
For LLM/agent integration, use:
devkit meta reference --format json- Get complete CLI structuredevkit meta describe --format json- Get command descriptions- Use
--format json --no-interactive --yesfor deterministic execution
Exit codes follow standard conventions (0=success, 1=error, etc.)
Services are managed through the CLI and stored in YAML format at ~/.devkit/config.yml. Each service includes:
- Rails application path
- Database backup path
- Environment (development/production/etc.)
- Database connection details (user, host, port)
- Runtime: typer, rich, PyYAML, pydantic
- Development: pytest, ruff, mkdocs, mkdocs-material
- Python: 3.11+
- External tools: Rails, PostgreSQL client tools (psql, pg_restore)