AgentSkillsCN

fse-git-workflow

使用Conventional Commits、Husky钩子与代码静态分析,指导您规范地向Oh My Brand!提交代码。在提交更改、推送至远程仓库,或修复预提交代码静态分析失败时,请使用本指南。

SKILL.md
--- frontmatter
name: fse-git-workflow
description: Guide for committing to Oh My Brand! using Conventional Commits, Husky hooks, and linting. Use this when making commits, pushing to remote, or fixing pre-commit linting failures.
metadata:
  author: Wesley Smits
  version: "1.0.0"

FSE Git Workflow

Git workflows, Conventional Commits, Husky pre-commit hooks, and CI/CD for the Oh My Brand! FSE theme.


When to Use

  • Making commits to the repository
  • Creating feature branches
  • Fixing pre-commit linting failures
  • Understanding CI/CD pipeline requirements
  • Creating pull requests
  • Releasing new versions

Reference Files

FilePurpose
ci.ymlGitHub Actions CI workflow
PULL_REQUEST_TEMPLATE.mdPR template

Development Workflow

Initial Setup

bash
# Clone and install
git clone git@github.com:WesleySmits/oh-my-brand-wp-fse.git
cd oh-my-brand-wp-fse
pnpm install && composer install
pnpm run prepare

# Verify
pnpm run lint && pnpm test && composer test

Daily Flow

bash
# 1. Start from main
git checkout main && git pull origin main

# 2. Create feature branch
git checkout -b feature/gallery-lightbox

# 3. Develop with watch mode
pnpm run watch

# 4. Lint and test before commit
pnpm run lint:fix && pnpm test && composer test

# 5. Commit (triggers hooks)
git commit -m "feat(gallery): Add lightbox functionality"

# 6. Push and create PR
git push -u origin feature/gallery-lightbox

Environment Commands

CommandPurpose
pnpm run buildProduction build
pnpm run watchDevelopment watch mode
pnpm run lintRun all linters
pnpm run lint:fixFix linting issues
pnpm testRun JS/TS tests
pnpm run test:e2eRun E2E tests
composer testRun PHP tests
composer lint:fixFix PHP issues

Conventional Commits

Format

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

[optional body]

[optional footer(s)]

Commit Types

TypeDescriptionExample
featNew featurefeat(gallery): Add zoom functionality
fixBug fixfix(faq): Resolve accordion collapse issue
docsDocumentation onlydocs(readme): Update installation steps
styleFormatting, CSS (no logic)style(css): Fix BEM class indentation
refactorCode refactoringrefactor(carousel): Simplify state
perfPerformance improvementperf(images): Implement lazy loading
testAdding/updating teststest(gallery): Add navigation tests
buildBuild system or depsbuild(vite): Upgrade to version 6.1
ciCI configurationci(github): Add e2e job
choreMaintenance taskschore(deps): Update dependencies

Scopes

ScopeUse For
blocksBlock-related changes
gallery, faq, hero, etc.Specific block
themeTheme configuration
assetsCSS/JS assets
depsDependencies
ciCI/CD

Subject Rules

RuleRequirement
CaseSentence case (capitalize first letter)
EmptySubject cannot be empty
Full stopNo period at the end
Max lengthHeader max 100 characters

Branch Naming

Format

code
<type>/<description>
TypeUse ForExample
feature/New featuresfeature/gallery-lightbox
fix/Bug fixesfix/carousel-navigation
docs/Documentationdocs/update-readme
refactor/Code refactoringrefactor/optimize-helpers
test/Test additionstest/add-faq-tests
chore/Maintenancechore/update-dependencies

Git Hooks (Husky)

Hook: pre-commit

Runs lint-staged on staged files:

  • ESLint for *.ts, *.js, *.tsx, *.jsx
  • Stylelint for *.css
  • PHPCS for *.php
  • Prettier for formatting

Hook: commit-msg

Validates commit message format with commitlint.

What Happens When You Commit

  1. pre-commit runs lint-staged on staged files
  2. commit-msg validates message format
  3. ✅ All pass → Commit succeeds
  4. ❌ Any fail → Commit aborted, fix errors and retry

Reinstall Hooks

bash
rm -rf .husky/_
pnpm run prepare

Pre-Commit Checklist

  • pnpm run lint passes
  • pnpm run lint:fix applied
  • pnpm test passes
  • composer test passes
  • Commit message follows Conventional Commits
  • Branch is up-to-date with main

Pull Request Process

  1. Push branch to remote
  2. Create PR on GitHub from feature branch to main
  3. Fill template (see PULL_REQUEST_TEMPLATE.md)
  4. CI runs - all checks must pass
  5. Request review from maintainer
  6. Squash merge to main after approval

PR Best Practices

PracticeDescription
Small PRsKeep changes focused
Descriptive titlesUse Conventional Commit format
Link issuesReference related GitHub issues
Add screenshotsFor visual changes

CI/CD Pipeline

Pipeline Jobs

See ci.yml for the full workflow.

JobPurpose
commitlintValidate commit messages
lint-jsESLint + Stylelint
lint-phpPHPCS with WordPress standards
test-unit-jsVitest with coverage
test-unit-phpPHPUnit
test-e2ePlaywright with wp-env
buildProduction build verification

Required Status Checks

All checks must pass before merging:

  • ✅ commitlint
  • ✅ lint-js
  • ✅ lint-php
  • ✅ test-unit-js
  • ✅ test-unit-php
  • ✅ test-e2e
  • ✅ build

Release Process

Semantic Versioning

code
MAJOR.MINOR.PATCH

MAJOR → Breaking changes
MINOR → New features (backward compatible)
PATCH → Bug fixes (backward compatible)

Creating a Release

bash
# 1. Ensure main is up to date
git checkout main && git pull origin main

# 2. Update version in: style.css, package.json, functions.php

# 3. Update CHANGELOG.md

# 4. Commit version bump
git commit -m "chore(release): Bump version to 1.2.0"

# 5. Create and push tag
git tag -a v1.2.0 -m "Release version 1.2.0"
git push origin main --tags

# 6. Create GitHub release

Troubleshooting

Commit Message Errors

"type must be one of..."

bash
# ❌ Wrong
git commit -m "added new button block"

# ✅ Correct
git commit -m "feat(blocks): Add new button block"

"subject must be sentence-case"

bash
# ❌ Wrong
git commit -m "feat(gallery): add lightbox"

# ✅ Correct
git commit -m "feat(gallery): Add lightbox"

Lint Errors

bash
# Fix all linting issues
pnpm run lint:fix

# Fix PHP issues
composer lint:fix

# Stage fixes and retry
git add . && git commit -m "feat(blocks): Add feature"

Git Hook Issues

bash
# Reinstall hooks
rm -rf .husky/_
pnpm run prepare

Bypass Hooks (Emergency Only)

bash
git commit -m "fix(urgent): Emergency fix" --no-verify
# Note: CI will still run all checks

Related Skills


References