Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jj/commands/commit-push-pr.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
description: Commit, create bookmarks, push, and create PRs in one workflow
model: claude-sonnet-4-5
tools: Bash(jj status:*), Bash(jj git remote list:*), Bash(jj log:*), Bash(jj bookmark create:*), Bash(jj bookmark track:*), Bash(jj git push:*), Bash(gh api user:*), Bash(gh pr list:*), Bash(gh pr create:*)
tools: Skill(jj:commit), Bash(jj status:*), Bash(jj git remote list:*), Bash(jj log:*), Bash(jj bookmark create:*), Bash(jj bookmark track:*), Bash(jj git push:*), Bash(gh api user:*), Bash(gh pr list:*), Bash(gh pr create:*)
---

# Commit, Push, and Create PRs
Expand Down
129 changes: 23 additions & 106 deletions jj/commands/commit.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,34 @@
---
description: Create jj changes with user approval and no Claude attribution
argument-hint: "[revset]"
model: claude-haiku-4-5
tools: Bash(jj status:*), Bash(jj diff:*), Bash(jj log:*), Bash(jj describe:*), Bash(jj split:*), Bash(jj new:*)
---

# Commit Changes with Jujutsu

You are tasked with creating jj changes for the work done during this session.
Create jj change descriptions for work done during this session. Write commit messages as if the user wrote them. NEVER add co-author information or Claude attribution.

## Optional Parameter
## Usage

This command accepts an optional revset argument:
- `/jj:commit` - Operate on the current working copy (`@`)
- `/jj:commit <revset>` - Operate on specific revision(s) (e.g., `xyz`, `@-`, `trunk()..@`)

When a revset is provided, only add/update descriptions for those commits. Do not split or modify other commits.
- `/jj:commit` - Describe the working copy (`@`) and any undescribed parent commits
- `/jj:commit <revset>` - Describe only the specified revision(s), without splitting or modifying other commits

## Process

### 1. Understand What Changed

**If no revset provided (default):**
- Review the conversation history to understand what was accomplished
- Run `jj status --no-pager` to see modified files
- Run `jj diff --no-pager` to review the actual changes
- Determine if changes should be one change or split into multiple logical changes
- Check for undescribed parent commits (see below)

**If revset provided:**
- Run `jj log --no-pager -r '<revset>'` to see which commits need descriptions
- Run `jj diff --no-pager -r '<change_id>'` for each commit to understand its changes
- Focus only on adding descriptions to the specified commits
### 1. Analyze Changes

**Check for undescribed parent commits:**
```bash
# Find commits between trunk and @ that have no description (empty or "(no description set)")
jj status --no-pager
jj diff --no-pager
jj log --no-pager -r 'trunk()..@ & description(exact:"")' -T 'change_id ++ "\n"'
```
For each undescribed parent commit found:
- Run `jj diff --no-pager -r '<change_id>'` to understand what it contains
- Draft an appropriate commit message based on the changes

### 2. Plan Your Change(s)
Run `jj diff --no-pager -r '<change_id>'` for each undescribed commit, including parents.

Draft clear, descriptive commit messages following these guidelines:
If a revset was provided, use `jj log --no-pager -r '<revset>'` and diff each commit instead.

### 2. Write Commit Messages

**Format:**
```
Expand All @@ -55,95 +40,27 @@ Draft clear, descriptive commit messages following these guidelines:
**Types:** `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `build`

**Rules:**
- Subject line: imperative mood, lowercase, no period, max 50 chars
- Subject: imperative mood, lowercase, no period, max 50 chars
- Body: wrap at 72 chars, explain WHY not just WHAT
- Focus on the user's intent, not implementation details

**Examples:**
- `feat: add dark mode toggle to settings`
- `fix: prevent crash when config file is missing`
- `refactor: extract validation logic into separate module`

### 3. Execute Immediately

**First, describe any undescribed parent commits:**
```bash
# For each undescribed parent commit found in step 1
jj describe -r <change_id> -m "commit message for parent"
```
- Group related changes logically
- Keep changes focused and atomic

**Then describe the current change (no revset):**
```bash
jj describe -m "your commit message"
```
### 3. Apply Descriptions

**For a specific revision (revset provided):**
```bash
jj describe -r <change_id> -m "your commit message"
jj describe -m "message" # current change
jj describe -r <change_id> -m "msg" # specific revision
```

**For multiple changes** (split by file paths, no revset only):
**To split into multiple changes** (only when no revset provided):
```bash
# Split specific files into first change with message
jj split -m "first change message" path/to/file1 path/to/dir/

# Describe the remaining change (now in @)
jj describe -m "second change message"
jj split -m "first message" path/to/files/
jj split -m "second message" more/files/
jj describe -m "remaining changes"
```

For three or more changes, chain splits:
```bash
jj split -m "first message" files-for-first-change/
jj split -m "second message" files-for-second-change/
jj describe -m "third message"
```
### 4. Show Results

**Show results:**
```bash
# Default (no revset)
jj log --no-pager -r 'ancestors(@, 5)'

# With revset
jj log --no-pager -r '<revset>'
```

## Important Rules

- **NEVER add co-author information or Claude attribution**
- Commits should be authored solely by the user
- Do not include "Generated with Claude" or "Co-Authored-By" lines
- Write commit messages as if the user wrote them

## Jujutsu Concepts

- **Automatic tracking**: All file changes are automatically tracked in the working copy change (@)
- **No staging**: Unlike git, there's no staging area - `jj describe` sets the message directly
- **Working copy is a change**: The @ revision always represents uncommitted work
- **`jj new`**: Creates a new empty change on top of the current one (use after describing to start fresh)
- **`jj split -m "msg" paths`**: Non-interactively splits specified paths into a new change with the given message
- **`jj squash`**: Combines the current change into its parent

## Common Patterns

**Describe current work and start fresh:**
```bash
jj describe -m "message"
jj new
```

**View recent changes:**
```bash
jj log --no-pager -r 'ancestors(@, 10)'
```

**Check what will be committed:**
```bash
jj diff --no-pager -r @
```

## Remember

- You have full context of what was done this session
- Group related changes together logically
- Keep changes focused and atomic
- The user trusts your judgment - they asked you to commit