This document provides information for developers working on ReqCassette.
-
Clone the repository
-
Install dependencies:
mix deps.get
-
Compile the project:
mix compile
We provide two main aliases for ensuring code quality:
Run this before committing your code. It will:
- Format code - Automatically fixes formatting issues
- Run Credo - Checks code quality with strict mode
- Run tests - Ensures all tests pass
mix precommitThis alias applies formatting changes, so your code will be modified if there are formatting issues.
This is designed for Continuous Integration environments. It will:
- Check formatting - Fails if code is not formatted (doesn't modify files)
- Run Credo - Checks code quality with strict mode
- Run tests - Ensures all tests pass
mix ciThis alias does NOT modify your code - it only checks and will fail if formatting is incorrect.
Credo is configured in .credo.exs. Current settings:
- Strict mode enabled - More rigorous checks
- Line length: 120 characters max (low priority)
- Module docs: Disabled (not required for now)
- Specs: Disabled (not required for now)
- Max complexity: 12
- Max nesting: 3
You can run Credo separately:
# Check for issues
mix credo
# Strict mode
mix credo --strict
# Explain a specific issue
mix credo explain lib/req_cassette/plug.ex:177:7The project uses Elixir's built-in formatter. Configuration is in
.formatter.exs.
Run formatter:
# Apply formatting
mix format
# Check without modifying
mix format --check-formattedmix testmix test test/req_cassette/plug_test.exsmix test test/req_cassette/plug_test.exs:14mix test --traceSome tests require API keys and are skipped by default:
# Run all tests including skipped ones
ANTHROPIC_API_KEY=sk-... mix test --include req_llm# HTTP demo (uses httpbin.org)
mix run examples/httpbin_demo.exs
# ReqLLM demo (requires API key)
ANTHROPIC_API_KEY=sk-... mix run examples/req_llm_demo.exsAlways run mix precommit before committing:
# Make your changes
# ...
# Run precommit (formats, checks, tests)
mix precommit
# Commit your changes
git add .
git commit -m "Your message"Your CI pipeline should run mix ci:
# Example GitHub Actions
- name: Check code quality
run: mix ciThe difference between precommit and ci:
- precommit: Fixes formatting automatically (for local development)
- ci: Only checks formatting, fails if not formatted (for CI/CD)
# Instead of:
Plug.Conn.put_resp_header(conn, "foo", "bar")
# Consider aliasing at the top:
alias Plug.Conn
Conn.put_resp_header(conn, "foo", "bar")This is currently set to :low priority and won't fail the build.
Core dependencies:
req- HTTP clientplug- Web library (for connection handling)jason- JSON encoding/decodingreq_llm- LLM integration
Dev/Test dependencies:
bypass- Mock HTTP server for testingcredo- Code quality checker
README.md- Project overview and quick startSUMMARY.md- Complete project documentationdocs/guides/- User guides (templating, ReqLLM, filtering)DEVELOPMENT.md- This file
- Fork the repository
- Create a feature branch
- Make your changes
- Run
mix precommitto ensure quality - Submit a pull request
If you see "mix test is running in the dev environment", make sure you're using the aliases:
# ❌ Wrong
mix test
# ✅ Correct
mix precommit
# or
mix ciThe aliases are configured with preferred_cli_env to run in the test
environment.
If Credo is flagging too many issues, you can adjust .credo.exs:
# Disable a specific check
{Credo.Check.Readability.ModuleDoc, false}
# Lower priority
{Credo.Check.Design.AliasUsage, priority: :low, exit_status: 0}Make sure you ran mix format locally before pushing:
mix format
git add .
git commit -m "Format code"
git push