Git Push 前文档更新校验
pre-push-validation
确保在执行 git push 操作前,CLAUDE.md、README.md 和 CHANGELOG.md 已更新。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- mx
- { "canonicalUri": "https://raw.githubusercontent.com/ddttom/allaboutv2/main/.claude/skills/pre-push-validation/SKILL.md" }
- name
- pre-push-validation
- tags
- [ "git push", "commit push", "pushing changes", "before push", "validate docs", "check documentation" ]
- author
- Tom Cranstoun
- version
- 1.0.0
- description
- Ensures CLAUDE.md, README.md, and CHANGELOG.md are updated before git push operations
- enforcement
- suggest
- trigger_type
- intent
- intent_patterns
- [ "push.*changes", "git push", "ready.*push", "update.*push" ]
03 SKILL.md 正文
Pre-Push Validation Skill
Ensures critical documentation files are updated before pushing changes to the repository.
What This Skill Does
Automatic validation before git push - The pre-push hook checks that documentation is current:
- CHANGELOG.md - Must document your changes
- README.md - Must reflect any project structure changes
- CLAUDE.md - Must reflect any AI instruction changes
How It Works
Pre-Push Hook
The hook .claude/hooks/pre-push-validation.sh runs automatically before git push operations:
Validation Logic:
- ✅ Checks commit dates - Documentation must be updated since oldest unpushed commit
- ✅ Detects uncommitted changes - Warns if docs have uncommitted changes
- ✅ Validates file existence - Ensures all critical files exist
- ❌ Blocks push - If documentation is outdated relative to code changes
Example Output:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
? PRE-PUSH VALIDATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
? Commits to push: 3
? Branch: main → origin/main
? Checking documentation files...
✓ CLAUDE.md: Updated 2025-12-10
✓ README.md: Updated 2025-12-10
❌ CHANGELOG.md: Not updated since 2025-12-09
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
❌ VALIDATION FAILED
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Please update the following files before pushing:
• CHANGELOG.md
? Tips:
1. Update CHANGELOG.md with your changes
2. Update README.md if project structure changed
3. Update CLAUDE.md if AI instructions changed
4. Commit your documentation updates
5. Push again
When to Update Each File
CHANGELOG.md (Required for ALL commits)
Always update when:
- Adding new features
- Fixing bugs
- Refactoring code
- Changing dependencies
- Modifying configuration
- Updating documentation
Format:
## [YYYY-MM-DD<letter>] - Brief Title
### Added/Changed/Fixed/Removed
- Detailed description of changes
- Impact and rationale
- Technical details
### Files Modified
1. `path/to/file.js` - Description
2. `path/to/file.css` - Description
**Total: X files modified**
README.md (Update when project changes)
Update when:
- Adding new blocks or components
- Changing project structure
- Adding new npm scripts
- Modifying development workflow
- Adding new dependencies
- Changing infrastructure
CLAUDE.md (Update when AI instructions change)
Update when:
- Adding new coding patterns
- Changing project conventions
- Adding new skills or commands
- Modifying development requirements
- Updating architecture decisions
- Changing configuration patterns
Using the Skill
Before Every Push
-
Review your commits:
git log origin/main..HEAD --oneline -
Update documentation:
- CHANGELOG.md - Document all changes
- README.md - Update if structure changed
- CLAUDE.md - Update if AI instructions changed
-
Commit all changes (including user edits):
git add . git commit -m "docs: Update documentation for [feature/fix]" -
Push with confidence:
git pushThe hook will validate and either allow or block the push.
Bypassing Validation (NOT RECOMMENDED)
If you absolutely must push without updating documentation:
git push --no-verify
⚠️ Warning: Only use this for:
- Emergency hotfixes
- Work-in-progress branches
- Documentation-only changes
Never use --no-verify for main/production branches.
Hook Installation
The hook is automatically available in Claude Code projects. To verify:
ls -la .claude/hooks/pre-push-validation.sh
Should show executable permissions: -rwxr-xr-x
If not executable:
chmod +x .claude/hooks/pre-push-validation.sh
Workflow Integration
Recommended Git Workflow
- Make code changes - Implement features/fixes
- Commit code -
git commit -m "feat: Add new feature" - Update documentation - CHANGELOG.md, README.md, CLAUDE.md as needed
- Commit documentation -
git commit -m "docs: Document new feature" - Push -
git push(hook validates automatically)
Multi-Commit Sessions
If you have multiple commits:
# Commits in current session
git log origin/main..HEAD --oneline
# The hook checks documentation is newer than ALL unpushed commits
Best Practice: Update documentation as you go, not at the end.
Troubleshooting
"VALIDATION FAILED" Error
Problem: Documentation files are outdated compared to code commits.
Solution:
- Check which files need updating (listed in error message)
- Update those files with your changes
- Commit all changes (including user edits):
git add . && git commit -m "docs: Update documentation" - Try pushing again:
git push
"Has uncommitted changes" Warning
Problem: Documentation file has uncommitted changes.
Solution:
- Review changes:
git diff [file] - Stage all changes:
git add . - Commit changes:
git commit -m "docs: Update [file]" - Push:
git push
Hook Not Running
Problem: Push succeeds without validation.
Possible causes:
- Hook file not executable - Run:
chmod +x .claude/hooks/pre-push-validation.sh - Not in git repository - Verify:
git rev-parse --is-inside-work-tree - New branch without upstream - Expected behavior, validation skipped
Benefits
- Consistent Documentation - Forces documentation updates before push
- Better Change History - CHANGELOG.md always current
- Team Alignment - Everyone knows what changed and why
- AI Assistant Context - CLAUDE.md stays current with project changes
- Prevents "I forgot to document" - Automated validation reminder
Configuration
The hook is configured via critical files array in the script:
CRITICAL_FILES=(
"CLAUDE.md"
"README.md"
"CHANGELOG.md"
)
To add more files, edit .claude/hooks/pre-push-validation.sh and add to the array.
See Also
- Hook configuration:
.claude/hooks/CONFIG.md - Git hooks documentation:
.claude/hooks/README.md - CHANGELOG format:
CHANGELOG.md(see existing entries) - README structure:
README.md(top-level sections) - CLAUDE.md patterns:
CLAUDE.md(configuration patterns section)
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
Testing Blocks
Guide for testing code changes in AEM Edge Delivery projects including blocks, scripts, and styles. Use this skill after making code changes and before opening a pull request to validate functionality. Covers unit testing for utilities and logic, browser testing with Playwright/Puppeteer, linting, performance validation, and guidance on which tests to maintain vs use as throwaway validation.
template-skill
Replace with description of the skill and when Claude should use it.
Slack 动图 GIF 制作
slack-gif-creator
用于创建针对 Slack 优化的动图 GIF 的工具包,包含大小限制校验器和可组合的动画原语。当用户请求制作 Slack 用的动图 GIF 或表情动画时适用,例如“帮我做一个 X 做 Y 的 Slack GIF”。
Claude Code 技能开发与管理
skill-developer
遵循 Anthropic 最佳实践创建和管理 Claude Code 技能。在创建新技能、修改 skill-rules.json、理解触发模式、使用 hooks、调试技能激活,或实现渐进式披露时使用。涵盖技能结构、YAML frontmatter、触发类型(关键词、意图模式、文件路径、内容模式)、强制级别(block、suggest、warn)、hook 机制(UserPromptSubmit、PreToolUse)、会话跟踪以及 500 行规则。