CLI tool that generates Conventional Commits messages from git diffs using local LLMs via Ollama. Single-file bash script, privacy-first (no cloud APIs).
- Bash 4.0+ (single script:
faff.sh) - Ollama API for local LLM inference
- Dependencies:
curl,jq,bc, coreutils (timeout)
# Run directly (requires staged git changes and Ollama running)
./faff.sh
# With custom model
FAFF_MODEL="qwen2.5-coder:3b" ./faff.sh
# Validate script syntax
bash -n faff.sh| Variable | Default | Purpose |
|---|---|---|
FAFF_MODEL |
qwen2.5-coder:7b |
Ollama model to use |
FAFF_TIMEOUT |
180 |
API timeout in seconds |
OLLAMA_HOST |
localhost |
Ollama server hostname |
OLLAMA_PORT |
11434 |
Ollama server port |
OLLAMA_PROTOCOL |
http |
Protocol for Ollama connection (http/https) |
OLLAMA_TOKEN |
(empty) | Optional API token for authenticated Ollama servers |
- Bash script with
#!/usr/bin/env bash - Use
function name()syntax for function declarations - Use
localfor function-scoped variables - Use
readonlyfor constants - Error messages to stderr via
error_exitfunction - Spinner feedback for long-running operations
Follow Conventional Commits 1.0.0 specification:
<type>: <description>
[body]
Types: feat, fix, build, chore, ci, docs, i18n, perf, refactor, revert, style, test
- Description: imperative mood, max 72 chars, no period, no capitalisation
- Body: explains what and why, uses
-for bullet points
Single script (faff.sh) with these key functions:
main()- Entry point, orchestrates workflowcheck_dependencies()- Validates bash version and required toolsget_git_diff()- Retrieves staged changesget_allowed_scopes()- Detects commitlint config and extracts allowed scopesgenerate_commit_message()- Calls Ollama API with structured JSON outputcheck_model()- Auto-downloads missing modelsconfirm_commit()- Interactive prompt (y/n/e for yes/no/edit)
The script embeds a detailed system prompt for Conventional Commits compliance, using Ollama's structured output format to ensure consistent JSON responses.
Commitlint: Auto-detects .commitlintrc.json or commitlint.config.json and extracts scope-enum to constrain LLM scope selection. Passive feature - no impact if no config exists.
- Must run inside a git repository with staged changes
- Requires Ollama service running and accessible
- Bash 4.0+ required (uses associative array syntax)
- No external config files - all configuration via environment variables