3.9 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Overview
Commitly is a Babashka CLI tool for managing commits across multiple independent git repositories within a monorepo structure. It automates committing and pushing changes that span multiple subrepos with a single command.
Architecture
Core Concept
The tool operates on a "monorepo of repos" pattern where:
- The parent directory contains multiple subdirectories, each with its own
.gitdirectory - Each subrepo is an independent git repository (not git submodules)
- Changes often span multiple repositories and need consistent commit messages
Code Structure
The entire implementation is a single Babashka script (commitly) with these key functions:
find-subrepos- Discovers all directories containing.gitin the current directoryhas-changes?- Usesgit status --porcelainto detect uncommitted changescommit-changes- Executesgit add -Aandgit commit -mfor a repopush-changes- Executesgit pushfor a repocommitly- Main orchestration function that coordinates the workflow-main- CLI argument parsing and entry point
Workflow
- Scan current directory for subdirectories with
.gitfolders - Filter to only repos with uncommitted changes
- For each modified repo: stage all changes and commit with provided message
- If
-pflag is present, push each successfully committed repo - Report success/failure for each repository
Common Commands
Basic Usage
# Commit changes across all modified subrepos
./commitly "commit message"
# Commit and push changes
./commitly -p "commit message"
# Push only (no commit) - useful after manual commits
./commitly -p
Running via Babashka Tasks
# Alternative way to run using bb.edn tasks
bb run "commit message"
Development
The script is self-contained with no external dependencies beyond Babashka standard library (babashka.process, babashka.fs). To modify:
- Edit the
commitlyscript directly - Test changes by running
./commitlywith test arguments - The script is executable via shebang
#!/usr/bin/env bb
Important Implementation Details
Error Handling
- Each repository operation is independent - one failure doesn't stop others
- Failed commits/pushes are collected and reported at the end
- Non-zero exit code (1) if any operations fail
- Empty commit message validation prevents accidental empty commits
Special -p Flag Behavior
The -p flag has dual behavior:
- With commit message: commits then pushes
- Without commit message: pushes only (skips committing)
This allows workflows like:
# Manual commits in individual repos, then bulk push
cd service-manager && git commit -m "specific message"
cd ../www && git commit -m "different message"
cd ..
./commitly -p # Push all repos
Process Execution
Uses babashka.process/shell with:
:continue true- Allows capturing errors without throwing exceptions:dir- Sets working directory for each git command:out :stringand:err :string- Captures output for reporting
Context: Monorepo Usage
This tool is designed for the ajet-industries monorepo which contains:
service-manager/- Clojure orchestration servicewww/- Clojure dashboard websitegateway/- Nginx reverse proxy configurationcommitly/- This tool itself- Other independent service repos
Each subrepo has its own git remote and CI/CD pipeline (Gitea Actions). When a cross-cutting change is made (e.g., updating CLAUDE.md files, shared configuration), commitly ensures all affected repos get consistent commit messages.
Skills Integration
The skills/ directory contains documentation for Claude Code skills. When working on commitly functionality or explaining its usage to users, reference skills/commitly.md for detailed usage patterns and examples.