git-expert
Mastery of Git protocol: internal objects (blob, tree, commit, tag), content-addressable filesystem, safe history rewriting (interactive rebase, filter-repo), reflog for recovery, local and server-side hooks, guardrails against force-pushes, secret leak detection, signed commits (GPG/SSH), conventional commits, and branching strategies (trunk-based, GitHub Flow). Use when writing conventional commit messages, creating feature branches, handling merge conflicts, setting up git hooks, configuring commit signing, or enforcing push policies. Trigger: Git protocol, git merge, git rebase, git cherry-pick, git stash, git branch, git checkout, git diff, git log, conventional commits, signed commits. Do NOT trigger for: GitHub UI navigation or repository administration without Git command usage.
- License 许可
- MIT
- 最近更新
- 2026-08-27
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- git-expert
- license
- MIT
- metadata
- { "author": "Community", "status": "stable", "version": "1.0", "category": "infrastructure" }
- description
- Mastery of Git protocol: internal objects (blob, tree, commit, tag), content-addressable filesystem, safe history rewriting (interactive rebase, filter-repo), reflog for recovery, local and server-side hooks, guardrails against force-pushes, secret leak detection, signed commits (GPG/SSH), conventional commits, and branching strategies (trunk-based, GitHub Flow). Use when writing conventional commit messages, creating feature branches, handling merge conflicts, setting up git hooks, configuring commit signing, or enforcing push policies. Trigger: Git protocol, git merge, git rebase, git cherry-pick, git stash, git branch, git checkout, git diff, git log, conventional commits, signed commits. Do NOT trigger for: GitHub UI navigation or repository administration without Git command usage.
02 资源文件 3
- 参考文档evals/evals.json2.0 KB
- 参考文档references/recovery.md561 B
- 参考文档references/workflows.md570 B
03 SKILL.md 正文
Git Expert
Git protocol: commits, branching, hooks, security and recovery.
Core Stack
- Protocol: Smart HTTP, SSH, Git protocol
- Internals: Objects (blob, tree, commit, tag), packfiles, reflog
- Branching: Trunk-Based Development (default for cloud-native projects), GitHub Flow
- Safety: --force-with-lease, signed commits (GPG/SSH), git-secrets/gitleaks
- Conventions: Conventional Commits (default for cloud-native projects)
Conventional Commits
type(scope): description
[optional body]
[optional footer(s)]
| Type | Use |
|---|---|
feat |
New feature (MINOR semver) |
fix |
Bug fix (PATCH semver) |
refactor |
Code restructure, no behavior change |
perf |
Performance improvement |
test |
Adding/updating tests |
docs |
Documentation only |
chore |
Maintenance, deps, config |
ci |
CI/CD changes |
build |
Build system changes |
revert |
Revert previous commit |
feat(api): add idempotency key support to resource creation
Implements idempotency key validation with 24h deduplication window.
Uses Redis to store key -> response mapping with TTL.
Closes #1234
Signed Commits
# GPG signing
git config --global commit.gpgsign true
git config --global user.signingkey <KEY_ID>
# SSH signing (GitHub)
git config --global gpg.format ssh
git config --global commit.gpgsign true
git config --global user.signingkey ~/.ssh/id_ed25519.pub
Branching Strategy
# Trunk-Based Development (recommended)
main # production-ready, always deployable
feat/<slug> # short-lived feature branch
fix/<slug> # short-lived bug fix
Protected branches
The following branch names are protected and MUST NEVER be used as a new feature/fix branch name, nor pushed to directly:
mainmasterdevelopdevelopmentstagingsandbox
Always create a prefixed branch (feat/<slug>, fix/<slug>, refactor/<slug>,
docs/<slug>, test/<slug>) instead. If the chosen name collides with a
protected branch, pick a different prefixed name before creating it.
Safety Guardrails
# NEVER use --force on shared branches
git push --force-with-lease origin main # safer force push
# Recover lost commits via reflog
git reflog
git checkout HEAD@{2} # go back 2 operations
git branch recovered-branch HEAD@{2}
# Undo last commit (keep changes)
git reset --soft HEAD~1
Secrets Prevention
# Pre-commit hook to detect secrets
# .git/hooks/pre-commit
#!/bin/bash
if git-secrets --scan; then
echo "No secrets found"
else
echo "Secret detected! Commit blocked."
exit 1
fi
Conflict Resolution
git pull --rebase origin main
# Resolve conflicts in each file
git add <resolved-file>
git rebase --continue
git push --force-with-lease origin feat/my-branch
Constraints
- NEVER force push to main/master (use --force-with-lease on feature branches only)
- NEVER push without signed commits configured in repos
- NEVER use git add -A / git add . without reviewing changes first
- NEVER commit secrets, .env files, or credentials (even in test fixtures)
- ALWAYS use conventional commit format for all repos
- ALWAYS pull --rebase before push to avoid merge bubbles
- NEVER commit directly to main (always via PR) in protected repos
- NEVER create a branch whose name equals a protected branch (main, master, develop, development, staging, sandbox)
- ALWAYS ask for explicit user confirmation before
git push(push is an ask-gated operation)
Overview
Master Git protocol: objects (blob, tree, commit, tag), safe history rewriting (interactive rebase, filter-repo), reflog for recovery, local and server-side hooks, signed commits (GPG/SSH), conventional commits, secret leak detection, and branching strategies (trunk-based, GitHub Flow).
Quick Reference
| Operation | Command | Safety |
|---|---|---|
| Force push | git push --force-with-lease | Safer than --force (checks remote) |
| Undo last commit | git reset --soft HEAD~1 | Keeps changes staged |
| Recover loss | git reflog + git checkout | Works for 90 days by default |
| Signed commit | git commit -S | GPG or SSH signature |
| Secret scan | git-secrets --scan | Pre-commit hook prevents leaks |
Workflow
- Create short-lived feature branch:
feat/<slug>orfix/<slug> - Make small commits with conventional commit format
- Pull --rebase before push to avoid merge bubbles
- Push with
--force-with-leaseif rebasing a feature branch - Open PR for code review (never commit directly to main)
- Squash merge via PR to keep main history clean
Anti-patterns
FAIL: Force pushing to shared branches without --force-with-lease
# BAD: overwrites remote changes without warning
git push --force origin main
# GOOD: fails if remote has new commits
git push --force-with-lease origin main
FAIL: Committing secrets and pushing before detection
# BAD: secret in commit
git add . && git commit -m "fix: update config"
# Oops — .env was included
# GOOD: pre-commit hook blocks secrets
cat > .git/hooks/pre-commit << 'EOF'
#!/bin/bash
git-secrets --scan || exit 1
EOF
FAIL: Using git add -A without reviewing changes
# BAD: blindly stage everything
git add -A
# GOOD: review before staging
git status
git add -p # interactive patch staging
References
-
Conventional Commits: https://www.conventionalcommits.org/ (last_verified: 2026-05)
-
Git documentation: https://git-scm.com/doc (last_verified: 2026-05)
-
GitHub secret scanning: https://docs.github.com/en/code-security/secret-scanning (last_verified: 2026-05)
Verification Checklist
- [ ] Conventional commit format used:
type(scope): description - [ ] Signed commits configured (GPG or SSH) for cloud-native repos
- [ ]
git push --force-with-leaseused instead of--forceon shared branches - [ ] Pre-commit hook installed for secret detection (
git-secretsorgitleaks) - [ ] No
.env, credentials, or secrets staged before commit (reviewed withgit status+git diff) - [ ]
git pull --rebaseused before push to avoid merge bubbles - [ ] Never committing directly to
main— always via PR for protected repos
Troubleshooting
| [WARN] Known issue | Likely cause | Fix |
|---|---|---|
git push --force-with-lease rejected |
Remote branch has commits you haven't pulled | Pull first: git pull --rebase origin feat/my-branch, resolve conflicts, push again |
| Secret detected after commit pushed | .env, .pem, or credentials included in commit; no pre-commit hook |
Use git filter-repo to remove from history; rotate exposed secrets; add pre-commit hook |
GPG signing fails with unusable secret key |
GPG key expired or not on this machine | Generate new key: gpg --full-generate-key; add to GitHub: gpg --armor --export <KEY_ID> | pbcopy |
| Merge conflict on rebase is confusing | Large PR with many commits touching same files | Use git rebase --interactive to squash related commits; resolve conflicts incrementally |
git filter-repo rewrites author dates even when only content changes (known limitation) |
filter-repo default behavior converts author and committer timestamps to current time | Use --refetch or force date preservation with custom callback; document original timestamps before running |
04 同仓库更多 Skills
web-browsing-agent-expert
Web browsing for AI agents: driving a headless browser (Playwright, Puppeteer) from agent tooling, navigation and page-state grounding, DOM extraction and structured data capture, form interaction, session and cookie management, anti-bot mitigation awareness, and safe browsing rules (no PII exfiltration, respect robots and terms). Use when building a browsing tool or MCP server for an agent, teaching an agent to navigate and read web pages, extracting structured content from dynamic sites, or handling login walls and pagination in agent workflows. Trigger: web browsing agent, headless browser, Playwright MCP, Puppeteer, browser automation for agents, DOM extraction, page navigation, session management. Do NOT trigger for: end-to-end UI testing of an application (use playwright-expert); writing standalone scraping scripts for data pipelines (use python-expert); fetching a single public URL (use the fetch tool).
vector-databases
Design and operate vector databases for cloud-native AI features. Use when selecting between pgvector, Pinecone, or Weaviate for AI context layer or integration-hub; designing embedding schemas and index parameters; implementing ANN search with metadata filtering; managing embedding model versions; optimizing query latency; or debugging low retrieval quality. Pairs with rag-architecture for pipeline design and postgres-database-expert for pgvector specifics. Trigger: vector database, pgvector, Pinecone, Weaviate, embedding, ANN search, HNSW, cosine similarity. Do NOT trigger for: relational SQL optimization, standard PostgreSQL schema design, Redis caching.
typescript-expert
Full-stack TypeScript stack for modern projects: frontend SSR/CSR with Next.js 14 App Router and React, backend APIs with Node.js (Express/Fastify), state management with Zustand/Redux Toolkit, unit and integration testing with Vitest/Jest + React Testing Library + MSW, and static analysis with ESLint/Prettier/tsc. Use when building React components or hooks, implementing Next.js App Router or Server Components, writing Node.js REST API handlers, implementing middleware (auth, rate-limit, logging), managing client state (Zustand/RTK), writing frontend/backend tests, or running TypeScript linting/type checks. Trigger: TypeScript, Next.js, React, Zustand, Node.js, Express, Fastify, MSW, Vitest. Do NOT trigger for: Python backend development, Go microservices, iOS/mobile development.
tool-usage
Guide correct tool selection, design, and orchestration for AI agents. Use when choosing between dedicated vs Bash tools, designing MCP tool interfaces, naming tool parameters, handling tool response limits, orchestrating parallel vs sequential calls, evaluating tool accuracy, applying ACI design principles, selecting workflow patterns, or reading/filtering/transforming/generating structured data (JSON, YAML, CSV, TOML, XML). Trigger: tool selection, MCP tool design, orchestration, ACI, parallel execution, composite tool, structured data, jq, yq, dasel, mlr, csvkit. Do NOT trigger for: writing application business logic, domain-specific development (route to domain skill), database migrations.
token-efficiency
Enforce token-efficient output, compression, caching, and model routing. Use when calibrating response verbosity, applying compression strategies to logs or RAG chunks, routing tasks to the right model tier, setting thinking budgets, enforcing word limits, compressing context before reinitiation, applying KV-cache ordering, masking tool output observations, or applying clarification-first protocol before irreversible actions. Trigger: token efficiency, compression, model routing, thinking budget, KV-cache, clarification protocol. Do NOT trigger for: non-agent tooling, CI/CD pipeline scripting, infrastructure provisioning.
time-series-db
Time-series database patterns for cloud-native metrics and analytics: TimescaleDB, InfluxDB, and Amazon Timestream selection; continuous aggregates, retention policies, downsampling, and integration with Prometheus/Grafana. Use when storing business metrics over time, building custom business dashboards, designing high-frequency event storage, or querying time-bucketed aggregations. Trigger: time-series, TimescaleDB, InfluxDB, Prometheus, Grafana, hypertable, continuous aggregate, retention policy. Do NOT trigger for: relational PostgreSQL schema design, NoSQL document stores, Kafka event streaming.