Skip to content

Contributing

MuseFlow is a personal project and showcase, but it is set up so that a change can be made, checked and reviewed the same way each time. This page is the short version; the rules themselves live in AGENTS.md, with the testing rules in tests/AGENTS.md.

Setup

Requirements and step-by-step installation (Python 3.14, uv, Docker Compose, direnv, a Spotify developer app and an OpenRouter API key) are in the README. In short:

make install        # dependencies and pre-commit hooks
cp .env.example .env   # then fill in the secrets
make up-db          # PostgreSQL
make db-upgrade     # apply the schema

Make targets

Target What it does
make install Install dependencies and the pre-commit hooks
make lint Ruff check and format, mypy, deptry (mutating: applies fixes)
make lint-check The same checks without modifying files; what CI runs
make test The full suite with the 100% branch gate (starts PostgreSQL and both WireMock containers, stops them afterwards)
make test-unit Unit tests only; needs no containers
make test-integration Integration tests (real PostgreSQL, WireMock)
make up, make up-db, make up-wiremock, make down Docker Compose services: make up starts the app and the database, WireMock (profile test) starts only for the integration tests
make db-revision Create an Alembic migration
make db-upgrade / make db-downgrade Apply or roll back migrations
make docs-serve Serve this documentation locally with live reload
make docs-build Build the documentation in strict mode, as CI does
make run Start the FastAPI dev server

Run make help for the full list.

Branches and commits

  • Work on a short-lived branch off main, named <type>/<topic> (for example docs/overhaul).
  • Commits follow Conventional Commits: feat:, fix:, refactor:, test:, docs:, chore:, with an optional scope (feat(llm): check the configured models against the OpenRouter catalog). The convention has been used since the V2 line started in May 2026; earlier history uses free-form messages.
  • Everything written for the repository is in English: code, comments, docstrings, log messages, CLI help, tests, commit messages and docs.
  • Commits made with an AI assistant carry a Co-Authored-By trailer.
  • Dependency updates arrive as a single weekly Dependabot PR; patch and minor updates are auto-merged, major ones are reviewed by hand (see Quality & testing).

Pull request checklist

  • make lint-check passes: Ruff, mypy and deptry are clean.
  • make test passes with 100% branch coverage; every new branch is covered, error paths by unit tests with AsyncMock, flows by integration tests.
  • New code follows the layering rule: nothing in domain/ imports a framework; use cases receive ports, never build repositories or clients.
  • A test file mirrors its source file under tests/unit and tests/integration, never consolidated; test code is fully typed and uses factories, not helper functions.
  • Schema changes follow migrations/AGENTS.md while in development: initial.py is regenerated, never a new revision, and the PR names the data a reset loses.
  • Logs carry no secrets; user-facing output stays in the CLI callback, not in the *_logic function, except what an interactive prompt shows.
  • An architecture review has been run (/arch-review), and a security review (/security-review) when auth, endpoints or external adapters changed.
  • User-visible behaviour changes update the user guide; structural changes update these technical pages.

Working with Claude Code

The repository is configured for Claude Code, which reads AGENTS.md natively. On top of it:

Need Use
Review a diff before opening a PR /arch-review, and /security-review when auth, endpoints or external adapters changed
Fix failing tests or coverage gaps the test agent (stops after 3 failed attempts and reports options A / B / C)

The human contributor stays responsible for every change: review the diff, run the checks, and decide. The full story and the reasoning are in AI-assisted development.

Notes for tests that touch external APIs

Never add a test that calls the live OpenRouter or Spotify APIs to the default suite. Live tests are marked openrouter_live / spotify_live, are skipped unless opted in, and cost money or use a real account. Use WireMock stubs under tests/assets/wiremock/ and mark the class @pytest.mark.wiremock("spotify") or ("openrouter") so parallel workers do not race on stubs.