# 🩺 Site Doctor

> Diagnoses your site's health. Finds broken links, database bloat, orphaned content, outdated plugins, and PHP errors.

| Field | Value |
|-------|-------|
| Slug | `site-doctor` |
| Version | 1.0.0 |
| Category | Maintenance |
| Author | Agentic Community |
| Required Capabilities | `manage_options` |

## What It Does

Site Doctor is a diagnostic and maintenance advisory agent that surfaces technical health issues and recommends fixes. It runs a comprehensive health check that scores your site 0-100 across database health, content hygiene, plugin status, and performance metrics, then produces a prioritised action list.

The agent digs deep into database health — table sizes, autoload option bloat, transient accumulation — and identifies orphaned content like old drafts, trashed posts, excessive revisions, and spam comments. It scans for broken internal links by actually fetching each URL with HTTP requests, and reads the PHP debug log to surface recent errors and warnings.

Site Doctor also evaluates performance-related factors: theme status, media library health (oversized images, orphaned attachments), caching configuration, Core Web Vitals via PageSpeed Insights, autoload impact analysis, and CSS/JS asset counts. All tools are read-only — Site Doctor diagnoses and recommends but never modifies your site.

## Tools

| Tool | Risk | Description |
|------|------|-------------|
| `run_health_check` | None | Run a comprehensive health check across database, content, and plugins. Returns an overall score and grade. |
| `get_database_health` | None | Check WordPress database health: table sizes, overhead, autoloaded options, transients, and overall statistics. |
| `get_orphaned_content` | None | Find orphaned content: auto-drafts, revisions, trashed posts, pending reviews, and spam comments. |
| `check_plugin_status` | None | List all installed plugins with their active/inactive status, version, and available updates. |
| `check_broken_internal_links` | None | Scan published posts for broken internal links (404s). Fetches each internal URL and reports dead links. |
| `get_php_errors` | None | Read the WordPress debug.log file and return recent PHP errors, warnings, and notices. |
| `check_theme_status` | None | List installed themes with status, version, parent info, update availability, and compatibility checks. |
| `scan_media_library` | None | Analyse the media library for oversized images, orphaned attachments, storage usage, and file-type breakdown. |
| `verify_core_integrity` | None | Compare WordPress core files against official checksums to detect modified, missing, or unexpected files. |
| `check_caching_status` | None | Detect active caching mechanisms: object cache, page cache plugins, opcode cache, and cache constants. |
| `check_core_web_vitals` | None | Check Core Web Vitals (LCP, INP, CLS) for a URL using Google PageSpeed Insights API. |
| `check_autoload_impact` | None | Estimate page load impact of autoloaded wp_options. Returns total size, top offenders, and recommendations. |
| `check_asset_count` | None | Count CSS and JS files loaded on a page. Flags excessive asset loading that can hurt Core Web Vitals. |

## Example Prompts

- "Run a full site health check"
- "How big is my database and what's bloating it?"
- "Find broken internal links across my site"
- "Show me recent PHP errors from the debug log"
- "Check my Core Web Vitals — is my homepage passing?"
- "Are any of my themes outdated or missing updates?"
- "Is object caching or page caching set up on my site?"
- "Which autoloaded options are slowing down my page load?"

---

_Generated by Agent Builder for WordPress_
