| name | yux-linear-commit |
| description | Commit changes with conventional commit messages and sync to Linear. Triggers on "linear commit", "commit and sync", "save progress", "提交代码". |
| allowed-tools | Read, Write, Bash(git:*), Bash(gh:*), Glob, Grep, mcp__linear__*, AskUserQuestion |
Linear Commit
Make incremental commits during development, linking to Linear issue and syncing progress.
Usage: /yux-linear-commit [--no-push] [description]
Input
description: Reference for commit message generation (Claude auto-generates)
--no-push: Skip auto-push after commit
Workflow
Step 1: Detect Context
- Get branch:
git branch --show-current
- Extract
LIN-xxx from branch name. If not on Linear branch -> prompt /yux-linear-start
- Fetch issue via
mcp__linear__get_issue(id: "LIN-xxx")
- Check changes:
git status --porcelain
- If changes exist -> continue to Step 2
- If clean -> run Clean Status Check below, then exit (do NOT continue to Step 2)
Clean Status Check (no uncommitted changes)
- Run
git log origin/main..HEAD --oneline. If empty (no commits on branch), say "No uncommitted changes and no commits on this branch yet" and exit.
- Get last commit:
git log -1 --format="%H %s" (full hash + subject)
- Fetch comments:
mcp__linear__list_comments(issueId: "<uuid from step 1.3>")
- Search comment bodies for the last commit hash substring
- If found (commit already synced):
=== No Changes ===
Last commit: <short-hash> - <subject> (synced to Linear ✓)
Issue: LIN-xxx - <title> (<status>)
Next: keep coding, or /yux-linear-pr when ready
- If not found (commit not synced):
Use AskUserQuestion: "Last commit
<short-hash> - <subject> hasn't been synced to Linear yet. Sync now?"
- Yes -> execute Step 9 (Sync to Linear) for this commit, then show summary
- No -> show summary with "Synced: skipped"
Step 2: Display Changes
Categorize files (new/modified/deleted), flag sensitive files (.env, credentials).
Step 3: File Selection
Use AskUserQuestion: commit all, select specific, exclude specific, or cancel.
Step 4: Atomic Check
Analyze if changes should be split. If multiple unrelated groups detected, suggest splitting. If user declines to split, proceed with all changes in a single commit.
Step 5: Generate Commit Message
Auto-determine from diff analysis:
- Emoji + type + scope + subject
- What/Why/Refs sections
- Language: detect from user input, default to English
- Format:
<emoji> <type>(<scope>): <subject>
- Include
Refs: LIN-xxx and Co-Authored-By line
Show for confirmation. User can modify or approve.
Step 6: Execute
git add <files>
git commit -m "<message>"
Step 7: Auto-Push (default on)
git push origin HEAD
If fails:
- Non-fast-forward: suggest
git pull --rebase origin HEAD, then retry push
- Auth/network error: inform user and stop (commit is still saved locally)
Skip if --no-push flag passed.
Step 8: Update Task State
If .claude/linear-tasks.json exists, update last_active_at.
Step 9: Sync to Linear (Required)
mcp__linear__create_comment(
issueId: "<uuid>",
body: "**Commit**: `<hash>`\n```\n<message>\n```\nFiles: <count>"
)
Step 10: Summary
=== Commit Synced ===
Commit: abc1234 - feat(auth): add JWT token validation
Branch: feat/LIN-456-user-auth
Files: 3 changed (+45, -12)
Push: origin/feat/LIN-456-user-auth
Linear: Comment posted to LIN-456
Next: /yux-linear-pr when ready for review