Complete guide to using OpenCode WordPress skills, agents, commands, and hooks.
After installation, verify everything works:
# Check available skills
opencode skills list
# Test a skill
opencode skill wordpress-theme-development- Start OpenCode session in your WordPress project directory
- Invoke a skill for specific task
- Use commands for quick actions
- Let agents review your code
- Hooks validate on commit
# List all skills
opencode skills list
# List WordPress skills only
opencode skills list --filter wordpress
# Show skill details
opencode skill wordpress-theme-development --infoSkills provide structured guidance for WordPress development.
# Invoke theme development skill
opencode skill wordpress-theme-development
# Or use slash command
/wp-themeSkill provides:
- Theme structure guidance
- Template hierarchy patterns
- Enqueue scripts/styles best practices
- Widget area setup
- Customizer integration
# Invoke plugin development skill
opencode skill wordpress-plugin-development
# Or use slash command
/wp-pluginSkill provides:
- Plugin structure guidance
- Hooks and filters patterns
- Settings API implementation
- Custom post type registration
- Security best practices
# Invoke WooCommerce skill
opencode skill woocommerce-patterns
# Or use slash command
/wc-buildSkill provides:
- WooCommerce extension structure
- Custom product types
- Payment gateway integration
- Order handling patterns
- WooCommerce hooks reference
# Invoke security skill
opencode skill wordpress-securitySkill provides:
- Security audit checklist
- Escaping and sanitization rules
- Nonce verification patterns
- Capability check templates
- SQL injection prevention
# Invoke REST API skill
opencode skill wordpress-rest-apiSkill provides:
- REST API endpoint registration
- Authentication patterns
- Permission callbacks
- Response formatting
- Error handling
# Invoke testing skill
opencode skill wordpress-testingSkill provides:
- PHPUnit setup guidance
- Test writing patterns
- Mock object usage
- Integration testing
- Codeception configuration
# Invoke hooks skill
opencode skill wordpress-hooks-filtersSkill provides:
- Action vs filter usage
- Hook priority management
- Custom hook creation
- Hook removal patterns
- Debugging hooks
# Invoke database skill
opencode skill wordpress-databaseSkill provides:
- $wpdb usage patterns
- Custom table creation
- Query optimization
- Transaction handling
- Cache integration
Commands provide quick actions via slash syntax.
# Create new theme
/wp-theme create my-theme
# Review theme
/wp-theme review
# Validate theme
/wp-theme validate
# Build theme assets
/wp-theme build# Create new plugin
/wp-plugin create my-plugin
# Review plugin
/wp-plugin review
# Validate plugin
/wp-plugin validate
# Build plugin
/wp-plugin build# Create WooCommerce extension
/wc-build create my-extension
# Review WooCommerce code
/wc-build review
# Validate WooCommerce integration
/wc-build validate# Full WordPress code review
/wp-review
# Review specific file
/wp-review path/to/file.php
# Review with fixes
/wp-review --fix# Fix build issues
/wp-build-fix
# Fix specific issue type
/wp-build-fix --type=php-lint
# Auto-fix all issues
/wp-build-fix --autoAgents automatically review and improve code.
Automatically activates when WordPress code is detected:
// Agent reviews:
- Coding standards compliance
- Security vulnerabilities
- Performance issues
- Hook/filter usage
- Documentation qualityUsage:
# Agent activates automatically
# Or explicitly invoke:
opencode agent wordpress-reviewerSpecialized for theme review:
# Invoke theme reviewer
opencode agent theme-reviewer
# Review specific theme
opencode agent theme-reviewer --theme=my-themeChecks:
- Template hierarchy
- Required files presence
- Theme supports
- Widget registration
- Customizer implementation
- Accessibility compliance
Specialized for plugin review:
# Invoke plugin reviewer
opencode agent plugin-reviewer
# Review specific plugin
opencode agent plugin-reviewer --plugin=my-pluginChecks:
- Plugin header compliance
- Activation/deactivation hooks
- Uninstall handling
- Settings API usage
- Custom post type registration
- Security practices
Resolves build and compilation issues:
# Invoke build resolver
opencode agent wordpress-build-resolver
# Resolve specific error
opencode agent wordpress-build-resolver --error="syntax error"Resolves:
- PHP syntax errors
- Composer dependency issues
- npm build errors
- Asset compilation failures
- WordPress coding standard violations
Rules are automatically enforced during development.
Enforces:
- Branch naming conventions
- Commit message format
- Merge strategies
- Pull request guidelines
Enforces:
- PSR-12 formatting
- WordPress coding standards
- Documentation comments
- Code organization
Enforces:
- README requirements
- Inline documentation
- Function/method documentation
- License headers
Enforces:
- No hardcoded secrets
- Proper escaping
- Input validation
- Output sanitization
Enforces WordPress Coding Standards:
- Yoda conditions
- Spacing rules
- Naming conventions
- Braces placement
Enforces:
- Proper hook usage
- Action vs filter distinction
- Hook naming
- Priority management
Enforces:
- Template hierarchy
- Loop patterns
- Template tag usage
- Conditional tags
Enforces:
- Nonce verification
- Capability checks
- Data escaping
- SQL preparation
Enforces:
- Test coverage requirements
- PHPUnit configuration
- Mock usage
- Test naming
Enforces:
- $wpdb usage
- Query preparation
- Table creation
- Transaction handling
Pre-commit hooks validate code before commit.
Validates PHP syntax:
# Automatic on commit
# Manual test:
node ~/.config/opencode/hooks/php-lint.js file.phpChecks:
- Syntax validity
- Parse errors
- Deprecated functions
- PHP version compatibility
Checks for debug code:
# Automatic on commit
# Manual test:
node ~/.config/opencode/hooks/wp-debug-check.js file.phpPrevents:
- var_dump() in code
- print_r() in code
- debug output
- Console logs in PHP
Validates security practices:
# Automatic on commit
# Manual test:
node ~/.config/opencode/hooks/security-check.js file.phpChecks:
- SQL injection risks
- XSS vulnerabilities
- CSRF protection
- Authentication bypass
Customize hook behavior:
// hooks/config.json
{
"php-lint": {
"enabled": true,
"phpVersion": "8.0",
"exclude": ["vendor/", "node_modules/"]
},
"wp-debug-check": {
"enabled": true,
"strict": true,
"allowed": ["debug-log"]
},
"security-check": {
"enabled": true,
"level": "strict",
"ignore": ["tests/"]
}
}Temporarily bypass hooks:
# Bypass all hooks
git commit --no-verify
# Bypass specific hook
SKIP_PHP_LINT=true git commit# 1. Start OpenCode in theme directory
cd wp-content/themes/my-theme
opencode
# 2. Invoke theme skill
/wp-theme
# 3. Create theme structure
opencode: "Create theme structure following skill guidance"
# 4. Use commands for quick actions
/wp-theme validate
# 5. Let agent review code
opencode agent theme-reviewer
# 6. Commit with hook validation
git commit -m "Add theme functionality"# 1. Start OpenCode in plugin directory
cd wp-content/plugins/my-plugin
opencode
# 2. Invoke plugin skill
/wp-plugin
# 3. Create plugin skeleton
opencode: "Create plugin following WordPress plugin patterns"
# 4. Validate plugin structure
/wp-plugin validate
# 5. Review with agent
opencode agent plugin-reviewer
# 6. Fix any issues
/wp-build-fix
# 7. Commit safely
git commit -m "Initial plugin structure"# 1. Start in WooCommerce extension directory
cd wp-content/plugins/my-wc-extension
opencode
# 2. Invoke WooCommerce skill
/wc-build
# 3. Create extension structure
opencode: "Create WooCommerce extension with custom product type"
# 4. Validate WooCommerce integration
/wc-build validate
# 5. Review WooCommerce code
opencode agent plugin-reviewer --woocommerce
# 6. Commit with validation
git commit -m "Add custom product type"# 1. Open existing WordPress project
cd wp-content/themes/client-theme
opencode
# 2. Full code review
/wp-review
# 3. Apply fixes
/wp-review --fix
# 4. Specific agent review
opencode agent theme-reviewer
# 5. Fix build issues
/wp-build-fix --auto
# 6. Validate fixes
/wp-theme validate
# 7. Commit improvements
git commit -m "Apply code review fixes"Invoke skills with parameters:
# Theme skill with specific template
opencode skill wordpress-theme-development --template=single
# Plugin skill with post type
opencode skill wordpress-plugin-development --cpt=product
# WooCommerce skill with gateway
opencode skill woocommerce-patterns --gateway=stripeConfigure agent behavior:
{
"agents": {
"wordpress-reviewer": {
"strict": true,
"autoFix": false,
"reportFormat": "markdown"
},
"theme-reviewer": {
"checkAccessibility": true,
"checkPerformance": true
}
}
}Process multiple files:
# Review all theme files
/wp-review themes/**/*.php
# Validate all plugins
/wp-plugin validate plugins/*/
# Fix all build issues
/wp-build-fix --recursiveUse in CI pipelines:
# .gitlab-ci.yml
wordpress-review:
script:
- opencode skills list
- opencode agent wordpress-reviewer
- node hooks/php-lint.js
- node hooks/security-check.js
only:
- merge_requestsIntegrate with VS Code:
// .vscode/settings.json
{
"opencode.skills": [
"wordpress-theme-development",
"wordpress-plugin-development"
],
"opencode.autoReview": true,
"opencode.hooks": true
}- Invoke skill first before starting development
- Follow skill guidance for structure and patterns
- Use skill examples as templates
- Review skill updates regularly
- Use commands for quick actions
- Validate before commit
- Fix issues promptly
- Don't bypass validation
- Let agents review automatically
- Address agent findings
- Run agents before commit
- Use specialized agents for specific code types
- Never disable hooks permanently
- Fix hook errors immediately
- Test hooks manually occasionally
- Update hook configuration as needed
- Understand rule requirements
- Follow rules consistently
- Don't suppress rule warnings
- Update rules for team standards
# Check skill directory
ls ~/.config/opencode/skills/
# Verify SKILL.md exists
find ~/.config/opencode/skills -name "SKILL.md"
# Check configuration
opencode config get skillsDir# Verify command files
ls ~/.config/opencode/.opencode/commands/
# Check command syntax
cat ~/.config/opencode/.opencode/commands/wp-theme.md
# Restart OpenCode
opencode restart# Check agent files
ls ~/.config/opencode/agents/
# Invoke agent explicitly
opencode agent wordpress-reviewer
# Check agent config
opencode config get agentsDir# Check Node.js version
node --version
# Install dependencies
cd ~/.config/opencode/hooks && npm install
# Test hook manually
node php-lint.js test.php
# Check hook logs
cat ~/.config/opencode/hooks/error.log# Quick theme creation
/wp-theme create --scaffold
# Quick plugin creation
/wp-plugin create --boilerplate
# Quick review
/wp-review --quickCtrl+Space: Invoke skill menuCtrl+R: Run reviewCtrl+B: Build/compileCtrl+H: Show hooks status
Create aliases for common operations:
# Add to .bashrc or .zshrc
alias wpt='opencode skill wordpress-theme-development'
alias wpp='opencode skill wordpress-plugin-development'
alias wc='opencode skill woocommerce-patterns'
alias wr='/wp-review'
alias wf='/wp-build-fix'Use templates from examples:
# Copy theme example
cp -r examples/theme-example wp-content/themes/my-theme
# Copy plugin example
cp -r examples/plugin-example wp-content/plugins/my-plugin
# Copy WooCommerce example
cp -r examples/woocommerce-example wp-content/plugins/my-wc-ext- Explore Examples: ../examples/
- Customize Rules: Edit rules to match your team standards
- Extend Hooks: Add custom hooks for specific validations
- Create Custom Skills: Add skills for your specific workflows
For usage questions:
- GitHub Issues: https://github.com/promoweb/opencode-wordpress/issues
- Discussions: https://github.com/promoweb/opencode-wordpress/discussions
- Documentation: All docs in docs/ folder
GPL v2 or later