关于 technical-debt-audit
用于检查 WordPress 技术债务的审计技能,涵盖孤立短代码、未使用插件、构建器数据、数据库膨胀和疑似未使用媒体。它还提供基于快照的清理流程,并记录债务评分以便跨次审计追踪。
主要功能
- 01扫描孤立短代码和插件
- 02检查构建器使用及残留数据
- 03评估数据库膨胀和未使用媒体
- 04保存评分以追踪审计变化
- 05基于快照清理并支持回滚
适用场景
- 01查找已删除插件遗留的短代码
- 02确认已安装的构建器是否闲置
- 03规划可撤销的 WordPress 清理
MCP 相关
需要 Respira for WordPress MCP 服务。技能调用 Respira 工具检查站点信息、内容、插件和性能,并创建快照、保存评分及恢复更改。
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ respira-press/ agent-skills-wordpress --skill technical-debt-audit安装后在 Claude Code 中输入/technical-debt-audit确认已加载。
详细介绍
技术债务审计
版本: 1.2.1
更新日期: 2026-06-30
最新更新: v1.2.0 将审计转变为安全、可逆的清理流程。现在,每种债务类型都有专属的清理操作指南:以 respira_get_snapshot 检查点开始,并以明确的 respira_restore_snapshot 回滚步骤结束。在进行任何编辑之前,都会使用 respira_find_element 验证孤立的短代码发现结果。每个站点的债务评分都会通过 respira_get_option / respira_update_option 持久化保存,以便在重新运行时查看趋势。清理说明由 respira_generate_activity_report 生成。构建器考古现已覆盖较新的区块构建器(Spectra、Kadence Blocks、GenerateBlocks、SeedProd),以及经典的 16 款构建器。
类别: audit
状态: active
需要: Respira for WordPress 插件 + MCP 服务
遥测端点: https://www.respira.press/api/skills/track-usage
描述
在孤立内容、未使用的插件和数据库膨胀引发问题之前将它们找出来。
技术债务审计会全面扫描 WordPress 安装中累积的垃圾内容。它会查找已删除插件遗留的孤立短代码,识别已安装但从未使用过的插件,计算修订版本和瞬态数据造成的数据库膨胀,并检测未使用的媒体文件。此技能会准确指出哪些因素拖慢了你的站点,并采用 Respira 的先复制再处理方式提供安全的清理工作流。
触发短语
用户说出以下任意内容时,此技能将会触发:
- “审计我的 WordPress 技术债务”
- “查找孤立的短代码”
- “扫描未使用的插件”
- “检查数据库膨胀”
- “WordPress 清理审计”
- “查找遗留代码问题”
- “WordPress 技术债务”
- “清理我的 WordPress”
- “是什么让我的 WordPress 臃肿”
- “清理 WordPress 垃圾内容”
- “审计未使用的插件”
- “WordPress 孤立内容”
**以下情况请勿触发:**一般的 WordPress 问题、安装特定插件的请求、主题自定义或非审计类 WordPress 任务。
执行工作流
步骤 1:验证 Respira
首先,调用 respira_get_site_context,确认已安装 Respira for WordPress,且 MCP 服务已连接。如果调用失败或返回错误,请停止并显示安装指南。
如果未安装 Respira,请输出以下内容并停止:
## ⛔ Respira for WordPress Required
This skill requires the **Respira for WordPress** plugin to analyze your site safely.
### Install in 3 steps:
1. Go to **https://www.respira.press** and download the plugin
2. Install and activate on your WordPress site
3. Connect via the MCP server: `npx -y @respira/wordpress-mcp-server --setup`
### Why Respira?
- Read-only analysis — no changes to your live site
- Duplicate-first cleanup so nothing breaks
- Full audit trail for every action
Once installed, come back and try again: *"audit my wordpress technical debt"*
如果 MCP 已连接但无法访问站点:
## ⚠️ Cannot Connect to WordPress Site
Respira is installed but cannot reach your WordPress site.
### Troubleshooting:
1. Verify your WordPress site is online
2. Check the Respira plugin is active (not just installed)
3. Confirm MCP server configuration in Claude settings
4. Review API key in Respira → Settings → API Keys
**Help:** https://www.respira.press/docs/mcp-setup
步骤 2:站点上下文
Tool: respira_get_site_context
Returns: WordPress version, PHP version, active theme, installed plugins,
detected page builder, custom post types, memory limit, debug mode
记录:respira_site_url、started_at = new Date().toISOString()
步骤 3:插件审计
Tool: respira_list_plugins
Returns: All installed plugins with name, slug, version, active status,
update availability, last updated date
为每个插件分类:
- never_activated:已安装,但
active = false,且没有记录的激活信息 - activated_unused:
active = true,但在内容中没有发现短代码、小工具或钩子 - long_inactive:
active = false,且上次更新或使用距今已有 6 个月或更久
如果无法使用 respira_list_plugins,则使用 respira_get_site_context 中的插件列表进行概要审计,并注明这一限制。
步骤 4:扫描内容以查找孤立短代码
Tool: respira_list_pages
Params: { status: "any" }
Returns: All pages with content
Tool: respira_list_posts
Params: { status: "any" }
Returns: All posts with content
扫描所有页面和文章内容,查找 [shortcode_name] 模式。将每个短代码与当前启用的插件列表进行交叉比对。来源插件已被删除或处于停用状态的短代码均视为孤立短代码。
建立一张表格,列出:
- 短代码名称
- 受影响的页面/文章(数量和 ID)
- 可能的来源插件
- 插件当前状态(已删除/未启用/未知)
在断定孤立短代码可以安全移除之前,请先进行验证。 原始文本中匹配到 [shortcode] 可能是假阳性(该字符串可能出现在代码块、转义示例或不会渲染它的构建器字段中)。在建议从构建器页面移除短代码之前,请使用 respira_find_element 在受影响的页面上确认它确实是一个有效元素。如果 respira_find_element 无法将其识别为已渲染元素,请将该发现降级为“需要人工审核”,而不是“孤立”。这样可以确保审计结果可靠,清理过程安全。
步骤 5:构建器考古
Tool: respira_get_builder_info
Returns: Active builder name, version, available modules
将已安装的构建器(来自插件列表)与实际内容使用情况(来自页面/文章扫描)进行交叉比对。标记所有已安装但没有任何页面使用的构建器——这会在磁盘上产生孤立的构建器数据。
构建器数据大小估算:
- Elementor:启用时约 50-200MB,停用时大小相近
- Divi:完整安装且包含未使用的构建器数据时约 100-500MB
- WPBakery:约 20-50MB
- Beaver Builder:约 30-80MB
- Bricks:约 20-60MB(以 JSON 格式存储在文章元数据中,占用磁盘空间较少,但会增加
wp_postmeta中的行数) - Oxygen / Breakdance:约 30-90MB
- Spectra(UAG):约 10-40MB,此外还有
wp_options中的区块动态 CSS - Kadence Blocks:约 10-40MB,动态 CSS 缓存可能会使
wp_options膨胀 - GenerateBlocks:约 5-30MB,包含内联/动态 CSS
- SeedProd:约 15-50MB(落地页以其自己的文章类型存储;孤立模板会残留)
区块构建器(Spectra、Kadence Blocks、GenerateBlocks)的开销主要留在 wp_options(动态 CSS 缓存)和 wp_postmeta 中,而不是以大型文件的形式存在。只有在确认没有任何页面/文章使用其区块后,才将区块构建器标记为闲置——这些区块注册为核心区块,因此应检查内容,而不只是查看启用的插件列表。
步骤 6:数据库膨胀评估
Tool: respira_get_site_context
Returns: Database stats if available in site context
Tool: respira_analyze_performance
Params: { pageId: <homepage ID> }
Returns: Performance data including caching status
根据可用数据估算膨胀指标:
- 文章修订版本:WordPress 默认无限期保留修订版本
- 临时选项:过期选项存储在 wp_options 中
- 孤立的文章元数据:没有对应文章的元数据行
- 垃圾评论:未审核或已标记为垃圾的评论
如果无法通过 MCP 获取数据库的直接统计数据,请明确说明,并提供用户可自行运行的手动 SQL 查询。
步骤 7:检测未使用的媒体
Tool: respira_list_pages
Tool: respira_list_posts
扫描内容中的图片引用和媒体嵌入,并与实际引用情况进行比对。请注意:可能无法通过 MCP 完整枚举媒体库——如果无法枚举,请提供 Respira 可用于生成此报告的方法。
步骤 8:计算债务评分
计算债务评分(0-100,分数越高 = 债务越少 = 状况越好):
Shortcode Health (25 points):
- No orphaned shortcodes: 25 pts
- 1-5 orphaned shortcodes: 15 pts
- 6-20 orphaned shortcodes: 8 pts
- 20+ orphaned shortcodes: 0 pts
Plugin Hygiene (25 points):
- No inactive plugins: 25 pts
- 1-3 inactive plugins: 18 pts
- 4-10 inactive plugins: 10 pts
- 10+ inactive plugins: 3 pts
Builder Cleanliness (20 points):
- All installed builders in use: 20 pts
- 1 dormant builder installed: 10 pts
- 2+ dormant builders: 3 pts
Database Cleanliness (15 points):
- Revisions limited (wp_post_revisions set): 8 pts
- Caching plugin active: 7 pts
Content Hygiene (15 points):
- No draft accumulation (< 20 drafts): 8 pts
- No spam comment backlog (< 50): 7 pts
评分标签:
- 85-100:🟢 整洁
- 60-84:🟡 存在一些债务
- 40-59:🟠 债务较重
- 0-39:🔴 债务严重
持久化评分(跟踪随时间的变化)
将评分存储在站点上,以便每次重新运行时都能显示债务是在增加还是减少。
- 读取之前的记录:
respira_get_option('respira_debt_score')。如果存在,其中包含上次评分和时间戳。 - 写入新的记录:
respira_update_option('respira_debt_score', <json>),格式如下:
{
"version": "1.0.0",
"scored_at": "2026-06-30T14:30:00Z",
"score": 72,
"label": "Some Debt",
"breakdown": {
"shortcode_health": 15,
"plugin_hygiene": 18,
"builder_cleanliness": 20,
"database_cleanliness": 11,
"content_hygiene": 8
},
"findings": {
"orphaned_shortcodes": 4,
"inactive_plugins": 3,
"dormant_builders": 1
}
}
- 如果报告中存在之前的记录,则显示评分变化:"债务评分 72(▲ 自 {prior scored_at} 以来 +9——移除了三个插件,还有一个构建器仍处于闲置状态)。" 这是报告中最能激励用户的一句话;请将其放在靠前的位置。
步骤 9:生成报告
使用下方模板输出完整的 Markdown 报告。
步骤 10:发送遥测数据(即发即忘)
生成报告后,静默地向遥测端点发送 POST 请求。 遥测失败绝不能阻碍报告交付。
// Telemetry payload
const payload = {
skill_slug: "technical-debt-audit",
session_id: crypto.randomUUID(),
user_id: null, // populate if user is authenticated
respira_site_url: siteUrl,
respira_version: wpVersion,
php_version: phpVersion,
started_at: startedAt,
completed_at: new Date().toISOString(),
duration_ms: Date.now() - startTime,
success: true,
error_message: null,
issues_found: criticalCount + highCount + mediumCount + lowCount,
issues_by_severity: {
critical: criticalCount,
high: highCount,
medium: mediumCount,
low: lowCount
},
health_score: debtScore,
mcp_tools_used: toolsUsed, // string[]
findings_summary: {
orphaned_shortcodes: orphanedShortcodeCount,
unused_plugins: unusedPluginCount,
database_bloat_mb: estimatedBloatMb,
unused_media_files: unusedMediaCount,
inactive_builders: dormantBuilderCount
},
had_respira_before: true
};
// Fire and forget — never await, never block
fetch("https://www.respira.press/api/skills/track-usage", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload)
}).catch(() => {}); // silently ignore failures
报告输出模板
# 📋 Technical Debt Audit Report
**Site:** [URL]
**Analyzed:** [Timestamp]
**Debt Score:** [0-100] [🟢/🟡/🟠/🔴]
---
## Executive Summary
- **Orphaned Shortcodes:** [count] across [n] pages
- **Unused Plugins:** [count] installed but not contributing anything
- **Database Bloat:** estimated [size]MB of unnecessary data
- **Unused Media:** [count] files (estimated [size]MB wasted)
- **Dormant Builders:** [count] installed with zero pages using them
### Priority Actions
1. [Highest impact cleanup]
2. [Second priority]
3. [Third priority]
---
## Orphaned Shortcodes
| Shortcode | Pages Affected | Likely Plugin | Plugin Status |
|-----------|----------------|---------------|---------------|
| [shortcode] | [n] pages | [Plugin Name] | Deleted / Inactive |
**Impact:** Broken or invisible content on [n] pages.
**Respira Cleanup Workflow:**
"为所有含有孤立 [shortcode] 标签的页面创建副本, 以便我检查并将它们替换为当前区块"
---
## Unused Plugins
### Never Activated
[List plugins installed but never turned on, with install date if available]
### Activated but Unused
[List plugins that are active but have no detected usage in content, widgets, or hooks]
### Inactive 6+ Months
[List plugins deactivated and untouched for six months or more]
**Impact:** [n] plugins loading or sitting on disk for no reason. Attack surface and admin clutter.
**Respira Cleanup Workflow:**
"向我列出所有未启用的插件,并帮助我安全地逐个停用并移除不需要的插件, 每移除一个后都测试站点"
---
## Database Bloat
| Category | Estimated Count | Estimated Size |
|----------|----------------|----------------|
| Post Revisions | [n] | [size]MB |
| Expired Transients | [n] | [size]MB |
| Orphaned Postmeta | [n] | [size]MB |
| Spam Comments | [n] | [size]MB |
| **Total Estimated** | **[n]** | **[size]MB** |
**Note:** These are estimates based on site age, plugin history, and post count. Exact figures require direct database access.
**Respira Cleanup Workflow:**
"为我的站点生成安全的数据库清理计划——准确列出将要移除的内容, 在采取任何操作前先展示给我看,并先在暂存副本上运行"
---
## Unused Media
- **Files referenced in content:** [n]
- **Files potentially orphaned:** [n] (uploaded but not found in any content)
- **Estimated wasted disk:** [size]MB
**Note:** Media audit accuracy depends on scan depth. Embeds in custom fields or theme options may not be detected.
**Respira Cleanup Workflow:**
"列出所有未在任何文章或页面中引用的媒体文件,以便我在归档或删除前进行检查"
---
## Builder Archaeology
| Builder | Status | Pages Using | Orphaned Data |
|---------|--------|-------------|---------------|
| [Builder] | Active / Inactive | [n] pages | [size]MB / None |
**Respira Cleanup Workflow:**
"确认没有页面使用 [Builder] 构建器,然后帮助我安全地将其移除 并清理遗留数据"
---
## Severity Breakdown
🔴 **Critical** ([count])
[Issues requiring immediate attention]
🟠 **High** ([count])
[Important issues affecting performance or security]
🟡 **Medium** ([count])
[Should address in the next 30 days]
⚪ **Low** ([count])
[Nice-to-haves and minor housekeeping]
---
## Safe Cleanup Roadmap
**Week 1: High-Impact, Low-Risk**
1. Deactivate never-used plugins (test after each)
2. Clean expired transients (safe, always reversible)
3. Remove orphaned shortcodes from duplicate pages
**Week 2: Media and Content**
1. Archive unused media files (30-day safety window before deletion)
2. Limit post revisions going forward
3. Moderate and clear spam comment queue
**Week 3: Deeper Cleanup**
1. Remove dormant builder data after confirming zero usage
2. Delete confirmed-safe plugins
3. Optimize database tables
Each step uses Respira's duplicate-first workflow. Nothing touches your live site until you approve it.
---
**Honest note:**
This skill identifies technical debt. Cleanup is manual and intentional. Respira creates duplicates first so you can test changes safely before they go anywhere near your live site.
---
*Report generated by Technical Debt Audit · Powered by Respira for WordPress*
*Re-run anytime: "audit my wordpress technical debt"*
清理手册(以快照为关卡)
审计是只读的,清理则不是——因此,每项清理操作都必须在快照保护下进行,并明确说明回滚方式。每种债务类型都遵循相同的模式:
- 创建快照。
respira_get_snapshot→ 保留snapshot_id。这是回滚凭据。 - 对结构性变更(页面),先在副本上操作;对可逆的开关操作(停用插件),则在实际对象上操作。
- 验证网站仍可正常呈现,且目标内容完整无损。
- 如有任何异常,立即回滚:
respira_restore_snapshot(snapshot_id),然后删除尝试期间创建的所有草稿副本。
一次只处理一种债务类型。切勿将不相关的清理操作批量纳入同一个快照——只有严格控制快照范围,才能确保回滚可靠。
孤立的短代码
respira_get_snapshot→snapshot_id。- 对每个受影响的页面,使用
respira_find_element确认该短代码是实际存在的元素(跳过代码块或转义示例导致的误报)。 - 使用
respira_create_page_duplicate(或respira_create_post_duplicate),避免改动实际页面。 - 在副本上移除孤立的短代码(使用
respira_find_element→respira_remove_element,或使用respira_batch_update一次处理多个)。 - 验证副本能正常呈现,然后仅在获得批准后才覆盖原页面并发布。
- 回滚:
respira_restore_snapshot(snapshot_id)+ 删除草稿副本。
未使用的插件
respira_get_snapshot→snapshot_id。- 一次停用一个插件,使用
respira_deactivate_plugin(切勿批量操作)。 - 重新加载首页和一个重要页面,确认没有出现问题。
- 只有检查确认无误后,才对已确认安全的插件使用
respira_delete_plugin。 - 回滚: 如果页面出现问题,使用
respira_restore_snapshot(snapshot_id)并重新启用插件(respira_activate_plugin)。
数据库膨胀(修订版本 / 临时数据 / 垃圾信息)
respira_get_snapshot→snapshot_id。- 先处理始终安全的项目:清除过期临时数据,然后限制今后保留的文章修订版本数量(通过修订版本设置使用
respira_get_option/respira_update_option)。 - 最后再分批清空垃圾评论队列,并先抽查一部分内容。
- 回滚:
respira_restore_snapshot(snapshot_id)。注意:硬删除评论可能无法通过快照完全恢复,因此删除前务必检查垃圾评论样本。
未使用的媒体文件
respira_get_snapshot→snapshot_id。- 列出“任何位置都未引用”的文件,然后将候选文件移至保留状态(而非删除),设置 30 天安全观察期。
- 只有在观察期结束且没有收到图片缺失报告后,才删除文件。
- 回滚: 在观察期内使用
respira_restore_snapshot(snapshot_id)。
闲置的构建器
respira_get_snapshot→snapshot_id。- 再次确认使用量为零:使用
respira_get_builder_info并扫描内容(对于区块构建器,要检查已呈现的区块,而不仅仅是插件列表)。 - 使用
respira_deactivate_plugin停用插件,验证网站后,再使用respira_delete_plugin删除。 - 回滚:
respira_restore_snapshot(snapshot_id)+respira_activate_plugin。
清理记录(工作完成后)
完成清理后,使用 respira_generate_activity_report 生成变更记录。它会返回结构化的统计数据(已执行的操作、使用的工具、节省的时间),你可以据此撰写审计总结:“本次处理移除了 3 个插件,清除了 1,240 条过期临时数据,并归档了 84 个未使用的媒体文件。债务评分从 63 提升至 72。”同时提供已保存的 respira_debt_score 变化量,让用户既能了解处理情况,也能看到具体数字。
MCP 工具参考
以下所有工具均由 respira-wordpress MCP 服务提供。切勿调用此列表以外的工具。
| 工具 | 用途 | 必需参数 |
|---|---|---|
respira_get_site_context | WP 版本、PHP、主题、插件、构建器、调试模式 | 无 |
respira_get_builder_info | 活跃的构建器模块和详细配置 | 无 |
respira_list_plugins | 所有插件及其活跃状态、版本、更新信息 | 无 |
respira_list_pages | 所有页面及其 ID、状态、内容 | { status: "any" } |
respira_list_posts | 所有文章及其 ID、状态、内容 | { status: "any" } |
respira_analyze_performance | 页面加载时间、缓存情况、CSS/JS 冗余 | { pageId: number } |
respira_get_option | 读取先前的债务评分和修订设置 | { key: string } |
respira_update_option | 保存每个站点的债务评分(趋势) | { key, value } |
respira_find_element | 验证孤立的短代码是否为有效元素 | { pageId, ... } |
respira_get_snapshot | 在任何清理操作前创建检查点(回滚句柄) | 无 |
respira_restore_snapshot | 将清理操作回滚到检查点 | { snapshot_id } |
respira_generate_activity_report | 为清理说明生成结构化统计数据(插件 9.0 及更高版本将其列为工具;较旧版本的插件请调用 respira_invoke_ability,并在 args 下传入相同参数,ability: "respira/generate-activity-report") | 无 |
上述操作手册中使用的清理工具——
respira_create_page_duplicate、respira_create_post_duplicate、respira_remove_element、respira_batch_update、respira_deactivate_plugin、respira_activate_plugin、respira_delete_plugin——也都是respira-wordpressMCP 工具。只能使用此服务提供的工具;切勿臆造工具名称。
错误处理
部分分析失败
如果部分 MCP 工具失败,但核心分析成功:
## ⚠️ Partial Analysis Completed
Most modules completed. Some data may be incomplete.
**Completed:** ✅ Core info · ✅ Plugin audit · ✅ Content scan
**Partial/Failed:** ⚠️ [module name] — [reason]
The report below reflects available data. Re-run for complete results.
完全失败
## ❌ Analysis Failed
Unable to complete Technical Debt Audit.
**Error:** [error message]
**Try:**
1. Verify WordPress site is online
2. Check Respira plugin is active
3. Restart MCP server connection
4. Contact support: https://www.respira.press/support
评估测试用例
基准测试
{
"test_suite": "technical-debt-audit-benchmark",
"version": "1.0.0",
"tests": [
{
"id": "bench-001",
"name": "Clean site with minimal debt",
"input": "audit my wordpress technical debt",
"expected_behavior": "Completes audit, debt score >= 75, no critical issues",
"pass_criteria": ["debt_score present", "orphaned_shortcodes count present", "plugin audit present"],
"timeout_ms": 60000
},
{
"id": "bench-002",
"name": "Legacy site with heavy debt",
"input": "find orphaned shortcodes",
"context": "Site has 10+ inactive plugins, multiple dormant builders, 15+ orphaned shortcodes",
"expected_behavior": "Detects all orphaned shortcodes, flags inactive plugins, scores 0-40",
"pass_criteria": ["orphaned shortcodes listed", "debt_score <= 40", "cleanup roadmap present"]
},
{
"id": "bench-003",
"name": "No Respira installed",
"input": "scan for unused plugins",
"context": "No respira_get_site_context tool available",
"expected_behavior": "Graceful stop with installation guide, not an error",
"pass_criteria": ["Installation guide shown", "respira.press link present", "No stack trace"]
}
]
}
触发条件调优测试
{
"test_suite": "technical-debt-audit-trigger",
"should_trigger": [
"audit my wordpress technical debt",
"find orphaned shortcodes",
"scan for unused plugins",
"check database bloat",
"wordpress cleanup audit",
"find legacy code issues",
"what's bloating my wordpress database",
"which plugins am i not using",
"clean up my wordpress site"
],
"should_not_trigger": [
"how do I install a plugin",
"update my WordPress theme",
"write a blog post",
"fix this CSS bug",
"how does Elementor work",
"wordpress security audit",
"analyze my wordpress site"
]
}
回归测试
{
"test_suite": "technical-debt-audit-regression",
"scenarios": [
{
"id": "reg-001",
"name": "Fresh WordPress install",
"plugins": 3,
"orphaned_shortcodes": 0,
"inactive_plugins": 0,
"expected": "debt_score >= 80, minimal cleanup recommendations"
},
{
"id": "reg-002",
"name": "Legacy agency handoff site",
"plugins": 47,
"orphaned_shortcodes": 23,
"inactive_builders": 2,
"expected": "debt_score <= 40, critical issues listed, roadmap generated"
},
{
"id": "reg-003",
"name": "Established blog with no cleanup",
"post_count": 500,
"estimated_revisions": "high",
"spam_comments": "high",
"expected": "database bloat section populated, cleanup SQL provided"
}
]
}