Contribution Guidelines & Testing
Step-by-step contribution workflows, local setup, test execution, template synchronization, and pull request requirements for ForgeWP.
We welcome contributions to ForgeWP. Whether you are fixing a compiler edge case, improving data hooks, enhancing CLI generators, or refining documentation, this guide details our development standards, testing workflows, and pull request process.
1. Getting Started Locally
Prerequisites
Ensure your development machine meets these requirements before cloning:
- Node.js: Match the installed dependency engines. For current compiler dependencies, use
22.18+in the22.xline or24.11+in the24.xline; see System Requirements. - PNPM: v9.0.0 or higher (
npm install -g pnpm). - Git: Installed and configured.
Fork & Clone
# Clone your fork
git clone https://github.com/<your-username>/forgewp.git
cd forgewp
# Install dependencies across all workspace packages
pnpm install
# Start the local development testbed
pnpm devThe dev server will boot packages/starter at http://localhost:5173. Any changes made inside packages/react/src or packages/compiler/lib will trigger instant Hot Module Replacement (HMR).
2. Testing Workflows
ForgeWP enforces strict automated testing and manual verification before merging changes.
Automated Test Suites
Run the compiler adapter and runtime test suites:
# Run adapter contract and typing tests
pnpm test:compiler-adapters
# Test create-forgewp interactive scaffolder
pnpm test:create
# Test create-forgewp HTML adapter scaffolder
pnpm test:create-htmlTo run package-specific test suites using Vitest:
# Run compiler unit tests
cd packages/compiler
pnpm testProduction Export Testing
Whenever you modify @forgewp/compiler or @forgewp/react, you must verify that the production export pipeline completes cleanly:
# Run production export in the testbed
pnpm exportInspect the generated output in packages/starter/.forgewp/out/:
- Check that
style.csscontains correct theme headers. - Check that
theme.jsoncontains valid v3 JSON syntax. - Check that
functions.phpproperly enqueues styles and scripts without PHP syntax errors. - Verify that generated templates (
index.php,single.php,archive.php) produce valid PHP tags.
Verification in Live WordPress
For runtime changes (e.g. hydration islands, Gutenberg blocks, form endpoints), test the exported theme in a local WordPress environment (such as LocalWP, WordPress Studio, or Docker):
# Install and activate the exported theme using WP-CLI
wp theme install packages/starter/.forgewp/out/*.zip --activateVerify:
- Theme activates without PHP errors or warnings.
- The homepage and subpages render without White Screen of Death (WSOD).
- Custom Gutenberg blocks appear in the editor inserter and save without block validation errors.
- Client hydration islands activate upon their designated trigger conditions.
3. Starter Template Synchronization
When users scaffold a new project with npm create forgewp@latest, the CLI copies files from packages/create-forgewp/template/.
To ensure the published template stays synchronized with the canonical testbed in packages/starter/, you must run the template sync script after editing starter files:
pnpm sync:templateIf you modified the HTML adapter template (packages/html-starter/), run:
pnpm sync:template-htmlImportant
Never edit files in packages/create-forgewp/template/ directly. Always make changes in packages/starter/ and execute pnpm sync:template. The sync script automatically normalizes workspace dependencies and preserves template-specific .gitignore rules.
4. Coding Standards & Conventions
TypeScript Strictness
- All framework code in
@forgewp/reactand framework interfaces must be strictly typed. - Avoid using
anywhere explicit generic constraints or union types are possible. - All code must pass type checking with zero errors:
pnpm typecheckZero Runtime Overhead in @forgewp/react
@forgewp/reactis designed to be a lightweight data bridge, not a heavyweight monolithic framework.- Avoid adding third-party dependencies to
packages/react/package.json. - Keep bundle size minimal: functions intended for compile-time AST translation must compile cleanly with 0 KB client footprint.
WordPress PHP Safety & Escaping
When authoring compiler PHP generators in packages/compiler/lib/:
- Always escape dynamic output using WordPress escaping functions:
- Text:
esc_html()oresc_html__() - HTML attributes:
esc_attr()oresc_attr__() - URLs:
esc_url() - Post body content:
wp_kses_post()orthe_content()
- Text:
- Always sanitize submitted user input with
sanitize_text_field(),sanitize_email(), orsanitize_textarea_field(). - Use WordPress nonce verification (
check_ajax_refereror REST permission callbacks) on sensitive endpoints.
Documentation Standards
- Zero Emojis: Do not use emojis in documentation markdown files or error messages.
- Code Block Titles: Always include a
title="..."attribute on fenced code blocks (e.g.tsx title="src/components/Card.tsx"). - Clickable File Links: Use GitHub-style markdown file links with the
file://scheme when referencing local files.
5. Pull Request & Release Process
Branch Naming Conventions
Create a descriptive branch for your work:
feat/feature-name: New features or capabilities.fix/issue-description: Bug fixes or edge-case corrections.docs/topic-name: Documentation additions or revisions.refactor/component-name: Code refactoring without behavior changes.
Pre-PR Checklist
Before opening a pull request, run the following verification sequence:
# 1. Typecheck all workspace packages
pnpm typecheck
# 2. Compile all packages
pnpm build
# 3. Run adapter tests
pnpm test:compiler-adapters
# 4. Sync starter template (if starter files were modified)
pnpm sync:template
# 5. Run testbed export
pnpm exportSubmitting Your Pull Request
- Push your branch to your fork on GitHub.
- Open a Pull Request against the
mainbranch offorgewp. - Provide a clear description detailing:
- Context: What problem does this PR solve?
- Changes: Summary of modifications made across packages.
- Testing: How was this change tested and verified?
- Link any related GitHub issues using keywords (e.g.
Closes #42).
Documentation Complete
Congratulations! You have completed the comprehensive documentation suite for ForgeWP. Return to the Documentation Overview to explore any topic or start building modern React-powered WordPress themes.
Package entry points
Keep the types condition first in each conditional package export, followed by the runtime conditions. Preserve the existing root and @forgewp/react/config targets when updating metadata. Run the React package export regression checks in the compiler tests to verify TypeScript consumer resolution and warning-free browser bundling.