magus v0.4.3 is out. See what's new
¶ View generated markdown
6 min read

magus-commit-composition

Short form: 2885 bytes, 35% smaller than the full form's 4453.

Restructure an UNPUSHED branch so each commit is one reviewable idea, using the workspace's own boundaries (project ownership, declared outputs, blast radius) rather than guessing from paths. Use when a branch has accumulated commits in the order the work occurred, before opening a PR, when asked to reconsolidate/squash/reword/clean up commits, or when a reviewer would meet a rename split across commits and a fix buried in a regeneration. Do NOT use on pushed commits, and do NOT use it to write a single message: this decides what goes IN each commit.

Install it, rather than copying from this page:

magus agent install .claude/skills   # writes both forms below

An installed copy carries a provenance stamp, so magus doctor can tell you when a magus upgrade has made it stale. Text copied from this page carries none.

What an installed copy carries

magus agent install writes this frontmatter above the body. magus doctor reads it to report whether your installed skills are current.

field value
license GPL-3.0-or-later
compatibility any-agent
source magus
agent-skill-version 147
knowledge-schema-version 24
skill-content bf2e77ea25ea
skill-variant full

The skill-content digest covers this skill alone, and both forms below report it: they go stale together, never one silently, and a change to another skill does not move it.

The two forms

Both are hand-authored from one source body. The short form is the always-loaded primary - the enumeration dropped, the judgment kept, for the most capable readers rather than the least. The full form is its <name>-full twin, loaded by name when a reader wants the rationale. The bar above shows how much shorter the primary is; switch between them here to see exactly what it gave up. See Skills for how to choose.

magus agent install --tar | tar -xO -f - magus-commit-composition/SKILL.md
# Commit composition

Reviewer reads commits, not diffs.
Decide what belongs in each commit: every commit one idea, accepted or rejected alone.
Use workspace's own boundaries, not directory names.
magus does not rewrite history: shows seams, proves afterwards nothing lost; your VCS edits.

## Two constraints

Only unpushed work eligible; published commits fixed.
Establish unpushed set before planning.

Generated output belongs with source that moved it; split -> source commit fails drift gate.

```sh
magus describe file <changed-path>...
```

Every `output` path joins `source` change that invalidated it.
Commit of all regeneration missed pairing -> fold into causing change.

## Ask workspace for seams

```sh
magus ls                             # the projects: the coarsest real boundary
magus describe project <path>        # its declared sources, outputs, depends_on
magus affected --impact              # what a candidate group actually reaches
magus refs <symbol> --occurrences    # every site of a rename, uncapped
```

Three signals, strongest first:
- Project ownership: projects with no dependency edge between them -> separate commits; edges from `magus describe project`.
- Blast radius: groups reaching disjoint project sets -> separable; same set -> usually one commit.
- Symbol coupling: rename's sites together, however many directories.

## Limits

Two changes inside one file cannot be separated by path.
File with rename and behavior fix -> hunk-level work, or ship together; recognize while planning.

Prefer cheapest operation making branch reviewable. Rising risk:
1. Reword message.
2. Fold regeneration into neighbor.
3. Drop commit whose content final tree does not keep.
4. Reorder independent commits.
5. Split one commit into several.

## Before start, after finish

Record state identity before rewriting:

```sh
magus vcs checkpoint          # revision, branch, dirty flag, patch digest; writes nothing
```

Restructure with your VCS.
When it stops on conflicted generated file -> settle with magus, not by hand:

```sh
magus vcs resolve             # settles the conflicted declared outputs, regenerates once
```

Prove content survived: restructure changes history and nothing else; lost commit still leaves building tree.

```sh
magus graph diff --rev <checkpoint-revision>
```

Everything reported must be intended change.
Missing nodes you did not remove -> work dropped -> return to recorded revision, restart; never reconcile by hand.

Finish: list what the commit wants, stage it, re-run gate:

```sh
magus vcs ls-files -o name | git add --pathspec-from-file=-
magus affected ci
```

## Not commit content at all

Session notes, scratch plans: not repository content unless repository already tracks them.
Untracked session state: harness memory, not branch.

## See also

- magus-vcs-hygiene: classifying paths, staging one commit safely.
magus agent install --tar | tar -xO -f - magus-commit-composition-full/SKILL.md
# Composing unpushed commits into reviewable chunks

A reviewer reads commits, not diffs. Work committed in the order it occurred to
you arrives as a log nobody can review: a rename spread over four commits, a fix
buried in a regeneration, notes-to-self between two real changes. This skill decides
what belongs in each commit, so every commit is one idea a reviewer can accept or
reject alone. The workspace models its own boundaries: use them, not directory
names.

magus does not rewrite history for you, the same way it reports what a
change affects without editing it. It shows the seams and proves afterwards that
nothing was lost; your VCS performs the edit.

## Contents

- Two constraints that decide most groupings
- Ask the workspace where the seams are
- Where this stops
- Before you start, and after you finish
- What does not belong in a commit at all
- See also

## Two constraints that decide most groupings

**Only unpushed work is eligible.** Published commits are fixed. Establish what is
unpushed before planning; a branch with no upstream has
published nothing.

**Generated output belongs with the source that moved it.** Split them and the
source commit fails its own drift gate.

```sh
magus describe file <changed-path>...
```

