AgentSkillsCN

commit

按照单体仓库的 Conventional Commits 标准进行提交,同时做好 GPG 签名、合理选择提交范围,并在提交前进行预检验证。对于涉及包变更的提交,还会贴心提醒用户关注变更集。无论是创建提交、撰写提交信息,还是应用户要求提交更改时,此技能都能为您提供有力支持。

SKILL.md
--- frontmatter
name: commit
description: Creates commits following the monorepo's Conventional Commits standard with proper GPG signing, scope selection, and pre-commit validation. Reminds about changesets for package changes. Use when creating commits, writing commit messages, or when the user asks to commit changes.

Commit Skill for UI Builder Monorepo

This skill guides committing changes following the project's Conventional Commits standard.

Critical Requirements

  1. Always run commits outside sandbox - Full shell permissions required for GPG signing and pre-commit hooks
  2. Never use --no-gpg-sign - All commits must be GPG-signed
  3. Never use --no-verify - Pre-commit hooks must run

Commit Format

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

[optional body]

[optional footer(s)]

Rules

RuleRequirement
Header max length100 characters
Subject caselowercase (never sentence-case, start-case, pascal-case, upper-case)
Subject endingNo period
ScopeRequired (scope-empty is enforced)
Body line lengthMax 100 characters
Body leading blankRequired if body present

Commit Types

TypeDescription
featNew feature
fixBug fix
docsDocumentation only
styleFormatting, whitespace (no code change)
refactorCode change that neither fixes a bug nor adds a feature
perfPerformance improvement
testAdding or correcting tests
buildBuild system or external dependencies
ciCI configuration changes
choreOther changes (not src or test)
revertReverts a previous commit
wipWork in progress (avoid if possible)

Allowed Scopes

The commitlint config enforces these scopes:

ScopeDescription
uiUI components and styling
apiAPI-related code
authAuthentication and authorization
builderBuilder app functionality
exportExport functionality
depsDependencies
configConfiguration files
ciCI/CD configuration
utilsUtility functions
docsDocumentation
testsTest-related changes
releaseRelease automation
adapterGeneric adapter changes
adapter-evmEVM adapter
adapter-evm-coreEVM core package
adapter-polkadotPolkadot adapter
adapter-solanaSolana adapter
adapter-stellarStellar adapter
adapter-midnightMidnight adapter
commonCommon/shared code

Extended Scopes (Update commitlint if needed)

These scopes are commonly used but may need to be added to commitlint.config.js:

  • spec / specs - Specification documents
  • adapters - Multiple adapters
  • changeset - Changeset files
  • core - Core functionality
  • form - Form-related code

Commit Workflow

bash
# 1. Stage changes
git add <files>

# 2. Commit with HEREDOC (recommended for multi-line messages)
git commit -m "$(cat <<'EOF'
feat(builder): add new contract template selector

Implements a dropdown component for selecting contract templates
with search functionality and categorization support.
EOF
)"

# Or use interactive Commitizen
pnpm commit

Changeset Reminder

Before committing changes to packages/ directory, check if a changeset is needed.

A changeset is required when:

  • Adding features to published packages
  • Fixing bugs in published packages
  • Making breaking changes

Check for existing changesets:

bash
ls .changeset/*.md

If no changeset exists for your changes, create one:

bash
pnpm changeset

Linked adapter packages (versioned together):

  • @openzeppelin/ui-builder-adapter-evm
  • @openzeppelin/ui-builder-adapter-evm-core (bundled, not published separately)
  • @openzeppelin/ui-builder-adapter-polkadot
  • @openzeppelin/ui-builder-adapter-solana
  • @openzeppelin/ui-builder-adapter-stellar
  • @openzeppelin/ui-builder-adapter-midnight

Pre-commit Hooks

The following checks run automatically:

  1. File permission check: Ensures correct file modes
  2. Formatting: Runs Prettier via pnpm fix-all
  3. Linting: Runs ESLint
  4. Re-staging: Auto-stages formatting fixes

If pre-commit fails, fix the issues and commit again.

Pre-push Hooks

Before pushing, these checks run:

  1. Linting: Full lint pass
  2. Adapter compliance: pnpm lint:adapters
  3. Export versions sync: Updates apps/builder/src/export/versions.ts if needed

If versions.ts is updated, you must amend your commit:

bash
git add apps/builder/src/export/versions.ts
git commit --amend --no-edit

Breaking Changes

Indicate breaking changes with ! after type/scope:

bash
feat(api)!: change response format to JSON

Or with a footer:

code
feat(api): change response format

BREAKING CHANGE: Response format changed from XML to JSON.
All clients must update their parsers.

Common Pitfalls

Sandbox Mode Errors

Symptom: Commit fails with permission errors, GPG signing fails, or hooks don't run.

Fix: Run commit commands with full shell permissions (outside sandbox).

Invalid Scope

Symptom: scope-enum error from commitlint.

Fix: Use one of the allowed scopes above, or update commitlint.config.js to add a new scope if justified.

Subject Case Error

Symptom: subject-case error.

Fix: Use lowercase for the entire subject:

  • Bad: Add new feature
  • Good: add new feature

Examples from Commit History

bash
# Feature with scope
feat(adapter-polkadot): add network icons for Polkadot ecosystem

# Fix with scope
fix(builder): correct ecosystem order in feature flag tests

# Refactor with scope
refactor(adapter-evm): migrate to use adapter-evm-core

# Chore without specific scope (use broader category)
chore: update export versions for ui-types 1.4.0 and ui-utils 1.1.1

# Documentation
docs(specs): update spec 008 and 009 for wallet extraction

# Performance improvement
perf(builder): fix slow dev server startup (minutes to seconds)

# With PR reference
feat(adapter-evm-core): Extract reusable EVM core modules (#309)

Quick Reference

bash
# Stage and commit interactively
git add . && pnpm commit

# Check commit format is valid
echo "feat(builder): add feature" | npx commitlint

# View recent commit formats for reference
git log --oneline -10

# Amend last commit (only if not pushed!)
git commit --amend