This repository contains developer tools that help teams work faster with AI hosted by mittwald in Germany.
mittwald AI hosting is especially useful for developer workflows that need:
- short feedback loops during coding
- reliable automation for continuous integration
- GDPR-aware, Germany-hosted infrastructure for AI-assisted development
AI-powered, well-formed git commit messages and branch names, generated from your staged changes.
Good commit messages are important but easy to postpone. AI-assisted generation helps you:
- keep commit history understandable and review-friendly
- consistently follow the Conventional Commits format
- reduce time spent writing commit text
- improve consistency across contributors
The same applies to branch names: git branch-ai names a branch after the changes that you are about to commit, in the form <type>/<short-description>.
The installer script sets up and configures cmai so commit messages and branch names can be generated using mittwald AI.
See https://github.com/mrgoonie/cmai for more details.
The installer first asks what to set up. Both features are checked. Move with the arrow keys, toggle a feature with space and confirm with enter:
- Commit messages: a
prepare-commit-msghook, so thatgit commitstarts with a generated message. - Branch names: the command
git branch-ai, which creates a branch with a generated name.
The installer does not remove a feature that you uncheck. It leaves that feature as it is.
The installer shows each change before it applies the change. Steps 1 to 3 are for both features, steps 4 to 6 for the commit messages, steps 7 and 8 for the branch names:
- Installs the latest
cmai, ifcmaiis missing or too old. If this installer or the install script ofcmaiinstalledcmai, a newer version replaces it:cmaihas no version number, so the installer compares the installed script with the latest one. The installer first checks the downloaded script for content thatcmaihas no need for, such as unknown hosts or encoded code, and asks before it installs a script with such content. A newer version with such content does not replace the installedcmai, and a failed download keeps it. This check is a heuristic, not a guarantee. The installer needssudoonly if it cannot write the links/usr/local/bin/cmaiand/usr/local/bin/git-branch-aiitself. - Asks for your mittwald AI API key, or takes the key from
MITTWALD_AI_API_KEY, and stores the key (see Where the API key is stored). - Configures
cmaito use mittwald AI. - Installs a
prepare-commit-msghook into your git template directory (default~/.git-templates). On Linux and macOS, the hook is in~/git-commit-ai/prepare-commit-msgand the template directory has a link to it.git initandgit clonecopy this link into a repository, so that an update of the hook reaches every repository. - Replaces copies of the hook from this installer with links, in the repository of the current directory and in the repositories below each directory of
--repos(see Update the hook in your repositories). On Windows, it updates these copies instead. - Optionally adds a snippet to your Vim config, so that
:qaborts the commit. - Installs the command
git branch-ai(see Create a branch). The script is~/git-commit-ai/git-branch-ai. The directory ofcmaigets a link to it, so that git finds it asgit branch-ai. Agit-branch-aiin that directory from another source stays, unless you agree to replace it. - Optionally adds a Git alias for the command. If you say yes, the installer asks for its name, with
baias the default. The alias names the script with its path, so it also works where the command is not on thePATH. An existing alias at that name stays unless you agree to replace it.
| System | Requirements |
|---|---|
| Linux | bash, git, curl, jq |
| macOS | git, curl and the bash of macOS; jq for example from brew install jq |
| Windows | Git for Windows; jq for example from winget install jqlang.jq |
On Windows, run the installer in Git Bash. The hook then works for every commit, also from PowerShell or an IDE. The installer puts cmai and git-branch-ai into ~/bin, which Git Bash has on its PATH. PowerShell and most IDEs do not have ~/bin on the PATH. Use the alias git bai there.
The installer stores the API key in the keychain of your system, if both of these are true:
- Your system has a keychain that the installer can use: the macOS Keychain, the Windows Credential Manager, or on Linux a keyring with the
secret-toolcommand (GNOME Keyring, KWallet). - Your
cmaican take the API key from the environment variableCMAI_API_KEY. The hook reads the key from the keychain and passes it tocmaithis way, so that the key is never in a file.
Otherwise the key is in ~/.config/git-commit-ai/config, which only you can read. When you run the installer again and the two conditions are true, the installer moves the key from that file into the keychain.
To run cmai yourself with a key from the keychain, pass the key in the same way, for example on Linux:
CMAI_API_KEY="$(secret-tool lookup service git-commit-ai account api-key)" cmaicurl -fsSL https://github.com/mittwald/ai-developer-tools/raw/refs/heads/main/install-git-commit-ai.sh | bashOn Windows, run this command in Git Bash.
Make sure to run git init in your existing repository.
To read the script before you run it, download the script first:
curl -fsSLO https://github.com/mittwald/ai-developer-tools/raw/refs/heads/main/install-git-commit-ai.sh
less install-git-commit-ai.sh
bash install-git-commit-ai.shTo install or update without prompts, for example from a script, pass --non-interactive. Every step then takes its default answer. The default answer keeps an existing prepare-commit-msg hook from another source and does not install a cmai script with unexpected content. In both cases the installer stops. The default answer also keeps a git-branch-ai command and a bai alias from another source. The installer then continues.
curl -fsSL https://github.com/mittwald/ai-developer-tools/raw/refs/heads/main/install-git-commit-ai.sh | bash -s -- --non-interactiveTo set up one feature only, pass --features commit or --features branch. With --features, the installer does not ask what to set up:
curl -fsSL https://github.com/mittwald/ai-developer-tools/raw/refs/heads/main/install-git-commit-ai.sh | bash -s -- --features branchWithout prompts, the installer takes the API key from MITTWALD_AI_API_KEY. Do not write the key into the command line, because your shell history keeps it. Read it without echo instead:
read -rs MITTWALD_AI_API_KEY && export MITTWALD_AI_API_KEYgit init does not replace a hook that a repository already has. A repository with a copy of the hook from an older installer keeps that copy. To replace these copies with links to the hook, pass the directories with your repositories to --repos:
curl -fsSL https://github.com/mittwald/ai-developer-tools/raw/refs/heads/main/install-git-commit-ai.sh | bash -s -- --repos ~/workspaceThe installer looks for repositories up to 5 levels below each directory. It changes only hooks from this installer. A repository without the hook, with a hook from another source, or with its own core.hooksPath stays as it is.
To link the hook in one repository, run this command in the repository:
ln -sf ~/git-commit-ai/prepare-commit-msg "$(git rev-parse --git-path hooks)/prepare-commit-msg"On Windows, copy the hook instead:
cp ~/.git-templates/hooks/prepare-commit-msg "$(git rev-parse --git-path hooks)/"Stage your changes, then run the command in your repository:
git branch-ai # or the alias: git baimittwald AI generates a name from the staged changes, such as fix/api-error-handling. On a terminal, the command shows the name and you can change it. Press enter to create the branch and to switch to it. Your changes stay staged, ready for git commit.
| Option | Effect |
|---|---|
-u, --unstaged |
Use the unstaged and untracked changes, not the staged ones |
-d, --diff <diff> |
Use the changes of git diff <diff>, for example main...HEAD |
-p, --print |
Print the name and do not create the branch |
-y, --yes |
Do not ask for the name before the branch is created |
-h |
Show the help (git itself takes --help and looks for a manual page) |
- Run
git initin your existing repository, if not done already. - Stage your changes (
git add ...). - Optionally create a branch for them (
git branch-ai). - Commit your changes, omitting the commit message (
git commit). cmaiuses mittwald AI to generate a commit message.- Review and adjust the message if needed in your editor.
- 🥳
- The hook and
git branch-aisend the diff of your staged changes to mittwald AI. Do not stage secrets. With--unstagedor--diff,git branch-aisends those changes instead. - The hook never blocks a commit. It tries up to 3 times, with time limits of 30, 45 and 68 seconds. If the generation fails, the hook prints the reason and your editor opens without a generated message.
git branch-aihas the same time limits. If the generation fails, it prints the reason and creates no branch. It also creates no branch if a branch of that name exists.- While you wait, the hook shows a status line such as
Reading between the hunks..., andgit branch-aione such asNaming things, the hard part.... The bold, fully colored part of the line grows with the elapsed share of the time limit. When the message is ready, the line becomesReading between the hunks... Read it all.. SetNO_COLOR=1for plain text. - Press
Ctrl-Cto stop the generation and the commit, or the generation of the branch name.
This repository is intended as a collection point for developer productivity tooling around mittwald AI hosting.
Check back later.
Please use this project's issue tracker to report specific suggestions or issues.
For security-related issues, please refrain from using the public issue tracker or discussion board. Have a look at the security policy, instead.
Also, please note that the issue tracker is not a support channel for mittwald's hosting products. Please use our regular support options to receive product support.
We are happy to accept external contributions to our documentation. See the Contribution guide for more information.