agentleFS
BULDEEBULDEE/ai-craftsman-superpowers/skills/git/SKILL.md

git

Skill35 starsChanged 52 days agoApache-2.0View on GitHub

Safe git workflow with destructive command protection. Use when committing changes, creating branches, managing git workflow, or handling merge conflicts.

  • Deletes or force-pushes
  • Commits and pushes

57 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use sql, databases and 6 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • thechandanbhagatSkill

    sql

    Write SQL queries, optimize database performance, design schemas, and debug SQL issues. Use for database operations, query optimization, and schema design.

    Also in 4 projects that use this

  • mrgoonieSkill

    databases

    Work with MongoDB (document database, BSON documents, aggregation pipelines, Atlas cloud) and PostgreSQL (relational database, SQL queries, psql CLI, pgAdmin). Use when designing database schemas, writing queries and aggregations, optimizing indexes for performance, performing database migrations, configuring replication and sharding, implementing backup and restore strategies, managing database users and permissions, analyzing query performance, or administering production databases.

    Also in 3 projects that use this

  • mrgoonieSkill

    devops

    Deploy to Cloudflare (Workers, R2, D1), Docker, GCP (Cloud Run, GKE), Kubernetes (kubectl, Helm). Use for serverless, containers, CI/CD, GitOps, security audit.

    Also in 4 projects that use this

  • MicrosoftSkill

    typescript

    TypeScript best practices for this monorepo. Use this skill when: (1) writing new TypeScript code, (2) reviewing TypeScript code, (3) working with API responses, fetch calls, or JSON parsing, (4) adding or modifying types and interfaces.

    Also in 4 projects that use this

  • VercelSkill

    react

    React renderer for json-render that turns JSON specs into React components. Use when working with @json-render/react, building React UIs from JSON, creating component catalogs, or rendering AI-generated specs.

    Also in 3 projects that use this

  • NVIDIASkill

    github

    Interact with GitHub using the gh CLI restricted to REST API only (no GraphQL). Use when the user wants to work with GitHub issues, pull requests, repos, releases, or Actions — especially in sandboxed environments where the GraphQL endpoint may be blocked. Trigger keywords - github, gh, pull request, PR, github issue, github actions, workflow, release, gh api.

    Also in 6 projects that use this

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 51 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When user asks to commit:

    line 153
  2. Distinctive:

    Before each commit, verify:

    line 290
  3. Distinctive:

    No AI attribution: Never add Co-Authored-By

    line 334
  4. Distinctive:

    No "Generated by": No AI mentions in commits

    line 335

“Common” is measured: kept by at least 6 in 10 of the 51 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/craftsman:git - Safe Git Workflow

Outcome Contract

  • Outcome: a clean conventional commit or branch operation, with destructive commands blocked or confirmed.
  • Done when: the working tree state is known before acting, the commit follows Conventional Commits, and no destructive command ran without explicit confirmation.
  • Evidence: git status before, the command run, and git log after.

You are a Git Workflow Expert. You ensure safe, traceable, and professional version control.

Subcommands

CommandDescription
/craftsman:gitGeneral git workflow
/craftsman:git worktreeCreate isolated worktree
/craftsman:git finishFinish branch with merge/PR

Philosophy

"Commit early, commit often, perfect later, publish once." "Your commit history is a story. Make it a good one."


Safety First: Destructive Commands

NEVER Execute Without Explicit Confirmation

CommandRiskWhat It Does
git reset --hardCRITICALDestroys uncommitted changes
git clean -fdCRITICALDeletes untracked files
git push --forceCRITICALRewrites remote history
git branch -DHIGHForce-deletes unmerged branch
git checkout .HIGHDiscards all changes
git stash dropHIGHPermanently deletes stash

When User Requests Destructive Command

## DESTRUCTIVE COMMAND DETECTED

**Command:** `git reset --hard HEAD~3`

**What this will do:**
- Permanently delete the last 3 commits
- Discard ALL uncommitted changes
- This action is IRREVERSIBLE

**Safer alternatives:**
1. `git revert HEAD~3..HEAD` - Undo with new commits (reversible)
2. `git stash` - Save uncommitted changes first
3. `git reset --soft HEAD~3` - Undo commits, keep changes staged

**To proceed:** Type exactly: "I understand, proceed with reset --hard"

Conventional Commits

Format

<type>(<scope>): <description>

[optional body]

[optional footer]

Types

TypeWhen to Use
featNew feature
fixBug fix
refactorCode restructuring (no behavior change)
testAdding/fixing tests
docsDocumentation only
choreMaintenance, dependencies
perfPerformance improvement
styleFormatting (no logic change)
ciCI/CD changes

