Development Workflow
A complete guide to developing WordPress sites with WDG AI Development Environment.
Typical Development Flow
%%{init: {'theme':'neutral'}}%%
graph TD
A[Create Project] --> B[Clone/Create Repos]
B --> C[Start Development]
C --> D[Code & Test]
D --> E[Index for AI Search]
E --> F[Use AI Assistant]
F --> D
D --> G[Build & Deploy]
Starting a New Project
1. Project Setup
# Create project with Wikit template
wdg create client-site
# Start the project
wdg start client-site
# Access the site
open https://client-site.localhost:64432. Repository Structure
Your project starts with this structure:
projects/client-site/
├── docker-compose.yml # Container config
├── .env # Environment variables
├── .wp-content-link # Repository mapping
└── repositories/
└── custom-theme/ # Your theme (from template)
├── style.css
├── functions.php
├── package.json
└── block-editor/ # Gutenberg blocks3. Add Your Repositories
# Add existing plugin
wdg client-site repo add https://github.com/team/custom-plugin.git
# Add another theme
wdg client-site repo add https://github.com/team/brand-theme.git
# List repositories
wdg client-site repo listDaily Development Workflow
Morning Routine
# 1. Update framework repositories
wdg update
# 2. Start your project
wdg start client-site
# 3. Pull latest changes
wdg client-site repo sync
# 4. Re-index if needed
wdg index client-siteActive Development
File Watching & Hot Reload
# Terminal 1: Watch theme files
cd projects/client-site/repositories/custom-theme
npm run watch
# Terminal 2: Watch logs
docker logs wdg-wp-client-site -fMaking Changes
- Edit files directly in
projects/client-site/repositories/ - Changes sync instantly to WordPress container
- Browser auto-refreshes with hot reload
Using AI Assistant
# Index your latest changes
wdg index client-site
# Connect Claude Desktop to search your code
# MCP server at http://localhost:6765Example Claude queries:
- "Find all custom post types in client-site"
- "Show me how authentication is handled"
- "Find similar implementations to this function"
Testing Workflow
Local Testing
# Run theme tests
cd projects/client-site/repositories/custom-theme
npm test
# Check PHP syntax
docker exec wdg-wp-client-site php -l wp-content/themes/custom-theme/*.php
# WordPress debug log
docker exec wdg-wp-client-site tail -f /var/www/html/wp-content/debug.logDatabase Operations
# Export before major changes
wdg client-site db export backup-$(date +%Y%m%d).sql
# Import test data
wdg client-site db import test-data.sql
# Reset to fresh WordPress
wdg client-site db resetTeam Collaboration Workflow
Setting Up for Team
- Share repository access
# Team member clones main repo
git clone https://github.com/team/project-repos.git
# Setup their environment
cd project-repos
wdg create client-site
wdg client-site repo attach ./theme
wdg client-site repo attach ./plugins- Sync configurations
# Export your database
wdg client-site db export initial-content.sql
# Commit to repo
git add initial-content.sql
git commit -m "Add initial content"
git push- Team member imports
# Pull latest
git pull
# Import database
wdg client-site db import initial-content.sql
# Start developing
wdg start client-siteGit Workflow Integration
# Install git hooks for consistency
wdg client-site repo hooks custom-theme
# Now commits trigger:
# - Code formatting
# - Linting
# - Pre-commit testsManaging Conflicts
# Before pulling changes
wdg client-site db export my-changes.sql
# Pull and merge
cd projects/client-site/repositories/custom-theme
git pull
# Resolve conflicts
# Re-index after merge
wdg index client-siteTheme Development Workflow
Creating Blocks
# Navigate to theme directory
cd projects/client-site/repositories/client-site-theme
# Create new Gutenberg block using @wordpress/create-block
npx @wordpress/create-block testimonial-slider
# This generates:
# - block.json
# - src/edit.js
# - src/save.js
# - src/editor.scss
# - src/style.scssBuilding Assets
# Navigate to theme directory
cd projects/client-site/repositories/client-site-theme
# Install dependencies
npm install
# Build assets
npm run build
# Watch for changes
npm run watchThe theme's package.json exposes these scripts: start, build, watch, scss, postcss, build:js, build:css, build:vendor, build:stylecss, watch:js, watch:css, check-updates, update. There is no build:production, package, analyze, lint:fix, optimize:images, critical:css, or docs:generate script.
Theme Build
# Build production assets through the CLI
wdg client-site build
# Or run the build script directly
cd projects/client-site/repositories/client-site-theme
npm run buildPlugin Development Workflow
Plugin Structure
// plugins/my-plugin/my-plugin.php
<?php
/**
* Plugin Name: My Custom Plugin
* Version: 1.0.0
*/
// Your code hereTesting Plugins
# Activate plugin
docker exec wdg-wp-client-site \
wp plugin activate my-plugin --allow-root
# Run plugin tests
docker exec wdg-wp-client-site \
bash -c "cd wp-content/plugins/my-plugin && phpunit"Debugging Workflow
Enable Debug Mode
Edit projects/client-site/.env:
WP_DEBUG=true
WP_DEBUG_LOG=true
WP_DEBUG_DISPLAY=falseView Logs
# WordPress debug log (project-scoped, supports --follow/--tail=N/--since=/--grep=)
wdg client-site logs debug --follow
# PHP and nginx logs
wdg client-site logs php
wdg client-site logs nginx
# All project logs
wdg client-site logs all
# Raw container access (fallback)
docker exec wdg-wp-client-site tail -f /var/www/html/wp-content/debug.logUsing Xdebug
Add to projects/client-site/docker-compose.yml:
environment:
XDEBUG_MODE: debug
XDEBUG_CONFIG: client_host=host.docker.internalPerformance Optimization Workflow
Profiling
# Install Query Monitor plugin
docker exec wdg-wp-client-site \
wp plugin install query-monitor --activate --allow-root
# Access at: /wp-admin/admin.php?page=qmCaching
# Or use the wdg command shorthand
wdg client-site wp plugin install redis-cache --activate
# Enable object cache
wdg client-site wp redis enableAsset Builds
# Build production assets
cd projects/client-site/repositories/custom-theme
npm run build
# Build individual bundles
npm run build:js
npm run build:cssDeployment Workflow
Pre-Deployment Checklist
# 1. Run all tests
npm test
phpunit
# 2. Build production assets
npm run build
# 3. Export content
wdg client-site db export production-ready.sql
# 4. Create deployment package
./scripts/create-deployment.shDeployment Package Structure
deployment/
├── database/
│ └── production-ready.sql
├── themes/
│ └── custom-theme/
├── plugins/
│ └── custom-plugin/
└── deploy.shDeployment Script
#!/bin/bash
# deploy.sh
# Upload files
rsync -avz themes/ user@server:/var/www/wp-content/themes/
rsync -avz plugins/ user@server:/var/www/wp-content/plugins/
# Import database
ssh user@server "wp db import production-ready.sql"
# Clear caches
ssh user@server "wp cache flush"AI-Assisted Development Workflow
1. Index Everything
# Index framework
wdg index
# Index your project
wdg index client-site
# Verify collections
wdg collections list2. Connect AI Assistant
Configure Claude Desktop:
{
"mcpServers": {
"wdg": {
"command": "nc",
"args": ["localhost", "6765"]
}
}
}3. AI-Powered Tasks
Code Review: "Review the security of the user authentication in client-site"
Pattern Search: "Find all AJAX handlers in the project"
Refactoring: "Show me functions that could use the Repository pattern"
Bug Finding: "Find potential SQL injection vulnerabilities"
Best Practices
1. Version Control
# Always commit before major changes
git add -A
git commit -m "Before refactoring user system"
# Tag stable versions
git tag -a v1.0.0 -m "First stable release"
git push --tags2. Database Backups
# Daily backup script
#!/bin/bash
DATE=$(date +%Y%m%d)
wdg client-site db export backups/backup-$DATE.sql3. Environment Separation
# Development
wdg create client-dev
# Staging
wdg create client-staging
# Production prep
wdg create client-prod4. Code Quality
Use the project-scoped CLI commands. lint runs PHPCS/PHPCBF and analyze runs PHPStan inside the project container:
# Lint PHP (PHPCS)
wdg client-site lint
# Auto-fix violations (PHPCBF)
wdg client-site lint --fix
# Summary report, severity threshold, or include plugins
wdg client-site lint --summary
wdg client-site lint --severity=5
wdg client-site lint --include-plugins
# Static analysis (PHPStan, in-container)
wdg client-site analyze
wdg client-site analyze --level=5
wdg client-site analyze --baseline
wdg client-site analyze --include-pluginsAutomation Scripts
Daily Development Script
#!/bin/bash
# dev-start.sh
echo "Starting development environment..."
# Update repositories
wdg update
# Start project
wdg start client-site
# Sync repos
wdg client-site repo sync
# Re-index
wdg index client-site
# Open browser
open https://client-site.localhost:6443
# Start watching
cd projects/client-site/repositories/custom-theme
npm run watchEnd of Day Script
#!/bin/bash
# dev-end.sh
echo "Shutting down development environment..."
# Export database
wdg client-site db export daily-backup.sql
# Commit changes
cd projects/client-site/repositories/custom-theme
git add -A
git commit -m "End of day: $(date +%Y-%m-%d)"
git push
# Stop project
wdg stop client-site
echo "Environment shut down. Changes saved."Pro Tip: Create aliases for common commands in your .bashrc:
alias wdg-start='wdg start client-site'
alias wdg-theme='cd ~/wdg-ai-dev/projects/client-site/repositories/custom-theme'
alias wdg-index='wdg index client-site'