All skills
asyrafhussin avatar

/git-workflow

@b02a263

Git best practices, branching strategies, commit conventions, and PR workflows. Use when reviewing git history, writing commits, setting up branching strategy, or improving git practices. Triggers on "git best practices", "commit message", "branching strategy", or "PR workflow".

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/git-workflow

This session only. Nothing lands on disk.

rulescommit-git-hooks.md

≈721 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Git Hooks for Commit Enforcement

Use Git hooks to automatically enforce commit message standards and run checks before commits reach the repository.

Bad Example

# No hooks — bad commits reach the repo unchecked
git commit -m "fix"
git commit -m "wip"
git commit -m "asdfasdf"
# All accepted with no validation

# Manual-only enforcement — relies on discipline
# Team agrees to follow conventions but nothing enforces it
# One developer ignores conventions, pollutes history

Good Example

# Install Husky and commitlint
npm install --save-dev husky @commitlint/cli @commitlint/config-conventional

# Enable Husky
npx husky init

# Create commit-msg hook
echo "npx --no -- commitlint --edit \$1" > .husky/commit-msg
chmod +x .husky/commit-msg

# Create pre-commit hook for linting and tests
echo "npm run lint && npm run test:unit" > .husky/pre-commit
chmod +x .husky/pre-commit
// commitlint.config.js
module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      ['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore', 'ci', 'build', 'revert']
    ],
    'subject-max-length': [2, 'always', 72],
    'subject-case': [2, 'always', 'lower-case'],
    'body-max-line-length': [2, 'always', 100],
  },
};
// package.json — ensure hooks are installed on npm install
{
  "scripts": {
    "prepare": "husky"
  }
}
# Now bad commits are rejected automatically
git commit -m "fix"
# ✖   subject may not be empty [subject-empty]
# ✖   type may not be empty [type-empty]

git commit -m "feat(auth): add OAuth login"
# ✔   Commit message is valid

Why

Git hooks automate enforcement at the source, before bad commits reach the repository:

  1. Immediate Feedback: Developers know instantly if their commit message is wrong
  2. Zero Drift: Conventions are enforced consistently — no exceptions
  3. Automated Changelog: Properly formatted commits enable tools like semantic-release
  4. No CI Dependency: Catches issues locally before pushing, saving CI minutes
  5. Onboarding: New developers learn conventions through immediate feedback

Hook types commonly used:

Hook When Use For
commit-msg After writing message Validate commit format
pre-commit Before commit Lint, format, unit tests
pre-push Before push Integration tests, build check

Important: Add .husky/ to version control so all team members get the same hooks. The prepare script in package.json installs hooks automatically after npm install.

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    This skill provides a comprehensive and secure set of guidelines for managing Git workflows, including commit message standards, branching strategies, and pull request best practices. It promotes industry-standard tools and safety measures, such as protected branches and automated linting, with no malicious patterns detected.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • Runlayer6mo

    19/32 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at b02a263. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
metadata
{
  "author": "AsyrafHussin",
  "version": "1.2.0"
}

README badge

README badge for asyrafhussin/agent-skills/git-workflow