We use tracking cookies to understand how you use the product and help us improve it. For more information on how we store cookies, read our  privacy policy.

Git Workflow

Branching strategy, commit conventions, and automated hooks

Plainform uses Husky for Git hooks and Commitlint for enforcing conventional commit messages. This ensures code quality and consistent commit history.

Commit Message Format

All commits must follow the Conventional Commits specification:

<type>(<scope>): <subject>

[optional body]

[optional footer]

Commit Types

TypeDescriptionExample
featNew featurefeat(auth): add OAuth login
fixBug fixfix(stripe): handle webhook timeout
docsDocumentation changesdocs(readme): update setup guide
styleCode style changes (formatting)style: fix indentation
refactorCode refactoringrefactor(api): simplify error handling
perfPerformance improvementsperf(db): optimize query
testAdding or updating teststest(auth): add login tests
buildBuild system changesbuild: update dependencies
ciCI/CD changesci: add deployment workflow
choreMaintenance taskschore: update gitignore
revertRevert previous commitrevert: undo feature X
securitySecurity fixessecurity: patch XSS vulnerability

The scope is optional but recommended for clarity (e.g., auth, stripe, db, ui).

Commit Rules

Header (first line):

  • Maximum 100 characters
  • Lowercase type and scope
  • No period at the end
  • Use imperative mood: "add" not "added" or "adds"

Body (optional):

  • Blank line after header
  • Maximum 100 characters per line
  • Explain what and why, not how

Footer (optional):

  • Blank line after body
  • Reference issues: Closes #123 or Fixes #456
  • Breaking changes: BREAKING CHANGE: description

Examples

Simple commit:

Simple commit example
git commit -m "feat(pricing): add annual subscription option"

Commit with body:

Commit with body example
git commit -m "fix(webhook): handle duplicate events" -m "Stripe can send duplicate webhook events during retries. Added idempotency check using event ID to prevent duplicate processing."

Breaking change:

Breaking change example
git commit -m "feat(api): change authentication endpoint" -m "BREAKING CHANGE: /api/auth endpoint moved to /api/v2/auth. Update all client applications to use new endpoint."

Git Hooks

Plainform uses Husky to run automated checks before commits and pushes.

Pre-Commit Hook

Runs before every commit to ensure code quality:

.husky/pre-commit
npm run lint

What it does:

  • Runs ESLint on all files
  • Checks for syntax errors
  • Enforces code style rules

If it fails:

  • Fix linting errors: npm run lint:fix
  • Review and fix remaining issues manually
  • Commit again

Commits are blocked if linting fails. This prevents broken code from entering the repository.

Commit-Msg Hook

Validates commit message format:

.husky/commit-msg
npx --no -- commitlint --edit

What it does:

  • Checks commit message follows Conventional Commits
  • Validates type, scope, and subject format
  • Enforces character limits

If it fails:

  • Review error message for specific issue
  • Amend commit message: git commit --amend
  • Follow the format rules above

Pre-Push Hook

Runs before pushing to remote:

.husky/pre-push
npm run build

What it does:

  • Runs full production build
  • Catches build errors before pushing
  • Ensures code compiles successfully

If it fails:

  • Fix build errors shown in output
  • Test locally: npm run build
  • Push again after fixing

Pre-push hook can take 30-60 seconds. This prevents pushing broken code to the repository.

Branching Strategy

Branch Naming

Use descriptive branch names with prefixes:

<type>/<short-description>

Examples:

  • feat/oauth-login
  • fix/stripe-webhook-timeout
  • docs/update-readme
  • refactor/api-error-handling

Create Feature Branch

Create feature branch
git checkout -b feat/new-feature

Work on your feature in isolation from main branch.

Make Changes and Commit

Make changes and commit
git add .
git commit -m "feat(scope): add new feature"

Hooks run automatically to validate your commit.

Keep Branch Updated

Keep branch updated
git checkout main
git pull origin main
git checkout feat/new-feature
git rebase main

Rebase regularly to avoid merge conflicts.

Push to Remote

Push to remote
git push origin feat/new-feature

Pre-push hook runs build to catch errors.

Create Pull Request

Open PR on GitHub/GitLab for code review.

Merge and Clean Up

Merge and clean up
git checkout main
git pull origin main
git branch -d feat/new-feature

Delete local branch after merging.

Bypassing Hooks

Not recommended, but sometimes necessary:

Skip hooks (not recommended)
# Skip pre-commit hook
git commit --no-verify -m "fix: emergency hotfix"

# Skip pre-push hook
git push --no-verify

Only bypass hooks for emergency fixes. Always fix issues properly afterward.

Troubleshooting

Configuration Files

Commitlint Config

commitlint.config.ts
module.exports = {
  extends: ['@commitlint/config-conventional'],
  rules: {
    'type-enum': [
      2,
      'always',
      [
        'build', 'chore', 'ci', 'docs', 'feat',
        'fix', 'perf', 'refactor', 'revert',
        'style', 'test', 'security'
      ],
    ],
    'header-max-length': [2, 'always', 100],
    'body-max-line-length': [2, 'always', 100],
  },
};

Husky Setup

package.json
{
  "scripts": {
    "prepare": "husky"
  }
}

The prepare script runs automatically after npm install to set up Git hooks.

Best Practices

Commit Often:

  • Small, focused commits are easier to review
  • Each commit should represent one logical change
  • Makes debugging and reverting easier

Write Clear Messages:

  • Explain what and why, not how
  • Future you will thank present you
  • Helps team understand changes

Keep Branches Short-Lived:

  • Merge feature branches within 1-2 days
  • Reduces merge conflicts
  • Faster feedback from team

Review Before Pushing:

  • Run npm run build locally
  • Test your changes
  • Review diff: git diff

Use .gitignore:

  • Never commit .env files
  • Exclude node_modules/, .next/, build artifacts
  • Keep repository clean

Next Steps

How is this guide ?

Last updated on