AgentSkillsCN

git-ops

在本地仓库与 GitHub 工作流中,熟练运用 Git 操作。当 Codex 需要检查仓库状态、撰写提交记录、管理分支、安全地执行变基或合并操作,或在遵循安全规范与提交约定的前提下,决定 Git/GitHub 命令(包括 gh 工具的使用)时,此技能大有裨益。

SKILL.md
--- frontmatter
name: git-ops
description: Git operations for local repos and GitHub workflows. Use when Codex needs to inspect repo state, craft commits, manage branches, rebase/merge safely, or decide on Git/GitHub commands (including gh usage) while following safety constraints and commit conventions.

Git Ops

Overview

Handle routine Git operations with safety-first constraints, clear commit messaging, and minimal history risk.

Workflow

  1. Inspect repo state
  • Use git status -sb and git diff to understand current changes.
  • Avoid touching unrelated user changes; never revert changes you did not make.
  1. Choose the safest path
  • Prefer non-destructive operations and reversible steps.
  • Avoid git reset --hard or git checkout -- unless explicitly requested.
  1. Apply changes
  • Stage only relevant files.
  • If a command would rewrite history (rebase, amend, force push), require explicit user intent.
  1. Create commits
  • Check commit message patterns in history first.
  • If no pattern exists, use Conventional Commits.
  1. GitHub interactions
  • Prefer the gh CLI when interacting with GitHub.

Commit Conventions

  • Inspect prior commits to mirror existing style.
  • Default to Conventional Commits when no clear pattern exists.

Rebase/Merge Guidance

  • Prefer fast-forward updates, then rebase, then merge (in that order).
  • When running rebase, use non-interactive mode with EDITOR=true to avoid blocking.
  • Do not recommend or execute history-rewriting commands unless explicitly requested.

Destructive-Operation Gate

  • Warn before destructive operations and provide safer alternatives.
  • Confirm explicit intent before executing irreversible actions.

Reference

Read references/git-ops.md for the full source guidance extracted from .codex/AGENTS.md.