Git Built-in Workflows¶
The Git plugin ships three workflows: one for commit creation and push automation, one for merging a branch into another one, and one for switching to another local branch.
commit-ai¶
Creates a commit from the current working tree using an AI-generated commit message, then pushes it.
Source workflow: plugins/titan-plugin-git/titan_plugin_git/workflows/commit-ai.yaml
Default flow¶
git.get_statusbefore_commithookgit.show_uncommitted_diff_summarygit.ai_generate_commit_messagegit.create_commitgit.push
Hooks¶
before_commit: inject validation or preparation steps before the commit is created
Typical extension points¶
- run lints before committing
- run tests before committing
- collect extra project context before AI commit message generation
Example extension¶
extends: "plugin:git/commit-ai"
hooks:
before_commit:
- id: lint
name: "Run Ruff"
command: "poetry run ruff check ."
on_error: fail
Related public steps¶
get_statusshow_uncommitted_diff_summaryai_generate_commit_messagecreate_commitpush
merge-branch¶
Merges another branch into the branch you are on, or into any other local branch via target_branch. When the merge conflicts, it hands the terminal to the configured interactive AI CLI so you can resolve the conflicts, then finishes the merge when you exit.
The merge never moves HEAD: the source branch is fetched and merged through its remote-tracking ref, so a failure at any point leaves you on the branch the merge lands on. The single exception is target_branch: resolve_merge_target checks that branch out, and only after everything that could refuse the merge has passed, so a refused merge still leaves you where you were.
Source workflow: plugins/titan-plugin-git/titan_plugin_git/workflows/merge-branch.yaml
Parameters¶
| Param | Default | Meaning |
|---|---|---|
target_branch |
"" |
Branch the merge lands on. Empty means the one already checked out; anything else is checked out first. |
source_branch |
"" |
Branch to merge. Empty means the base branch configured for the project (plugins.git.main_branch). |
remote |
"origin" |
Remote the source branch is fetched from. |
merge_commit_no_verify |
true |
Skip pre-commit and commit-msg hooks on the merge commit. Deliberately not no_verify: that key is read by create_commit, and ctx.data is shared with workflows nested from the hooks. |
Default flow¶
before_mergehookgit.resolve_merge_target(switches totarget_branchwhen one is given)git.fetch_merge_sourcegit.merge_source_branchcore.ai_code_assistant(skips itself when there are no conflicts)git.complete_mergegit.push(asks first; skips itself when there is nothing to push)after_mergehook
Behavior¶
- Working tree must be clean. The workflow exits before touching anything if there are uncommitted changes. A merge on a dirty tree cannot be rolled back safely once it conflicts.
- Merging into another branch. With
target_branchset, the source branch, the dirty tree and "cannot merge a branch into itself" are all checked against that target before the checkout, so a merge that will not happen never moves you. - No conflicts: git commits the merge itself with the message it suggests. Steps 5 and 6 skip.
- Conflicts: the conflicted files are listed, the AI CLI is launched with a prompt describing them, and on exit
complete_mergerunsgit add --allplus a commit with git's prepared merge message. - Conflicts still unresolved on exit: you are asked whether to abort the merge (restoring the previous state) or commit as-is. "Unresolved" is decided by the file content, not by the index, so a file the AI CLI fixed without staging counts as resolved.
- Pushing: the last step offers to push the branch, so the merge reaches the remote (and any PR on it) without a second workflow. It asks before pushing, skips itself when the branch has nothing unpushed, and never runs at all when the merge was aborted — an abort exits the workflow. Set
confirm_push: falseto push without asking. - Hooks on the merge commit: skipped by default (
no_verify: true). The commit only carries git's own merge message, and a hook that fails at that point leaves the merge stopped with everything staged. Setno_verify: falseto run them, or lint from theafter_mergehook, where a failure no longer blocks the merge.
Hooks¶
before_merge: overridesource_branchor run pre-merge validationafter_merge: run anything that depends on the merge result, for example tests or a push
Example: always merge develop¶
Example: run the project's own commit workflow after the merge¶
The merge commit itself always uses git's prepared merge message. Anything committed after the merge — an auto-corrected lint fix, a regenerated lockfile — is an ordinary commit, so route it through the project's commit workflow instead of duplicating commit logic here:
extends: "plugin:git/merge-branch"
hooks:
after_merge:
- id: verify
name: "Verify the merged code"
command: "./gradlew detekt --auto-correct"
on_error: continue
- id: commit_fixes
name: "Commit fixes"
workflow: "commit-ai"
Nested workflows resolve through the registry, so a commit-ai overridden in .titan/workflows/ wins over the plugin's version.
Two things to know before relying on this:
- The nested commit workflow cannot double as the verification.
commit-airunsget_statusfirst, before itsbefore_commithook, andget_statusexits when the working tree is clean. After a successful merge commit the tree is clean, so the nested workflow exits at its first step and any lint injected inbefore_commitnever runs. Put the verification inafter_mergeitself, as above. - The verification has to modify files for the commit step to do anything. A report-only linter leaves nothing to commit, so the nested workflow exits harmlessly. An
Exitinside a nested workflow stops only that workflow, so the merge is unaffected either way.
Note that ctx.data is shared with nested workflows: a key set by merge-branch is visible to the steps of the workflow you nest.
Related public steps¶
resolve_merge_targetfetch_merge_sourcemerge_source_branchcomplete_merge
switch-branch¶
Switches to another local branch. The branches you worked on most recently are offered first: the ones HEAD was switched to (from the reflog), then the rest by the date of their last commit, each one shown with how long ago that was and where it pushes.
The workflow refuses to move while the working tree has modified or staged files - those would travel to the other branch and mix with its work. Untracked files follow HEAD anywhere, so they never block it.
Source workflow: plugins/titan-plugin-git/titan_plugin_git/workflows/switch-branch.yaml
Parameters¶
| Parameter | Default | Description |
|---|---|---|
branch |
"" |
Branch to switch to. Empty asks, offering the recently used ones. |
branch_limit |
10 |
How many branches to offer. |
Default flow¶
git.switch_branch
Example extension¶
Related public steps¶
switch_branch