Every `output` path joins the `source` change that invalidated it. A commit that is
all regeneration missed that pairing: fold it into the change that caused it.

## Ask the workspace where the seams are

```sh
magus ls                             # the projects: the coarsest real boundary
magus describe project <path>        # its declared sources, outputs, depends_on
magus affected --impact              # what a candidate group actually reaches
magus refs <symbol> --occurrences    # every site of a rename, uncapped
```

Three signals, strongest first:

- **Project ownership.** Changes in projects with no dependency edge between them
  are separate commits. Read the edges from `magus describe project`,
  which frequently disagrees with what the directory layout suggests.
- **Blast radius.** Groups that reach disjoint project sets are separable; groups
  that reach the same set usually want one commit.
- **Symbol coupling.** A rename's sites belong together, however many directories
  they span. If refs reports a project not-indexed, run
  `magus graph build` first: `unknown, not absent` is not an empty result.

## Where this stops

**Two changes inside one file cannot be separated by path.** A file carrying a
rename and a behavior fix needs hunk-level work, or they ship together. Recognize it
while planning; discovering it
mid-restructure turns a cleanup into a recovery.

Prefer the cheapest operation that makes the branch reviewable. In rising order of
risk:

1. Reword a message.
2. Fold a regeneration into its neighbor.
3. Drop a commit whose content the final tree does not keep.
4. Reorder independent commits.
5. Split one commit into several.

Most branches need only the first three.

## Before you start, and after you finish

Record the identity of the state you are about to rewrite:

```sh
magus vcs checkpoint          # revision, branch, dirty flag, patch digest; writes nothing
```

Restructure with your VCS. When it stops on a conflicted generated file, settle it
with magus, not by hand:

```sh
magus vcs resolve             # settles the conflicted declared outputs, regenerates once
```

**Prove the content survived.** A restructure changes history and nothing else, and
a lost commit still leaves a tree that builds, which is why
a green suite is not evidence here:

```sh
magus graph diff --rev <checkpoint-revision>
```

Everything it reports must be a change you intended. Missing nodes you did not
remove mean the restructure dropped work: return to the recorded revision and start
again, never reconcile by hand.

Finish by listing what the commit wants, staging that list, and re-running the gate:

```sh
magus vcs ls-files -o name | git add --pathspec-from-file=-
magus affected ci
```

## What does not belong in a commit at all

Session notes and scratch plans are not repository content unless the repository
already tracks them; check the path's history on the base branch
before assuming either way. Untracked session state belongs in your harness's
memory, not the branch, and dropping those commits is
often the single largest reduction available.

## See also

- magus-vcs-hygiene covers classifying paths and staging one commit safely.
generatedinternal/agent/skills/magus-commit-composition/SKILL.mdagentsskillsmagus-commit-composition
Last updated (61fd39a7)
Earlier changes on this page (7)

Full history ↗ · Blame source ↗

Glossary

Workspace

The magus root directory that owns a set of projects and shared config; the unit magus operates over. Workspace in full.

Project

A directory magus recognizes as a unit of work (it has a magusfile); the unit of caching, scheduling, and dependency tracking. Project in full.

Op

A single tool-native command a target composes (long form: operation); the middle of the work hierarchy (Spell to Op to Target). Op in full.

Ward

A coded diagnostic that inspects a resolved op and nudges or blocks an anti-pattern before it runs. Ward in full.

Affected

The set of projects touched by a change; magus affected <target> runs a target only over them. Affected in full.

CI

An ordinary target you compose yourself with ctx.needs; magus does not hardcode its stages. It is the anchor magus affected ci keys off, and ci strips the rw charm. CI in full.

Span

OpenTelemetry's name for one unit of work under a trace: a target execution, whose sub-operations are child spans. An output reference points at a span's captured output. Span in full.

Ownership

An insight lens for author concentration: the primary author and their share, the distinct-author count (the bus factor), and abandonment. Ownership in full.

Agent

A model working through an agent host such as Claude Code, Codex, Cursor or OpenCode. magus treats an agent as one more caller of its CLI, MCP tools and console, held to the same checks as a person. Agent in full.

Harness

The deterministic scaffolding around the work on a change, for a person or an agent: compiler errors, formatters, linters, checks, gates, leases and hooks, placed at points a person chose. Around an agent's loop, magus supplies one and keeps it outside. Harness in full.

Skill

A packaged set of instructions an agent host loads when a task matches its description: a directory holding a SKILL.md. magus ships its magus-* skills in the binary and writes them with magus agent install. Skill in full.

Session

An agent host's conversation, by the id the host delivers to its hooks. magus never mints one: a record with no session is unattributed, and the OS user it carries says whose account ran it. Session in full.

Run

One target executing under one magus invocation, such as magus run test web or magus affected ci. A run keeps its captured output behind an output reference. Every magus run is a run whether or not any job asked for it; see Job for how the two relate. Run in full.

Pane

A split within a tab. Splitting divides the focused pane along its longer side, so the same action tiles side-by-side on a desktop and stacks on a phone; a tab with no split is a single pane. Drag the divider to re-weight the split. Pane in full.

Conventions

Placeholders

Angle brackets mark a value you replace with your own; never type the brackets:

magus run <target>
magus completion <shell>    # e.g. bash, zsh, fish

<target>, <path>, <shell>, <name> and the like are stand-ins, not literal text.