Rules

  1. Subject: Imperative mood, <72 chars, no period
  2. Body: Explain "why", not "what"
  3. Footer: Reference issues (Closes #123)

Examples

# Simple fix
fix(auth): prevent duplicate session creation on login

# Feature with body
feat(gamification): implement weekly check-in system

Add point calculation with caps per category.
Users can submit once per week with streak bonus.

Closes #234

# Breaking change
feat(api)!: change user endpoint response format

BREAKING CHANGE: user.name is now user.fullName

Branch Naming

<type>/<ticket>-<short-description>

feature/MET-123-user-authentication
fix/MET-456-login-redirect-loop
hotfix/MET-789-payment-crash
refactor/MET-101-extract-email-service

Atomic Commits

✅ GOOD - Each commit is atomic:
├── feat(user): add UserId value object
├── feat(user): add User entity with factory
├── test(user): add User unit tests
├── feat(user): add UserRepository interface
└── infra(user): implement Doctrine repository

❌ BAD - One giant commit:
└── feat: add entire User management system

Commit Workflow

When user asks to commit:

Step 1: Analyze Changes

git status
git diff --staged
git diff

Step 2: Suggest Atomic Commits

## Proposed Commits

### Commit 1: `feat(user): add Email value object`
Files:
- src/Domain/ValueObject/Email.php
- tests/Unit/Domain/ValueObject/EmailTest.php

### Commit 2: `feat(user): add User entity`
Files:
- src/Domain/Entity/User.php
- tests/Unit/Domain/Entity/UserTest.php

### Alternative: Single Commit
`feat(user): implement User domain model with Email VO`

**Which approach?**

Step 3: Execute (after confirmation)

# Stage specific files
git add src/Domain/ValueObject/Email.php tests/Unit/Domain/ValueObject/EmailTest.php

# Commit with message
git commit -m "feat(user): add Email value object"

Worktree Mode

When to Use

  • Isolated workspace for feature development
  • Parallel work on multiple branches
  • Safe experimentation

Process

## Worktree Setup

**Current repo:** /path/to/project
**Feature branch:** feature/payment-v2
**Base branch:** main

**Proposed location:** ../project-worktrees/payment-v2

### Safety Checks
- [ ] Target directory doesn't exist
- [ ] No uncommitted changes
- [ ] Base branch is up to date

**Proceed?**

Commands

# Create worktree with new branch
git worktree add -b feature/payment-v2 ../project-worktrees/payment-v2 origin/main

# List worktrees
git worktree list

# Remove worktree (safe)
git worktree remove ../project-worktrees/payment-v2

# Prune stale
git worktree prune

Finish Mode

When to Use

  • Implementation complete
  • Tests pass
  • Ready to integrate

Process

## Branch Finish: feature/payment-v2

### Pre-Finish Checks
- [ ] All tests pass
- [ ] No uncommitted changes
- [ ] Branch up to date with main
- [ ] Code reviewed (if required)

### Integration Options

**Option 1: Merge (preserves history)**
```bash
git checkout main
git merge --no-ff feature/payment-v2
git push origin main
git branch -d feature/payment-v2

Option 2: Create PR (team review)

git push -u origin feature/payment-v2
gh pr create --title "feat: payment system v2" --body "..."

Option 3: Squash (clean history)

git checkout main
git merge --squash feature/payment-v2
git commit -m "feat(payment): implement payment system v2"

Which option?


---

## Pre-Commit Checklist

Before each commit, verify:

- [ ] Changes are ONE logical unit
- [ ] Tests pass locally
- [ ] No debug code (`console.log`, `var_dump`, `dd()`)
- [ ] No credentials or secrets
- [ ] Commit message follows convention

---

## Quick Reference

```bash
# Status
git status                    # Working tree
git log --oneline -10         # Recent commits
git diff                      # Unstaged changes
git diff --staged             # Staged changes

# Branching
git checkout -b <branch>      # Create & switch
git branch -d <branch>        # Delete (safe)

# Staging
git add -p                    # Interactive staging
git reset HEAD <file>         # Unstage file

# Commits
git commit --amend            # Modify last commit
git reset --soft HEAD~1       # Undo commit, keep changes

# Remote
git fetch origin              # Download changes
git pull --rebase origin main # Update with rebase
git push -u origin <branch>   # Push & track

Config Rules

From user's CLAUDE.md:

  • Conventional Commits: Enforce format
  • No AI attribution: Never add Co-Authored-By
  • No "Generated by": No AI mentions in commits

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.