# Site Troubleshooting

## When to Use
Use this skill when the user reports errors, performance issues, white screens, or needs help diagnosing site problems.

## Diagnostic Commands

### Error Investigation
- `wp option get siteurl` / `wp option get home` — Check for URL mismatches
- `wp eval "error_reporting(E_ALL); ini_set('display_errors', 1);"` — Check PHP error reporting
- `wp config get WP_DEBUG` — Check debug mode status
- `wp config get WP_DEBUG_LOG` — Check if debug logging is on

### Plugin Conflicts
- `wp plugin list --status=active --fields=name,version` — List active plugins
- `wp plugin deactivate --all` — Deactivate all plugins (for conflict testing)
- `wp plugin activate <plugin>` — Reactivate one at a time

### Theme Issues
- `wp theme list --status=active` — Current active theme
- `wp theme activate twentytwentyfive` — Switch to default theme

### Database
- `wp db check` — Check database tables
- `wp db query "SELECT COUNT(*) FROM wp_options WHERE autoload='yes'"` — Check autoloaded options
- `wp transient delete --all` — Clear transients
- `wp cache flush` — Flush object cache

### Performance
- `wp db query "SELECT option_name, LENGTH(option_value) as size FROM wp_options WHERE autoload='yes' ORDER BY size DESC LIMIT 20"` — Large autoloaded options
- `wp cron event list` — Check scheduled events
- `wp rewrite flush` — Flush rewrite rules

### Site Health
- `wp core verify-checksums` — Verify core file integrity
- `wp plugin verify-checksums --all` — Verify plugin file integrity

## Common Issues & Solutions

### White Screen of Death
1. Enable WP_DEBUG: `wp config set WP_DEBUG true --raw`
2. Check debug.log: `wp eval "echo file_get_contents(WP_CONTENT_DIR . '/debug.log');"`
3. Deactivate plugins to find conflict
4. Switch to default theme

### 500 Internal Server Error
1. Check PHP error logs
2. Verify .htaccess: `wp rewrite flush`
3. Check file permissions
4. Increase PHP memory: `wp config set WP_MEMORY_LIMIT 256M`

### Slow Site
1. Check autoloaded options size
2. Review active plugins count
3. Check for long-running cron jobs
4. Verify object caching

## Verification Steps
After applying a fix:
1. Test the specific scenario that was broken
2. Check debug.log for new errors
3. Verify site loads correctly
4. Confirm no regressions
