Skill: dougchambes/legend-git-helper (version 1.0.0)

--- name: git-helper description: "Git workflow automation for commits, pushes, rebases, status checks, and branch operations. Use when working with git repositories for: (1) Checking status, (2) Staging files, (3) Creating commits with conventional messages, (4) Pushing/pulling, (5) Rebasing/merging, (6) Viewing logs/diffs, or (7) Managing branches." --- # Git Helper Handles all git operations through safe, consistent workflows. ## Core Workflows ### Status Check Before any git operation, run `git status` to understand repository state. ### Staging - `git add <file>` - Stage specific files - `git add -A` - Stage all changes - `git add -p` - Interactive staging (review hunks) ### Committing Use Conventional Commits format: ``` <type>(<scope>): <description> [optional body] [optional footer] ``` **Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore` **Scope:** Optional, usually the component or area affected **Description:** Imperative present tense ("add feature" not "added feature") ### Push/Pull - `git push` - Push to remote (default: current branch) - `git pull --rebase` - Fetch and rebase (preferred default) - `git pull` - Fetch and merge (when merge history needed) ### Rebasing - `git rebase -i HEAD~N` - Interactive rebase last N commits - Always confirm branch state before rebasing - Never rebase shared/public branches without explicit permission ### Log/Diff - `git log --oneline -N` - View last N commits - `git diff` - Unstaged changes - `git diff --staged` - Staged changes - `git diff HEAD~N` - Changes over last N commits ## Safety Rules 1. **Never force push** without explicit user permission 2. **Always check status** before any operation 3. **Confirm destructive actions** (rebase, reset, hard, force push) 4. **Stay within workspace boundaries** - respect user's file access rules 5. **Pull before push** when working with shared branches ## When to Read references/workflows.md Load this reference file when: - User needs detailed Conventional Commits specification - Complex rebase/merge scenarios require guidance - Branch strategy consultation needed - Conflict resolution guidance required

path: references/workflows.md
content: # Git Workflows Reference

## Conventional Commits Specification

**Format:**
```
<type>(<scope>): <description>
```

**Optional extensions:**
- Body: Provide context, motivation, trade-offs
- Footer: Breaking changes, issue references

### Types

- `feat`: New feature
- `fix`: Bug fix
- `docs`: Documentation only
- `style`: Formatting, no code change
- `refactor`: Code restructuring, no behavior change
- `test`: Adding or fixing tests
- `chore`: Maintenance, tooling, deps

### Examples

```
feat(auth): add OAuth2 provider support

Implemented Google and GitHub OAuth providers.
Uses PKCE flow for security.

Closes #123
```

```
fix(parser): handle null values in JSON response

Added null checks before parsing nested objects.
Prevents TypeError on malformed API responses.
```

```
chore(deps): update axios to v1.6.0
```

## Branch Strategy

### Main Branches
- `main` / `master` - Production-ready code
- `develop` - Integration branch (optional)

### Feature Branches
```
git checkout -b feat/<feature-name>
# work...
git add -A
git commit -m "feat: implement feature"
git push -u origin feat/<feature-name>
# PR to main
```

### Hotfix Branches
```
git checkout -b hotfix/<issue> main
# fix...
git commit -m "fix: critical production issue"
git push -u origin hotfix/<issue>
# PR to main + develop
```

## Safe Rebase Workflow

1. **Check current state:**
   ```
   git status
   git log --oneline -5
   ```

2. **Backup branch:**
   ```
   git branch backup-<branchname>
   ```

3. **Interactive rebase:**
   ```
   git rebase -i HEAD~N
   ```

4. **Verify:**
   ```
   git log --oneline -5
   git diff HEAD~5
   ```

5. **Force push (only if safe):**
   ```
   git push --force-with-lease
   ```

## Conflict Resolution

1. **During rebase/merge:**
   ```
   git status  # shows conflicted files
   ```

2. **Manual edit:**
   - Open conflicted files
   - Resolve `<<<<<<<`, `=======`, `>>>>>>>` markers

3. **Mark resolved:**
   ```
   git add <resolved-file>
   ```

4. **Continue:**
   ```
   git rebase --continue
   # or
   git merge --continue
   ```

5. **Abort if needed:**
   ```
   git rebase --abort
   git merge --abort
   ```

## Daily Workflow

```bash
# Morning sync
git checkout main
git pull --rebase

# Start feature
git checkout -b feat/your-feature

# Work cycle
git add -p
git commit -m "feat: description"

# End of day
git push -u origin feat/your-feature
```

## Common Patterns

### Undo last commit (keep changes)
```
git reset --soft HEAD~1
```

### Discard last commit and changes
```
git reset --hard HEAD~1
```

### View commit history
```
git log --oneline --graph --all -20
```

### Stash changes
```
git stash
git stash list
git stash pop
```

Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: clean | SkillSpector: clean (LOW)