check-history
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGit History Context Skill
Git历史上下文Skill
⚠️ MANDATORY SKILL - YOU MUST INVOKE THIS
⚠️ 强制Skill - 你必须调用此Skill
Purpose
用途
This skill gathers comprehensive git context before starting any work. It helps understand the current state of the repository, recent changes, and identify related previous work.
CRITICAL: You MUST invoke this skill - NEVER gather git context manually with individual git commands.
此Skill会在开展任何工作前收集全面的Git上下文信息。它有助于了解仓库的当前状态、最近的变更,并识别相关的过往工作内容。
重要提示: 你必须调用此Skill - 绝对不要通过单独的Git命令手动收集Git上下文信息。
🚫 NEVER DO THIS
🚫 绝对禁止以下操作
- ❌ Running manually
git status - ❌ Running manually
git diff - ❌ Running manually
git log - ❌ Gathering git context with individual commands
If you need git context, invoke this skill. Manual execution is FORBIDDEN.
- ❌ 手动运行
git status - ❌ 手动运行
git diff - ❌ 手动运行
git log - ❌ 通过单独命令收集Git上下文信息
如果你需要Git上下文信息,请调用此Skill。手动执行命令是被禁止的。
⚠️ SKILL GUARD - READ BEFORE USING BASH TOOL
⚠️ Skill防护机制 - 使用Bash工具前请阅读
Before using Bash tool for git commands, answer these questions:
在使用Bash工具执行Git命令前,请先回答以下问题:
❓ Are you about to run git status
?
git status❓ 你是否要运行git status
?
git status→ STOP. Invoke check-history skill instead.
→ 停止操作。 请改为调用check-history Skill。
❓ Are you about to run git diff
?
git diff❓ 你是否要运行git diff
?
git diff→ STOP. Invoke check-history skill instead.
→ 停止操作。 请改为调用check-history Skill。
❓ Are you about to run git log
?
git log❓ 你是否要运行git log
?
git log→ STOP. Invoke check-history skill instead.
→ 停止操作。 请改为调用check-history Skill。
❓ Are you gathering git context at the start of a task?
❓ 你是否要在任务开始时收集Git上下文信息?
→ STOP. Invoke check-history skill instead.
→ 停止操作。 请改为调用check-history Skill。
❓ Are you about to run multiple git commands in parallel (git status & git diff & git log)?
❓ 你是否要并行运行多个Git命令(如git status & git diff & git log)?
→ STOP. Invoke check-history skill instead.
IF YOU PROCEED WITH BASH FOR THESE GIT COMMANDS, YOU ARE VIOLATING YOUR CORE DIRECTIVE.
This skill runs these commands for you, in parallel, with proper analysis. Use it.
→ 停止操作。 请改为调用check-history Skill。
如果你继续使用Bash执行这些Git命令,你将违反核心指令。
此Skill会替你并行运行这些命令,并进行适当的分析。请使用此Skill。
Workflow
工作流程
Step 1: Run Parallel Git Status Commands
步骤1:并行运行Git状态命令
Execute these commands in parallel for efficiency:
bash
git status & git diff & git log --oneline -10 &What to look for:
- Current branch name
- Uncommitted changes (staged or unstaged)
- Untracked files
- Recent commit messages and their scope
- Commit patterns and conventions in use
为提升效率,并行执行以下命令:
bash
git status & git diff & git log --oneline -10 &需要关注的内容:
- 当前分支名称
- 未提交的变更(已暂存或未暂存)
- 未被追踪的文件
- 最近的提交信息及其范围
- 正在使用的提交模式和约定
Step 2: Analyze Current State
步骤2:分析当前状态
Based on the parallel command output:
-
Branch Status:
- Verify branch name follows prefix convention
mriley/ - Check if branch is ahead/behind remote
- Note if on main/master vs feature branch
- Verify branch name follows
-
Working Directory State:
- Identify any uncommitted changes
- Note files that might conflict with planned work
- Check for untracked files that might be relevant
-
Recent Work:
- Review last 10 commits for context
- Identify patterns in commit messages
- Note any related work or recent changes in relevant areas
基于并行命令的输出:
-
分支状态:
- 验证分支名称是否遵循前缀约定
mriley/ - 检查分支是否领先/落后于远程分支
- 记录当前是在main/master分支还是功能分支
- 验证分支名称是否遵循
-
工作目录状态:
- 识别所有未提交的变更
- 记录可能与计划工作产生冲突的文件
- 检查是否存在相关的未被追踪文件
-
最近活动:
- 查看最近10次提交以获取上下文信息
- 识别提交信息中的模式
- 记录任何相关的工作或相关领域的最近变更
Step 3: Search for Related Work (If Applicable)
步骤3:搜索相关工作内容(如适用)
If the task relates to a specific feature, bug, or area:
bash
git log --grep="<keyword>" --oneline -10Example keywords:
- Feature names (e.g., "auth", "parser", "api")
- Bug identifiers (e.g., "fix", "bug", "issue")
- Scope identifiers from conventional commits
如果任务与特定功能、Bug或领域相关:
bash
git log --grep="<keyword>" --oneline -10示例关键词:
- 功能名称(如"auth", "parser", "api")
- Bug标识符(如"fix", "bug", "issue")
- 约定式提交中的范围标识符
Step 4: Get Detailed Context (If Needed)
步骤4:获取详细上下文信息(如需要)
For more detailed information about recent changes:
bash
git show --name-only HEAD # Files changed in last commit
git diff --name-only origin/main # Files changed vs main branch
git log --graph --oneline -10 # Visual commit graph如需了解最近变更的更详细信息:
bash
git show --name-only HEAD # 最后一次提交中变更的文件
git diff --name-only origin/main # 与main分支相比变更的文件
git log --graph --oneline -10 # 可视化提交图Step 5: Generate Context Summary
步骤5:生成上下文摘要
Provide a concise summary including:
-
Current State:
- Branch:
<branch-name> - Status: Clean working directory / Has uncommitted changes
- Position: Up to date / Ahead by N commits / Behind by N commits
- Branch:
-
Recent Activity:
- Last 3-5 relevant commits with their scope and purpose
- Any ongoing work that might be related
-
Relevant History:
- Related previous work (if found via grep)
- Patterns or conventions observed
-
Recommendations:
- Any concerns or conflicts to address
- Suggested next steps based on current state
提供简洁的摘要,包括:
-
当前状态:
- 分支:
<branch-name> - 状态:工作目录干净 / 存在未提交变更
- 位置:与远程同步 / 领先N次提交 / 落后N次提交
- 分支:
-
最近活动:
- 最近3-5次相关提交及其范围和用途
- 任何可能相关的正在进行中的工作
-
相关历史记录:
- 通过grep找到的相关过往工作内容
- 观察到的模式或约定
-
建议:
- 需要解决的任何问题或冲突
- 基于当前状态建议的下一步操作
Example Output
示例输出
Git Context Summary:
==================
Current State:
- Branch: mriley/feat/user-authentication
- Status: Clean working directory
- Position: Ahead of origin/main by 2 commits
Recent Activity:
1. feat(auth): add JWT token generation (3 hours ago)
2. feat(auth): implement user login endpoint (5 hours ago)
3. test(auth): add unit tests for password hashing (1 day ago)
Relevant History:
- Found 3 commits related to "auth" in past week
- Project consistently uses conventional commits with scope
- Security-focused: all auth changes include tests
Recommendations:
- Safe to proceed with auth-related work
- Follow existing pattern: feature + tests in same commit
- Consider reviewing recent auth commits for contextGit上下文摘要:
==================
当前状态:
- 分支: mriley/feat/user-authentication
- 状态: 工作目录干净
- 位置: 领先origin/main分支2次提交
最近活动:
1. feat(auth): 添加JWT令牌生成功能(3小时前)
2. feat(auth): 实现用户登录端点(5小时前)
3. test(auth): 为密码哈希添加单元测试(1天前)
相关历史记录:
- 过去一周内找到3次与"auth"相关的提交
- 项目始终使用带范围的约定式提交
- 注重安全性:所有认证相关变更都包含测试
建议:
- 可以安全开展认证相关工作
- 遵循现有模式:同一提交中包含功能和测试
- 建议查看最近的认证相关提交以获取上下文信息Error Handling
错误处理
If git command fails:
如果Git命令执行失败:
- Verify we're in a git repository
- Check git is installed and accessible
- Report error to user with specific command that failed
- 验证当前是否处于Git仓库中
- 检查Git是否已安装且可访问
- 向用户报告失败的具体命令
If not in a git repo:
如果当前不在Git仓库中:
- Note this is not a git repository
- Skip git-specific checks
- Proceed with file system context if needed
- 记录当前不是Git仓库
- 跳过Git相关检查
- 如有需要,继续使用文件系统上下文信息
Integration with Other Skills
与其他Skill的集成
This skill should be invoked by:
- - Before creating implementation plans
sparc-plan - - To understand what's being committed
safe-commit - - To generate meaningful PR descriptions
create-pr
此Skill应由以下Skill调用:
- - 在创建实施计划前
sparc-plan - - 了解要提交的内容时
safe-commit - - 生成有意义的PR描述时
create-pr
Best Practices
最佳实践
- Always run parallel commands - Don't run git commands sequentially
- Be concise - Summarize, don't dump raw git output
- Focus on relevance - Highlight information relevant to the current task
- Note patterns - Identify conventions and patterns in commit history
- Flag concerns - Highlight any potential conflicts or issues early
- 始终运行并行命令 - 不要按顺序运行Git命令
- 保持简洁 - 进行摘要,不要直接输出原始Git结果
- 聚焦相关性 - 突出显示与当前任务相关的信息
- 记录模式 - 识别提交历史中的约定和模式
- 标记问题 - 尽早突出显示任何潜在的冲突或问题
Related Commands
相关命令
- - Quick visual git dashboard (lighter weight alternative for simple status checks)
/quick-status - - Full branch code review against main
/review-branch
- - 快速可视化Git仪表板(适用于简单状态检查的轻量替代方案)
/quick-status - - 针对main分支的完整分支代码评审
/review-branch