description: "Static code SEO audit — scan codebase for SEO templates, alt-tags, metadata, and database loops" version: "1.0"
/seo-audit-code <domain|url> [--performance] [--source-path ]
Purpose
Performs static code analysis of the website files in the workspace (default: ./sourcecode/) to verify compliance with SEO structure rules and performance best practices. Generates diff patches for easy auto-fixing.
Steps
Init/load domain project (Primary Agent: @[tech-seo-director]):
- If project doesn't exist, initialize it:
python .agents/scripts/run_plugin_script.py seo-core project_manager.py init <domain> - Locate project directory
PROJECT_DIR = .seo
- If project doesn't exist, initialize it:
Verify and Resolve Target Path:
- Check if
./sourcecode/exists in the workspace. If yes, default to./sourcecode. - If not, check if
settings.source_code_pathis defined inproject.json. - If not, check for dynamic framework signatures (WordPress themes, Next.js page roots).
- Check if
Performance Scan Gate:
- If
--performanceis not passed, prompt the user:"Bạn có muốn quét sâu về hiệu năng code (Level 2 - Ví dụ: query database trùng lặp, loop lồng nhau) không? (Y/N)" - Set the
--performanceflag accordingly based on response.
- If
Execute Scanner Script:
- Run the Python scanner:
python .agents/scripts/run_plugin_script.py seo-code code_scanner.py \ --project-dir <PROJECT_DIR> \ [--performance] \ [--source-path <path>] - This writes
code-audit-{date}.jsoninto<PROJECT_DIR>/data/.
- Run the Python scanner:
Generate Diffs & Propose Fixes:
- Read the scanned issues.
- For structural template changes (e.g. adding missing hooks, image alt tags, canonicals), generate the precise diff patches.
- Save the proposed fixes to
<PROJECT_DIR>/fixes/{date}/proposed-fixes.json.
Create Markdown Report:
- Apply templates to output
<PROJECT_DIR>/reports/code-audit-{date}.md. - Display a summary of issues classified by severity (Critical, High, Medium, Low) and framework area.
- Display side-by-side diff mockups in the report for user review.
- Apply templates to output
User Approval (Suggest & Approve Gate):
- Present the summary of issues and generated diffs.
- Ask the user:
"Đã tạo đề xuất sửa lỗi tại .seo/fixes/{date}/. Bạn muốn tự động sửa các lỗi này không? (Y/N)" - If Yes:
python .agents/scripts/run_plugin_script.py seo-code code_fixer.py \ --fix-file <PROJECT_DIR>/fixes/{date}/proposed-fixes.json