AgentSkillsCN

jj-workflow

Jujutsu (jj) 版本控制,助力 AI 辅助开发。适用于以下场景: - 仓库中包含 `.jj/` 目录(可通过 `jj root` 检查) - 在发生重大变更后需要回滚或恢复 - 在提交 PR 前对杂乱的历史记录进行整理与优化

SKILL.md
--- frontmatter
name: jj-workflow
description: |
  Jujutsu (jj) version control for AI-assisted development. Use when:
  - Repo has `.jj/` directory (check with `jj root`)
  - Need undo/recovery after breaking changes
  - Curating messy history before PR

jj Workflow

Mental Model

No staging area. Your working directory is always a commit. Every save is tracked.

  • @ = your current change (the working copy)
  • @- = parent of current change
  • Changes are mutable until pushed

When to Use What

SituationDo This
Starting new workjj new -m "what I'm trying"
Work is done, move onjj new (current becomes parent)
Annotate what you didjj describe -m "feat: auth"
Broke somethingjj op logjj op restore <id>
Undo one filejj restore --from @- <path>
Combine messy commitsjj squash
Split bloated commitjj split
Try something riskyjj new -m "experiment", then jj abandon @ if it fails

AI Coding Pattern

During implementation, don't think about commits. Just work. jj tracks everything.

bash
# Before risky change
jj describe -m "checkpoint: auth works"
jj new -m "adding OAuth"

# If it breaks
jj op log              # Find good state
jj op restore <id>     # Go back

# When done, curate
jj log -r 'ancestors(@, 10)'
jj squash              # Combine checkpoints
jj describe -m "feat: OAuth support"

Push to GitHub

bash
jj bookmark create feature-x   # Name for pushing
jj git push --allow-new        # Push to remote

Teammates see clean git. They don't know you used jj.

Recovery

The oplog records every operation. Nothing is lost.

bash
jj op log                      # See all operations
jj undo                        # Undo last operation
jj op restore <id>             # Jump to any past state

Bail Out

bash
rm -rf .jj    # Delete jj, keep git unchanged