# chamoji commit

> Write a commit with the composer: a gitmoji, a scope, a title, a body, why you made the change, and whether it breaks anything.

Source: https://www.chamoji.dev/docs/commands/commit

Write a commit with the composer. It asks for a gitmoji, a scope, a title, a body, why you made the change and whether it breaks anything, then commits what you staged. The changelog can sort a commit like this on its own.

[CHANGES YOUR REPO] [MONOREPO-AWARE]

> **Note:** The composer needs a terminal. In a script or CI, use `git commit -m`.

## What it does, in order

CHANGES YOUR REPO · chamoji commit

1. **Opens the composer.** On the terminal, even when stdin isn’t one, as in a git hook. With no terminal at all it stops and exits 2.
2. **Asks.** A gitmoji from a search list, then the scope, the title, a body, why, and whether it breaks anything. Enter moves on, Esc goes back and Ctrl-C cancels.
3. **Stamps the workstream.** When a workstream is active in this worktree, it adds its `Workstream:` line.
4. **Commits.** With `git commit`, so your git hooks and settings apply. It prints what git prints.

## The questions

| Name | Type | Description |
| --- | --- | --- |
| `Gitmoji` | | Type `bug`, `fix` or a few letters such as `spk`, and pick with the arrow keys. With [Jev’s suggestions](https://www.chamoji.dev/docs/guides/writing-commits.md) turned on, its three likeliest gitmojis show above the list, or at the top of it when Jev is very sure. |
| `Scope` | optional | Written as `(scope):` after the gitmoji. Skipped when `scopePrompt` is false. |
| `Title` | | The rest of the subject line. Its first letter is capitalized unless `capitalizeTitle` is false. |
| `Body` | optional | More lines after the subject. Skipped when `messagePrompt` is false. |
| `Why?` | optional | Kept as a `Why:` trailer, so `chamoji why` and project memory can find it later. |
| `Breaking change?` | y/N | No by default. Yes asks what breaks, and adds a `BREAKING CHANGE:` trailer with your answer, or the title when you leave it empty. |

In a repo with release units, a line under the header says which units the staged change releases with, and which it only rides along to. When it releases none of its own, a last question offers to release those units now, with a `Release:` trailer for each.

The settings come from `.gitmojirc.json`, or the `gitmoji` key in `package.json`, as gitmoji-cli reads them. `emojiFormat: "code"` writes `:sparkles:` instead of ✨, and `autoAdd` stages everything first. [Config](https://www.chamoji.dev/docs/reference/config.md#settings-kept-elsewhere) lists them with their defaults.

## Arguments

`chamoji commit` takes no arguments.

## Flags

| Name | Type | Description |
| --- | --- | --- |
| `--all, -a` | boolean | Commit every change to tracked files, as `git commit -a` does, not only what you staged. New files still need `git add`. With `autoAdd` set, every change is staged first either way. |
| `--no-update-check` | boolean | Don’t check npm for a newer chamoji. See [the update notice](https://www.chamoji.dev/docs/install.md#the-update-notice). |

## Common combinations

- `chamoji commit`: Commit what you staged.
- `chamoji commit -a`: Commit every change to tracked files.
- `chamoji hook install`: Open the same composer on a plain `git commit`.

## Output

These are from real runs in a small repo called widgets. The composer draws in place; each block is one screen.

Typing `bug` narrows the list:

```txt title="Gitmoji"
 chamoji commit  Enter next · Esc back · Ctrl-C cancel

 Gitmoji › bug
 ❯ 🐛 bug                         Fix a bug.
   🏗️ building_construction       Make architectural changes.
```

The subject line builds up under the header as you answer. On the last question, Enter takes the default, No, and git commits:

```txt title="Breaking change?"
 chamoji commit  Enter next · Esc back · Ctrl-C cancel
 🐛 (picker): Keep the month when a range is cleared

 Breaking change? (y/N) ›
[main ed9b8a1] 🐛 (picker): Keep the month when a range is cleared
 1 file changed, 1 insertion(+)
```

The answer to “Why?” is a trailer:

```txt title="git log -1 --format=%B"
🐛 (picker): Keep the month when a range is cleared

Why: Clearing a range jumped back to today
```

In a repo with two apps, a fix to the shared `packages/ui` releases neither app on its own, so the composer offers to release both:

```txt title="Release mobile, web now?"
 chamoji commit  Enter next · Esc back · Ctrl-C cancel
 rides along to: mobile, web
 🐛 (ui): Keep the button label on one line

 Release mobile, web now? (y/N) ›
[main 1e23054] 🐛 (ui): Keep the button label on one line
 1 file changed, 1 insertion(+)
```

Yes adds the trailers:

```txt title="git log -1 --format=%B"
🐛 (ui): Keep the button label on one line

Release: mobile
Release: web
```

Ctrl-C at any point commits nothing:

```txt title="Ctrl-C"
Cancelled; nothing was committed.
```

Without a terminal:

```txt title="chamoji commit"
chamoji: commit needs a terminal to ask on; in scripts, use git commit -m
```

## Exit codes

| Name | Type | Description |
| --- | --- | --- |
| `0` | | It committed. |
| `2` | | There is no terminal to ask on. |
| `1` | | You cancelled, git refused the commit, or this isn’t a git repo. |

[Exit codes](https://www.chamoji.dev/docs/reference/exit-codes.md) has every command’s codes.

## Related

- [Writing commits](https://www.chamoji.dev/docs/guides/writing-commits.md): The composer, the hook, and Jev’s suggestions.
- [hook](https://www.chamoji.dev/docs/commands/hook.md): Open the composer on a plain git commit.
- [ws](https://www.chamoji.dev/docs/commands/ws.md): Workstreams, and the line that stamps their commits.
- [How commits are read](https://www.chamoji.dev/docs/reference/how-commits-are-read.md): How the changelog sorts what you wrote.
