AgentSkillsCN

stage-related-files

在 Git 提交前,对相关变更进行分组与阶段性整理。当您准备将文件暂存以待提交、对相关变更进行归类,或决定每次提交应包含哪些内容时,可借助此技巧。本指南详细阐述了如何合理分组变更,以及何时应当拆分提交。

SKILL.md
--- frontmatter
name: stage-related-files
description: "Group and stage related changes for git commit. Use when staging files for commit, grouping related changes, or deciding what to include in each commit. Implements how to group changes and when to split commits."

Stage Related Files Skill

Group changes logically for git add and decide when to split into one or more commits.

When to Use

  • Use when staging files for commit (e.g. as part of shipit or any commit workflow)
  • Use when grouping related changes into logical commits
  • Use when deciding whether to make one commit or several

Instructions

Grouping Criteria

Group by logical change: one feature/fix/docs refactor per commit when possible.

  • Same type of change: Same scope (e.g. one area of codebase), no unrelated edits in one commit
  • When to split: Separate commits for distinct features, fixes, or doc-only vs code

Steps

  1. Run git status to see modified, added, and deleted files
  2. Propose groupings (paths or patterns) based on the criteria above
  3. For each group, run git add <paths>. Avoid staging everything in one blob unless it truly is one logical change
  4. Run git status again to verify what is staged

Single vs Multiple Commits

  • Single: All changes are one logical unit — use one git add for the full set
  • Multiple: If the working tree has clearly separate logical changes, do multiple git add + commit cycles (group 1 → add → commit, then group 2 → add → commit)

Related Artifacts