AgentSkillsCN

skill-git-workflow

为任务操作创建范围限定的 git 提交。在任务状态变化或工件创建后调用。

SKILL.md
--- frontmatter
name: skill-git-workflow
description: Create scoped git commits for task operations. Invoke after task status changes or artifact creation.
allowed-tools: Bash(git:*)
context: fork

Git Workflow Skill

Create properly scoped git commits for task operations.

Trigger Conditions

This skill activates when:

  • Task status changes (research, plan, implement complete)
  • Artifacts are created
  • Task lifecycle operations occur

Commit Message Formats

Task Operations

OperationFormat
Create tasktask {N}: create {title}
Complete researchtask {N}: complete research
Create plantask {N}: create implementation plan
Complete phasetask {N} phase {P}: {phase_name}
Complete tasktask {N}: complete implementation
Revise plantask {N}: revise plan (v{V})

System Operations

OperationFormat
Archive taskstodo: archive {N} completed tasks
Error fixeserrors: create fix plan for {N} errors
Code reviewreview: {scope} code review
State syncsync: reconcile TODO.md and state.json

Execution Flow

code
1. Receive commit request:
   - operation_type
   - task_number (if applicable)
   - scope (files to include)
   - message_template

2. Stage appropriate files:
   - git add {scope}

3. Create commit:
   - Format message
   - Add co-author
   - Execute commit

4. Verify success:
   - Check exit code
   - Log result

5. Return result

Commit Scope Rules

Task-Specific Commits

Include only task-related files:

code
.claude/specs/TODO.md
.claude/specs/state.json
.claude/specs/{N}_{SLUG}/**

Implementation Commits

Include source files modified:

code
Logos/**/*.lean  (for Lean tasks)
src/**/*         (for general tasks)

Phase Commits

Scope to phase changes only:

code
Files modified in that phase
Updated plan with phase status

Safety Checks

Before Commit

code
1. git status - verify staged files
2. Check no sensitive files staged (.env, credentials)
3. Verify commit message format

Never Run

  • git push --force
  • git reset --hard (without explicit request)
  • git rebase -i

Message Template

code
{scope}: {action} {description}

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Execution Commands

Standard Commit

bash
git add {files}
git commit -m "$(cat <<'EOF'
{message}

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"

Task Commit

bash
git add .claude/specs/
git commit -m "$(cat <<'EOF'
task {N}: {action}

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
EOF
)"

Return Format

json
{
  "status": "completed|failed",
  "summary": "Created commit: {short_message}",
  "commit_hash": "abc123",
  "files_committed": [
    "path/to/file1",
    "path/to/file2"
  ],
  "message": "Full commit message"
}

Error Handling

Nothing to Commit

json
{
  "status": "completed",
  "summary": "No changes to commit",
  "commit_hash": null
}

Pre-Commit Hook Failure

json
{
  "status": "failed",
  "error": "Pre-commit hook failed",
  "recovery": "Fix issues and retry (do not use --no-verify)"
}

Git Error

json
{
  "status": "failed",
  "error": "Git command failed: {error}",
  "recovery": "Check git status and resolve manually"
}

Non-Blocking Behavior

Git failures should NOT block task operations:

  • Log the failure
  • Continue with task
  • Report to user that commit failed
  • Task state is preserved regardless