opencode-skills-collection 3.1.23 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/bundled-skills/.antigravity-install-manifest.json +24 -1
  2. package/bundled-skills/007/SKILL.md +2 -2
  3. package/bundled-skills/10-andruia-skill-smith/SKILL.md +1 -1
  4. package/bundled-skills/agent-squad/SKILL.md +5 -0
  5. package/bundled-skills/agent-squad/alex/SKILL.md +3 -0
  6. package/bundled-skills/agent-squad/aria/SKILL.md +3 -0
  7. package/bundled-skills/agent-squad/dep/SKILL.md +3 -0
  8. package/bundled-skills/agent-squad/luna/SKILL.md +4 -1
  9. package/bundled-skills/agent-squad/mason/SKILL.md +3 -0
  10. package/bundled-skills/agent-squad/max/SKILL.md +3 -0
  11. package/bundled-skills/agent-squad/quinn/SKILL.md +3 -0
  12. package/bundled-skills/agent-squad/rex/SKILL.md +3 -0
  13. package/bundled-skills/angular/metadata.json +1 -1
  14. package/bundled-skills/angular-best-practices/metadata.json +1 -1
  15. package/bundled-skills/angular-state-management/metadata.json +1 -1
  16. package/bundled-skills/angular-ui-patterns/metadata.json +1 -1
  17. package/bundled-skills/antigravity-skill-orchestrator/SKILL.md +2 -2
  18. package/bundled-skills/apify-actor-development/SKILL.md +2 -2
  19. package/bundled-skills/apple-container/SKILL.md +165 -0
  20. package/bundled-skills/apple-container/references/commands.md +1593 -0
  21. package/bundled-skills/apple-container/references/concepts.md +294 -0
  22. package/bundled-skills/apple-container/references/configuration.md +499 -0
  23. package/bundled-skills/apple-container/references/workflows.md +498 -0
  24. package/bundled-skills/ask-copilot/SKILL.md +112 -0
  25. package/bundled-skills/auto-research/SKILL.md +126 -0
  26. package/bundled-skills/brooks-lint/SKILL.md +1 -1
  27. package/bundled-skills/browser-harness/references/install.md +3 -1
  28. package/bundled-skills/chrome-extension-developer/SKILL.md +1 -1
  29. package/bundled-skills/clean-code-guard/SKILL.md +184 -0
  30. package/bundled-skills/clean-code-guard/references/ai-failure-modes.md +345 -0
  31. package/bundled-skills/clean-code-guard/references/comments-and-formatting.md +115 -0
  32. package/bundled-skills/clean-code-guard/references/dry-kiss-yagni.md +133 -0
  33. package/bundled-skills/clean-code-guard/references/naming-and-functions.md +187 -0
  34. package/bundled-skills/clean-code-guard/references/review-checklist.md +150 -0
  35. package/bundled-skills/clean-code-guard/references/solid.md +280 -0
  36. package/bundled-skills/clean-code-guard/references/sources.md +47 -0
  37. package/bundled-skills/cloudflare-security-audit/SKILL.md +137 -0
  38. package/bundled-skills/cloudflare-security-audit/references/AI-AND-LLM.md +67 -0
  39. package/bundled-skills/cloudflare-security-audit/references/ATTACK-CLASSES.md +116 -0
  40. package/bundled-skills/cloudflare-security-audit/references/CLIENT-SIDE.md +67 -0
  41. package/bundled-skills/cloudflare-security-audit/references/HUNTING.md +110 -0
  42. package/bundled-skills/cloudflare-security-audit/references/MEMORY-SAFETY-AND-BINARY.md +58 -0
  43. package/bundled-skills/cloudflare-security-audit/references/RECONNAISSANCE.md +46 -0
  44. package/bundled-skills/cloudflare-security-audit/references/VALIDATION-AND-REPORTING.md +109 -0
  45. package/bundled-skills/cloudflare-security-audit/references/WEB-PROTOCOL-AND-AUTH.md +85 -0
  46. package/bundled-skills/cloudflare-security-audit/resources/report-schema.json +210 -0
  47. package/bundled-skills/comfyui-gateway/references/troubleshooting.md +1 -1
  48. package/bundled-skills/commit/SKILL.md +2 -1
  49. package/bundled-skills/deepapi/SKILL.md +6 -6
  50. package/bundled-skills/docs/README.md +1 -1
  51. package/bundled-skills/docs/contributors/quality-bar.md +1 -1
  52. package/bundled-skills/docs/contributors/security-guardrails.md +1 -1
  53. package/bundled-skills/docs/integrations/jetski-cortex.md +5 -5
  54. package/bundled-skills/docs/integrations/jetski-gemini-loader/README.md +3 -3
  55. package/bundled-skills/docs/maintainers/ci-drift-fix.md +7 -5
  56. package/bundled-skills/docs/maintainers/merge-batch.md +24 -7
  57. package/bundled-skills/docs/maintainers/pr-autonomy.md +89 -0
  58. package/bundled-skills/docs/maintainers/release-notes-7.2.0.md +1 -1
  59. package/bundled-skills/docs/maintainers/release-process.md +9 -9
  60. package/bundled-skills/docs/maintainers/repo-growth-seo.md +5 -5
  61. package/bundled-skills/docs/maintainers/skills-date-tracking.md +1 -1
  62. package/bundled-skills/docs/maintainers/skills-update-guide.md +2 -2
  63. package/bundled-skills/docs/users/{antigravity-awesome-skills-vs-awesome-claude-skills.md → agentic-awesome-skills-vs-awesome-claude-skills.md} +5 -5
  64. package/bundled-skills/docs/users/ai-agent-skills.md +4 -4
  65. package/bundled-skills/docs/users/best-claude-code-skills-github.md +3 -3
  66. package/bundled-skills/docs/users/best-cursor-skills-github.md +3 -3
  67. package/bundled-skills/docs/users/bundles.md +56 -57
  68. package/bundled-skills/docs/users/claude-code-skills.md +6 -6
  69. package/bundled-skills/docs/users/codex-cli-skills.md +5 -5
  70. package/bundled-skills/docs/users/cursor-skills.md +3 -3
  71. package/bundled-skills/docs/users/faq.md +27 -15
  72. package/bundled-skills/docs/users/gemini-cli-skills.md +4 -4
  73. package/bundled-skills/docs/users/getting-started.md +22 -12
  74. package/bundled-skills/docs/users/kiro-integration.md +7 -7
  75. package/bundled-skills/docs/users/plugins.md +8 -9
  76. package/bundled-skills/docs/users/security-skills.md +1 -1
  77. package/bundled-skills/docs/users/skills-vs-mcp-tools.md +1 -1
  78. package/bundled-skills/docs/users/specialized-plugin-roadmap.md +3 -4
  79. package/bundled-skills/docs/users/usage.md +9 -9
  80. package/bundled-skills/docs/users/visual-guide.md +7 -7
  81. package/bundled-skills/docs/users/windows-truncation-recovery.md +1 -1
  82. package/bundled-skills/docs/users/workflows.md +1 -1
  83. package/bundled-skills/docs/vietnamese/BUNDLES.vi.md +1 -1
  84. package/bundled-skills/docs/vietnamese/FAQ.vi.md +15 -8
  85. package/bundled-skills/docs/vietnamese/GETTING_STARTED.vi.md +12 -5
  86. package/bundled-skills/docs/vietnamese/QUALITY_BAR.vi.md +1 -1
  87. package/bundled-skills/docs/vietnamese/README.vi.md +21 -17
  88. package/bundled-skills/docs/vietnamese/SECURITY_GUARDRAILS.vi.md +1 -1
  89. package/bundled-skills/docs/vietnamese/SKILLS_README.vi.md +2 -2
  90. package/bundled-skills/docs/vietnamese/TRANSLATION_PLAN.vi.md +1 -1
  91. package/bundled-skills/docs/vietnamese/VISUAL_GUIDE.vi.md +8 -8
  92. package/bundled-skills/docs-guard/SKILL.md +109 -0
  93. package/bundled-skills/docs-guard/references/code-samples.md +46 -0
  94. package/bundled-skills/docs-guard/references/docstrings.md +60 -0
  95. package/bundled-skills/docs-guard/references/review-checklist.md +45 -0
  96. package/bundled-skills/docs-guard/references/sources.md +22 -0
  97. package/bundled-skills/docs-guard/references/verification.md +51 -0
  98. package/bundled-skills/efficient-web-research/SKILL.md +4 -0
  99. package/bundled-skills/electron-development/SKILL.md +1 -1
  100. package/bundled-skills/event-staffing-compliance/SKILL.md +3 -0
  101. package/bundled-skills/event-staffing-ordering/SKILL.md +3 -0
  102. package/bundled-skills/feature-tracking/SKILL.md +222 -0
  103. package/bundled-skills/flutter-expert/SKILL.md +6 -1
  104. package/bundled-skills/flutter-expert/resources/implementation-playbook.md +214 -0
  105. package/bundled-skills/gemini-deep-research/README.md +246 -0
  106. package/bundled-skills/gemini-deep-research/SKILL.md +136 -0
  107. package/bundled-skills/gemini-deep-research/requirements.txt +2 -0
  108. package/bundled-skills/gemini-deep-research/scripts/research.py +692 -0
  109. package/bundled-skills/git-pushing/SKILL.md +21 -4
  110. package/bundled-skills/git-pushing/scripts/smart_commit.sh +206 -11
  111. package/bundled-skills/go-in-depth/scripts/workflow-script.js +4 -1
  112. package/bundled-skills/grok-build/SKILL.md +167 -0
  113. package/bundled-skills/grok-build/references/cli.md +99 -0
  114. package/bundled-skills/huggingface-tool-builder/references/find_models_by_paper.sh +1 -1
  115. package/bundled-skills/idea-autopsy/SKILL.md +147 -0
  116. package/bundled-skills/it-manager-hospital/README.md +1 -1
  117. package/bundled-skills/it-manager-pro/README.md +1 -1
  118. package/bundled-skills/itil-expert/README.md +1 -1
  119. package/bundled-skills/langgraph/SKILL.md +1 -1
  120. package/bundled-skills/linkedin-content-generator/SKILL.md +1 -1
  121. package/bundled-skills/lint-and-validate/scripts/lint_runner.py +23 -23
  122. package/bundled-skills/lint-and-validate/scripts/type_coverage.py +30 -30
  123. package/bundled-skills/logic-lens/SKILL.md +1 -1
  124. package/bundled-skills/lore/LICENSE +21 -0
  125. package/bundled-skills/lore/README.md +386 -0
  126. package/bundled-skills/lore/README.zh-CN.md +386 -0
  127. package/bundled-skills/lore/SKILL.md +453 -0
  128. package/bundled-skills/lore/WORKFLOWS.md +216 -0
  129. package/bundled-skills/lore/WORKFLOWS.zh-CN.md +216 -0
  130. package/bundled-skills/lore/references/audit-template.md +60 -0
  131. package/bundled-skills/lore/references/compatibility.md +228 -0
  132. package/bundled-skills/lore/references/config.md +125 -0
  133. package/bundled-skills/lore/references/entry-format.md +70 -0
  134. package/bundled-skills/lore/references/history-command.md +106 -0
  135. package/bundled-skills/lore/references/monorepo-detection.md +78 -0
  136. package/bundled-skills/lore/references/platform-mirrors.md +377 -0
  137. package/bundled-skills/lore/references/stale-new-markers.md +62 -0
  138. package/bundled-skills/lore/references/summary-template.md +98 -0
  139. package/bundled-skills/lore/scripts/README.md +54 -0
  140. package/bundled-skills/lore/scripts/README.zh-CN.md +54 -0
  141. package/bundled-skills/lore/scripts/find_duplicates.py +211 -0
  142. package/bundled-skills/lore/scripts/find_stale.py +116 -0
  143. package/bundled-skills/lore/scripts/history.py +527 -0
  144. package/bundled-skills/lore/scripts/id_hash.py +32 -0
  145. package/bundled-skills/lore/scripts/list_entries.py +183 -0
  146. package/bundled-skills/lovable-cleanup/SKILL.md +3 -3
  147. package/bundled-skills/makepad-splash/SKILL.md +1 -1
  148. package/bundled-skills/mmx-cli/SKILL.md +14 -1
  149. package/bundled-skills/monopoly/SKILL.md +5 -0
  150. package/bundled-skills/monopoly/patterns/SKILL.md +4 -0
  151. package/bundled-skills/monopoly/scale-benchmarks/SKILL.md +4 -0
  152. package/bundled-skills/monopoly/security-checklist/SKILL.md +4 -0
  153. package/bundled-skills/monopoly/tech-matrix/SKILL.md +4 -0
  154. package/bundled-skills/mtls-configuration/SKILL.md +1 -1
  155. package/bundled-skills/network-101/SKILL.md +4 -5
  156. package/bundled-skills/nika/SKILL.md +270 -0
  157. package/bundled-skills/not-a-vibe-coder/SKILL.md +4 -0
  158. package/bundled-skills/ontoly-software-graph/SKILL.md +160 -0
  159. package/bundled-skills/openclaw-github-repo-commander/SKILL.md +1 -1
  160. package/bundled-skills/pilot-protocol/SKILL.md +6 -3
  161. package/bundled-skills/postgres-readonly-queries/README.md +77 -0
  162. package/bundled-skills/postgres-readonly-queries/SKILL.md +152 -0
  163. package/bundled-skills/postgres-readonly-queries/connections.example.json +34 -0
  164. package/bundled-skills/postgres-readonly-queries/requirements.txt +1 -0
  165. package/bundled-skills/postgres-readonly-queries/scripts/query.py +262 -0
  166. package/bundled-skills/pptx-deck-creation/SKILL.md +275 -0
  167. package/bundled-skills/pptx-deck-creation/references/audit-checklist.md +156 -0
  168. package/bundled-skills/pptx-deck-creation/references/design-profiles.md +96 -0
  169. package/bundled-skills/pptx-deck-creation/references/python-snippets.md +150 -0
  170. package/bundled-skills/pptx-deck-creation/references/reference-deck-analysis.md +91 -0
  171. package/bundled-skills/pptx-deck-creation/references/visual-asset-adapters.md +158 -0
  172. package/bundled-skills/privilege-escalation-methods/SKILL.md +1 -1
  173. package/bundled-skills/product-decision-agent/SKILL.md +94 -0
  174. package/bundled-skills/product-decision-agent/agents/openai.yaml +7 -0
  175. package/bundled-skills/product-decision-agent/references/methodology-basis.md +232 -0
  176. package/bundled-skills/product-decision-agent/references/product-playbooks.md +813 -0
  177. package/bundled-skills/product-decision-agent/references/reasoning-engine.md +289 -0
  178. package/bundled-skills/product-decision-agent/references/response-examples.md +279 -0
  179. package/bundled-skills/product-decision-agent/scripts/quality_gate.py +221 -0
  180. package/bundled-skills/product-decision-agent/scripts/test_quality_gate.py +94 -0
  181. package/bundled-skills/pytest-skill/reference/playbook.md +358 -0
  182. package/bundled-skills/quit-sponsor/SKILL.md +96 -0
  183. package/bundled-skills/rclone-cli/references/providers/s3.md +1 -1
  184. package/bundled-skills/security-and-hardening/SKILL.md +1 -1
  185. package/bundled-skills/semgrep-rule-creator/SKILL.md +6 -6
  186. package/bundled-skills/skill-creator/README.md +3 -3
  187. package/bundled-skills/skill-creator/SKILL.md +8 -4
  188. package/bundled-skills/skill-creator/scripts/quick_validate.py +1 -1
  189. package/bundled-skills/sql-injection-testing/SKILL.md +4 -4
  190. package/bundled-skills/subagent-orchestrator/README.md +1 -1
  191. package/bundled-skills/super-code/bash/SKILL.md +3 -0
  192. package/bundled-skills/super-code/c/SKILL.md +3 -0
  193. package/bundled-skills/super-code/cpp/SKILL.md +3 -0
  194. package/bundled-skills/super-code/csharp/SKILL.md +3 -0
  195. package/bundled-skills/super-code/dart/SKILL.md +3 -0
  196. package/bundled-skills/super-code/elixir/SKILL.md +3 -0
  197. package/bundled-skills/super-code/go/SKILL.md +3 -0
  198. package/bundled-skills/super-code/java/SKILL.md +3 -0
  199. package/bundled-skills/super-code/kotlin/SKILL.md +3 -0
  200. package/bundled-skills/super-code/php/SKILL.md +3 -0
  201. package/bundled-skills/super-code/python/SKILL.md +3 -0
  202. package/bundled-skills/super-code/ruby/SKILL.md +3 -0
  203. package/bundled-skills/super-code/rust/SKILL.md +3 -0
  204. package/bundled-skills/super-code/scala/SKILL.md +3 -0
  205. package/bundled-skills/super-code/swift/SKILL.md +3 -0
  206. package/bundled-skills/super-code/typescript/SKILL.md +3 -0
  207. package/bundled-skills/telegram-bot-messaging/README.md +185 -0
  208. package/bundled-skills/telegram-bot-messaging/SKILL.md +101 -0
  209. package/bundled-skills/telegram-bot-messaging/scripts/telegram.sh +420 -0
  210. package/bundled-skills/test-guard/SKILL.md +132 -0
  211. package/bundled-skills/test-guard/references/jest.md +50 -0
  212. package/bundled-skills/test-guard/references/llm-app-testing.md +40 -0
  213. package/bundled-skills/test-guard/references/phpunit.md +56 -0
  214. package/bundled-skills/test-guard/references/pytest.md +65 -0
  215. package/bundled-skills/trading-ledger/SKILL.md +11 -3
  216. package/bundled-skills/uizze-ui-research/SKILL.md +93 -0
  217. package/bundled-skills/vibe-code-auditor/SKILL.md +1 -1
  218. package/bundled-skills/vibecode-production-qa-validator/SKILL.md +1 -1
  219. package/bundled-skills/videodb/scripts/ws_listener.py +29 -15
  220. package/bundled-skills/voice-ai-engine-development/README.md +1 -1
  221. package/bundled-skills/vulnerability-scanner/SKILL.md +1 -1
  222. package/bundled-skills/warehouse/SKILL.md +154 -0
  223. package/bundled-skills/woo-guard/SKILL.md +113 -0
  224. package/bundled-skills/woo-guard/references/checkout-and-money.md +64 -0
  225. package/bundled-skills/woo-guard/references/hpos-and-crud.md +87 -0
  226. package/bundled-skills/woo-guard/references/review-checklist.md +44 -0
  227. package/bundled-skills/woo-guard/references/sources.md +17 -0
  228. package/bundled-skills/wp-guard/SKILL.md +119 -0
  229. package/bundled-skills/wp-guard/references/i18n.md +88 -0
  230. package/bundled-skills/wp-guard/references/performance.md +70 -0
  231. package/bundled-skills/wp-guard/references/review-checklist.md +57 -0
  232. package/bundled-skills/wp-guard/references/security.md +100 -0
  233. package/bundled-skills/wp-guard/references/sources.md +27 -0
  234. package/bundled-skills/writing-skills/gotchas.md +1 -1
  235. package/bundled-skills/writing-skills/references/standards/metadata-standard.md +1 -1
  236. package/bundled-skills/x-twitter-scraper/SKILL.md +14 -32
  237. package/bundled-skills/xss-html-injection/SKILL.md +3 -3
  238. package/bundled-skills/youtube-seo-optimizer/SKILL.md +1 -1
  239. package/bundled-skills/youtube-summarizer/CHANGELOG.md +2 -2
  240. package/package.json +1 -1
  241. package/skills_index.json +273 -0
@@ -0,0 +1,113 @@
1
+ ---
2
+ name: "woo-guard"
3
+ description: "Review generated or changed WooCommerce extensions, payment and shipping integrations, checkout customizations, and order or product logic."
4
+ risk: "critical"
5
+ source: "community"
6
+ source_repo: "amElnagdy/guard-skills"
7
+ source_type: "community"
8
+ date_added: 2026-07-13
9
+ author: "community"
10
+ tags: []
11
+ tools: []
12
+ ---
13
+
14
+
15
+ # Woo Guard
16
+
17
+ You are reviewing generated or changed WooCommerce code before it ships. Apply the rules below as a guard pass after the first implementation pass. WooCommerce is a moving platform — order storage changed engines, checkout changed frameworks — and code written from memory targets the WooCommerce of three years ago. With money on the line, "works on my demo store" is not a standard.
18
+
19
+ These rules exist because AI agents produce WooCommerce code with systematic failures: order meta read through `get_post_meta()` (broken on HPOS stores), products updated by direct meta writes that skip lookup tables and hooks, checkout validated only in JavaScript, prices computed in floats, and `woocommerce_*` hooks registered before confirming WooCommerce is active.
20
+
21
+ ## When to Use
22
+
23
+ Use this skill when reviewing generated or changed WooCommerce code — extensions, payment and shipping integrations, checkout customizations, and order/product logic — before it ships. Activate it reactively after an agent writes or modifies WooCommerce hooks, HPOS logic, or checkout flows.
24
+
25
+ ## How to use this skill
26
+
27
+ **Guard-pass mode** (recommended): after WooCommerce code has been generated or edited, apply the rules to the diff or target files, then run the self-check before delivery.
28
+
29
+ **Live mode** (explicit): when the user invokes this skill before writing WooCommerce code, apply the same rules while writing, then run the self-check before delivery.
30
+
31
+ **Review mode** (the user asks you to review or audit WooCommerce code): walk [references/review-checklist.md](references/review-checklist.md) and produce a structured findings report. Do not edit code in review mode unless asked.
32
+
33
+ **Security floor** — these hold in all WooCommerce code, at maximum severity, because money is on the line:
34
+
35
+ - Escape all output with the context-correct `esc_*` function.
36
+ - `wp_unslash()` then sanitize all request data before it touches logic.
37
+ - Capability check plus nonce on every state change.
38
+ - `$wpdb->prepare()` for every query containing a variable.
39
+
40
+ If wp-guard is installed, run it alongside for the full WordPress layer.
41
+
42
+ ## Adapt to the project first
43
+
44
+ 1. Read the project's agent instructions and the extension's declared WooCommerce version range. Project conventions win on conflict.
45
+ 2. Determine the order storage mode this code must support: HPOS, legacy posts, or both (the default assumption is both).
46
+ 3. Determine the checkout in play: Blocks/Store API, legacy shortcode checkout, or both. Hooks for one do not fire in the other.
47
+ 4. Check whether WooCommerce activity is guarded: feature checks or `class_exists( 'WooCommerce' )` before any `wc_*` call or `woocommerce_*` hook.
48
+
49
+ ## The Rules
50
+
51
+ ### Order and product data — must fix
52
+
53
+ 1. **Orders are not posts.** Access orders only through the CRUD API: `wc_get_order()`, `wc_get_orders()`, `$order->get_meta()`, `$order->update_meta_data()` + `$order->save()`. Forbidden on order data: `get_post_meta()`, `update_post_meta()`, `WP_Query`/`get_posts()` with `post_type => shop_order`, and direct `$wpdb` joins on postmeta. These work on legacy stores and silently break on HPOS stores. Details: [references/hpos-and-crud.md](references/hpos-and-crud.md).
54
+
55
+ 2. **CRUD objects, getters/setters, then save.** Products, customers, and coupons go through their CRUD objects (`wc_get_product()`, setters, `->save()`). Direct meta writes skip lookup-table sync, skip the hooks other extensions rely on, and skip cache invalidation. Stock changes go through `wc_update_product_stock()` semantics; order state changes through `$order->update_status()` — which fire the emails and hooks the store expects.
56
+
57
+ 3. **Declare feature compatibility.** Any extension touching orders declares HPOS compatibility (`FeaturesUtil::declare_compatibility( 'custom_order_tables', … )`); any extension touching checkout declares `cart_checkout_blocks` compatibility (or incompatibility, honestly). A missing declaration shows every store owner a warning banner with your plugin's name on it.
58
+
59
+ ### Checkout and money — must fix
60
+
61
+ 4. **Checkout validation is server-side.** Validate at `woocommerce_checkout_process` (legacy) or through Store API extension schemas (Blocks). JavaScript validation is UX, never security. Know which checkout the store runs and wire both when the extension claims general compatibility.
62
+
63
+ 5. **Money is not a float.** Prices and totals go through `wc_format_decimal()` for storage-safe values, `wc_price()` for display, and WooCommerce's own tax/rounding settings for arithmetic. No hand-rolled currency symbols, no `number_format()` on prices, no float equality on totals.
64
+
65
+ ### Runtime discipline — should fix
66
+
67
+ 6. **Guard the runtime context.** `WC()->cart` and `WC()->session` are null in REST, cron, CLI, and admin contexts — check before touching them. Never assume a logged-in customer in webhook or gateway callbacks. Verify every `woocommerce_*` hook and `wc_*` function exists in the supported version range — WooCommerce renames and retires hooks across majors.
68
+
69
+ 7. **Hooks over template overrides.** Prefer, in order: existing WooCommerce hooks/filters → the `woocommerce_locate_template` filter → a theme-level override. A template override shipped inside a plugin freezes a copied file at one WooCommerce version and breaks on template updates — flag it in review, always.
70
+
71
+ 8. **Background work scales with order volume.** Batch jobs, syncs, and webhook fan-out go through Action Scheduler (bundled with WooCommerce), not raw WP-Cron loops. Handlers are idempotent — order events fire more than once in real stores.
72
+
73
+ ## Self-check before delivery
74
+
75
+ 1. Grep your diff for `get_post_meta`, `update_post_meta`, `post_type => 'shop_order'`: any of them touching orders? (Rule 1)
76
+ 2. Any product/order/customer write that bypasses a CRUD object's `save()`? (Rule 2)
77
+ 3. Does the extension declare HPOS (and checkout-blocks, if relevant) compatibility? (Rule 3)
78
+ 4. Is every checkout rule enforced server-side, for the checkout(s) the store actually runs? (Rule 4)
79
+ 5. Any float arithmetic, hardcoded currency symbol, or `number_format()` on money? (Rule 5)
80
+ 6. Any `WC()->cart`/`WC()->session` access that can run in REST/cron/CLI? Any unverified hook name? (Rule 6)
81
+ 7. Any template file shipped in the plugin? (Rule 7)
82
+ 8. Security floor: every output escaped, every request input unslashed then sanitized, every state change capability-checked and nonce-verified, every variable query prepared?
83
+
84
+ If any answer is wrong, fix it before showing the user.
85
+
86
+ ## Reporting format (review mode)
87
+
88
+ ```
89
+ **Rule N violation** in `path/file.php:<line or function>`
90
+ - What: <one sentence>
91
+ - Risk: <HPOS breakage / skipped hooks / money error / checkout bypass — one phrase>
92
+ - Fix: <one sentence>
93
+ ```
94
+
95
+ Group by file, lead with Rules 1–5 findings. If a file is clean, don't mention it.
96
+
97
+ ## Severity guide
98
+
99
+ - **Must fix:** Rules 1–5 — broken stores, skipped business logic, wrong money
100
+ - **Should fix:** Rules 6–8 — context crashes, update fragility, jobs that die at scale
101
+
102
+ ## References
103
+
104
+ - [references/hpos-and-crud.md](references/hpos-and-crud.md) — HPOS background, CRUD patterns, compatibility declaration, violation table
105
+ - [references/checkout-and-money.md](references/checkout-and-money.md) — legacy vs Blocks checkout, Store API validation, price and currency handling
106
+ - [references/review-checklist.md](references/review-checklist.md) — structured walk-through for review mode
107
+ - [references/sources.md](references/sources.md) — WooCommerce developer documentation URLs; read only when citing
108
+
109
+ ## What this skill does not do
110
+
111
+ - Cover the full WordPress layer beyond the security floor — i18n and asset/query discipline are wp-guard's jurisdiction when it is installed.
112
+ - Review store configuration, theme styling, or payment provider account setup.
113
+ - Decide pricing or business logic — it guards how WooCommerce code ships, not what the store sells.
@@ -0,0 +1,64 @@
1
+ # Woo Guard — Checkout and Money Reference
2
+
3
+ ## Contents
4
+
5
+ - Two checkouts, two hook surfaces
6
+ - Server-side validation
7
+ - Cart and session context guards
8
+ - Money handling
9
+ - Gateway and webhook callbacks
10
+
11
+ ## Two checkouts, two hook surfaces
12
+
13
+ Modern stores run the Blocks checkout (Store API); legacy stores run the shortcode checkout (`woocommerce_checkout_*` hooks, `wp_ajax` fragments). The hook surfaces do not overlap:
14
+
15
+ - Legacy-only: `woocommerce_checkout_fields`, `woocommerce_checkout_process`, `woocommerce_after_order_notes`.
16
+ - Blocks: Store API extensions (`ExtendSchema`), additional-fields API, server-side endpoint validation.
17
+
18
+ An extension claiming general compatibility wires both or declares which one it supports (see compatibility declaration in [hpos-and-crud.md](hpos-and-crud.md)). AI-generated checkout code overwhelmingly targets the legacy surface only — on a Blocks store it simply never runs: a hook on the wrong surface fails silently, no error, no behavior.
19
+
20
+ ## Server-side validation
21
+
22
+ ```php
23
+ /**
24
+ * Reject checkout when the VAT number is malformed.
25
+ *
26
+ * JS validation on the field is UX; this hook is the actual gate.
27
+ */
28
+ add_action( 'woocommerce_checkout_process', function () {
29
+ $vat = isset( $_POST['ncs_vat'] ) ? sanitize_text_field( wp_unslash( $_POST['ncs_vat'] ) ) : '';
30
+
31
+ if ( '' !== $vat && ! ncs_vat_is_valid( $vat ) ) {
32
+ wc_add_notice( __( 'Please enter a valid VAT number.', 'ncs-checkout' ), 'error' );
33
+ }
34
+ } );
35
+ ```
36
+
37
+ For Blocks, the equivalent lives in the Store API additional-fields/extension schema callbacks. Either way: the server decides, every field is unslashed then sanitized with the type-correct function, and error messages go through `wc_add_notice()`/schema errors — never `die()`.
38
+
39
+ ## Cart and session context guards
40
+
41
+ `WC()->cart`, `WC()->session`, and `WC()->customer` are initialized for front-end requests — they are null in REST, cron, CLI, webhooks, and most admin requests:
42
+
43
+ ```php
44
+ if ( function_exists( 'WC' ) && WC()->cart instanceof WC_Cart ) {
45
+ $count = WC()->cart->get_cart_contents_count();
46
+ }
47
+ ```
48
+
49
+ Code that touches the cart inside an API callback or scheduled job is a fatal error wearing a demo-store disguise. Flag it in review even when "it worked locally."
50
+
51
+ ## Money handling
52
+
53
+ - Storage and arithmetic inputs: `wc_format_decimal( $value )` — normalizes locale decimals and precision.
54
+ - Display: `wc_price( $amount )` — currency symbol, position, separators, all from store settings. Hardcoded `'$' . $amount` fails on the other 150 currencies.
55
+ - Totals and tax: use order/cart getters (`get_total()`, `get_subtotal()`, `WC_Tax` methods) — they apply the store's rounding mode. Re-deriving totals with raw float math produces penny drift that accountants will find.
56
+ - Comparisons: compare formatted decimals or integer minor units; never `==` on floats.
57
+ - Refund/discount logic: negative amounts have meaning — test the zero and partial cases explicitly (test-guard says hi).
58
+
59
+ ## Gateway and webhook callbacks
60
+
61
+ - Verify webhook signatures/secrets before touching any order; fail closed with the provider's expected status code.
62
+ - Look up orders from gateway references via `wc_get_orders( array( 'transaction_id' => … ) )` or stored CRUD meta — not custom SQL.
63
+ - Callbacks run unauthenticated by design: capability checks don't apply, signature verification is the authentication, and every input is still unslashed and sanitized before use.
64
+ - Idempotency: providers retry. Processing the same payment event twice must not complete an order twice.
@@ -0,0 +1,87 @@
1
+ # Woo Guard — HPOS and CRUD Reference
2
+
3
+ ## Contents
4
+
5
+ - Why HPOS breaks legacy code
6
+ - Order access patterns
7
+ - Order meta done right
8
+ - Products, stock, and lookup tables
9
+ - Status transitions
10
+ - Declaring compatibility
11
+ - Violation table for review
12
+
13
+ ## Why HPOS breaks legacy code
14
+
15
+ High-Performance Order Storage moved orders out of `wp_posts`/`wp_postmeta` into dedicated tables, and it is the default on new stores. Code that treats orders as posts returns empty results or stale data on HPOS stores — silently, with no error. Code written "from memory" almost always targets the legacy storage, because that is what most training-era tutorials show.
16
+
17
+ ## Order access patterns
18
+
19
+ ```php
20
+ // Wrong — assumes orders are posts. Fails on HPOS.
21
+ $total = get_post_meta( $order_id, '_order_total', true );
22
+ $orders = get_posts( array( 'post_type' => 'shop_order', 'numberposts' => 20 ) );
23
+
24
+ // Right — storage-agnostic CRUD API.
25
+ $order = wc_get_order( $order_id );
26
+ $total = $order ? $order->get_total() : 0;
27
+ $orders = wc_get_orders( array( 'status' => 'wc-processing', 'limit' => 20 ) );
28
+ ```
29
+
30
+ `wc_get_orders()` takes its own argument schema (not `WP_Query` args): `limit`, `status`, `customer_id`, `date_created`, `meta_query` equivalents via `field_query`. Never run an unbounded order query — always set a `limit` (wp-guard covers query discipline in depth when installed).
31
+
32
+ ## Order meta done right
33
+
34
+ ```php
35
+ $order = wc_get_order( $order_id );
36
+ $order->update_meta_data( '_ncs_sync_status', 'queued' );
37
+ $order->save(); // persists to whichever storage backend is active
38
+
39
+ $value = $order->get_meta( '_ncs_sync_status' ); // single value, unserialized
40
+ ```
41
+
42
+ `save()` is not optional — without it, meta changes exist only in memory. Batched changes: set everything, save once.
43
+
44
+ ## Products, stock, and lookup tables
45
+
46
+ Product meta writes through `update_post_meta()` skip `wc_product_meta_lookup` sync, skip `woocommerce_update_product`-family hooks, and skip cache invalidation — three classes of bugs other plugins will blame on you.
47
+
48
+ ```php
49
+ $product = wc_get_product( $product_id );
50
+ $product->set_stock_quantity( $new_qty );
51
+ $product->set_regular_price( wc_format_decimal( $price ) );
52
+ $product->save();
53
+ ```
54
+
55
+ Stock specifically: `wc_update_product_stock()` and the CRUD setters handle backorders, stock status flips, and concurrency better than any hand-rolled meta math. Direct increments via meta are race-prone on busy stores.
56
+
57
+ ## Status transitions
58
+
59
+ ```php
60
+ $order->update_status( 'completed', 'Synced to fulfillment.' ); // fires emails + hooks
61
+ ```
62
+
63
+ Never set status by writing meta or post fields — `update_status()` triggers the `woocommerce_order_status_*` hooks and customer emails the rest of the store depends on. If suppressing side effects is the goal, that is a design discussion to surface, not a meta write to sneak in.
64
+
65
+ ## Declaring compatibility
66
+
67
+ ```php
68
+ add_action( 'before_woocommerce_init', function () {
69
+ if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
70
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
71
+ \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true );
72
+ }
73
+ } );
74
+ ```
75
+
76
+ Declare only what is true — a false `custom_order_tables` declaration on postmeta-reading code converts a visible warning into an invisible data bug.
77
+
78
+ ## Violation table for review
79
+
80
+ | Grep hit | Why it fails |
81
+ |---|---|
82
+ | `get_post_meta( $order_id` | HPOS: order meta is not postmeta |
83
+ | `post_type => 'shop_order'` (or `shop_order_refund`) | HPOS: orders are not posts |
84
+ | `update_post_meta( $product_id` | Skips lookup tables, hooks, caches |
85
+ | `wp_update_post` on order/product IDs | Same class of bypass |
86
+ | `$wpdb` joins on `postmeta` for order data | HPOS + fragile schema coupling |
87
+ | `posts_per_page => -1` over products/orders | Unbounded query, store-sized blast radius |
@@ -0,0 +1,44 @@
1
+ # Woo Guard — Review Checklist
2
+
3
+ Structured walk for review mode. First sweep the security floor on the same files — output escaping, unslash-then-sanitize on request data, capability plus nonce on state changes, prepared queries — money code gets zero security slack (wp-guard covers the full WordPress layer when installed). Cite file:line.
4
+
5
+ ## Contents
6
+
7
+ - Pass 1: HPOS and CRUD greps
8
+ - Pass 2: Checkout and money
9
+ - Pass 3: Runtime context
10
+ - Pass 4: Compatibility and packaging
11
+ - Reporting
12
+
13
+ ## Pass 1: HPOS and CRUD greps (must fix)
14
+
15
+ Run the violation table in [hpos-and-crud.md](hpos-and-crud.md):
16
+
17
+ - `get_post_meta` / `update_post_meta` / `wp_update_post` touching order or product IDs
18
+ - `post_type => 'shop_order'` in any query; `$wpdb` joins on postmeta for order data
19
+ - Meta changes without a following `save()`
20
+ - Stock or order status set by meta/post-field writes instead of `wc_update_product_stock()` / `$order->update_status()`
21
+ - Unbounded `wc_get_orders()` / product queries (no `limit`)
22
+
23
+ ## Pass 2: Checkout and money (must fix)
24
+
25
+ - Checkout rules enforced server-side (`woocommerce_checkout_process` or Store API schema)? JS-only validation is a finding.
26
+ - Which checkout does the code target — and does that match what it claims to support?
27
+ - Money: `wc_format_decimal()` on inputs, `wc_price()` on display, store rounding on totals; flag float arithmetic, `number_format()`, hardcoded symbols, float `==`.
28
+ - Webhook/gateway callbacks: signature verified before order access? Idempotent on retries?
29
+
30
+ ## Pass 3: Runtime context (should fix)
31
+
32
+ - `WC()->cart` / `WC()->session` / `WC()->customer` reachable from REST, cron, CLI, or webhooks without guards?
33
+ - `woocommerce_*` hooks and `wc_*` functions verified to exist in the supported version range?
34
+ - WooCommerce-active checks before hooking (`class_exists` / feature checks)?
35
+
36
+ ## Pass 4: Compatibility and packaging (should fix)
37
+
38
+ - `FeaturesUtil` declarations present and truthful (`custom_order_tables`, `cart_checkout_blocks`)?
39
+ - Template overrides shipped inside the plugin? (Always a finding — hooks or `woocommerce_locate_template`.)
40
+ - Background/batch work on Action Scheduler, idempotent handlers?
41
+
42
+ ## Reporting
43
+
44
+ Use the SKILL.md format (What / Risk / Fix). Lead with Pass 1–2 findings and an overall verdict (merge / fix first / do not merge). Note explicitly when security-floor findings exist on the same files so the user sees the full bill at once.
@@ -0,0 +1,17 @@
1
+ # Woo Guard — Sources
2
+
3
+ Central bibliography. Operational guidance lives in the other references; read this file only when a source URL is needed.
4
+
5
+ ## Contents
6
+
7
+ - WooCommerce developer documentation
8
+
9
+ ## WooCommerce developer documentation
10
+
11
+ - HPOS (High-Performance Order Storage): https://developer.woocommerce.com/docs/features/high-performance-order-storage/
12
+ - HPOS recipe book (compatibility patterns): https://developer.woocommerce.com/docs/features/high-performance-order-storage/recipe-book/
13
+ - CRUD objects: https://developer.woocommerce.com/docs/category/data-management/crud-objects/
14
+ - Store API: https://developer.woocommerce.com/docs/apis/store-api/
15
+ - Cart and Checkout Blocks — extensibility: https://developer.woocommerce.com/docs/category/cart-and-checkout-blocks/
16
+ - Action Scheduler: https://actionscheduler.org/
17
+ - Payment gateway API: https://developer.woocommerce.com/docs/woocommerce-payment-gateway-api/
@@ -0,0 +1,119 @@
1
+ ---
2
+ name: "wp-guard"
3
+ description: "Review generated or changed WordPress plugins, themes, and blocks for security, internationalization, performance, and API correctness."
4
+ risk: "offensive"
5
+ source: "community"
6
+ source_repo: "amElnagdy/guard-skills"
7
+ source_type: "community"
8
+ date_added: 2026-07-13
9
+ author: "community"
10
+ tags: []
11
+ tools: []
12
+ ---
13
+
14
+
15
+ # WP Guard
16
+
17
+ > [!WARNING]
18
+ > **Authorized Use Only.** Review only WordPress code and environments the user owns or is explicitly authorized to assess. Keep checks non-destructive and inside the approved scope.
19
+
20
+ You are reviewing generated or changed WordPress code before it ships. Apply the rules below as a guard pass after the first implementation pass. Be a sharp reviewer, not a pedantic one: flag what creates vulnerabilities, breaks translations, or melts servers — ignore cosmetic preferences WPCS tooling already handles.
21
+
22
+ These rules exist because AI agents produce WordPress code with systematic failures: raw `echo` of request data, AJAX handlers with neither nonce nor capability check, SQL built by string interpolation, English hardcoded into user-facing strings, `posts_per_page => -1` on sites with a million posts, and hand-rolled replacements for APIs core already ships. Each one looks fine in a demo and fails in production.
23
+
24
+ ## When to Use
25
+
26
+ Use this skill when reviewing generated or changed WordPress code — plugins, themes, and blocks — before it ships. Activate it reactively after an agent writes, edits, or reviews code touching WordPress APIs: hooks, custom post types, REST endpoints, database queries, and block editor integrations.
27
+
28
+ ## How to use this skill
29
+
30
+ **Guard-pass mode** (recommended): after WordPress code has been generated or edited, apply the rules to the diff or target files, then run the self-check before delivery. Fix violations before showing the user.
31
+
32
+ **Live mode** (explicit): when the user invokes this skill before writing WordPress code, apply the same rules while writing, then run the self-check before delivery.
33
+
34
+ **Review mode** (the user asks you to review, audit, or rate WordPress code): walk [references/review-checklist.md](references/review-checklist.md) against the target files and produce a structured findings report. Do not edit code in review mode unless asked.
35
+
36
+ Pair this skill with clean-code-guard when both are installed: clean-code-guard owns generic code quality; wp-guard owns the WordPress layer.
37
+
38
+ ## Adapt to the project first
39
+
40
+ 1. Read the project's agent instructions (CLAUDE.md, AGENTS.md), `phpcs.xml`/WPCS config, and `composer.json`. Project conventions win on conflict.
41
+ 2. Identify the established prefix (functions, options, meta keys, handles) and the minimum supported WP/PHP versions. Match both.
42
+ 3. Detect context: WooCommerce APIs in play → apply woo-guard alongside this skill when it is installed; otherwise apply WooCommerce's HPOS, CRUD, and checkout rules from its developer documentation. Multilingual site (WPML/Polylang/multisite) → i18n rules are blocking, not advisory.
43
+ 4. Read one neighboring file before writing. Mirror its error handling, hook registration style, and escaping habits — unless they violate the security rules below, which are non-negotiable.
44
+
45
+ ## The Rules
46
+
47
+ ### Security — must fix, no exceptions
48
+
49
+ 1. **Escape late, escape everything.** Every variable crossing into HTML output goes through the context-correct function: `esc_html()`, `esc_attr()`, `esc_url()`, or `wp_kses()`/`wp_kses_post()` for rich content. Data passed to inline JS goes through `wp_json_encode()` + `wp_add_inline_script()` — `esc_js()` is legacy, for single-quoted strings in inline attributes only. Escaping happens at output, not at storage. `echo $anything;` without an `esc_*` wrapper fails review.
50
+
51
+ 2. **Sanitize early, and unslash first.** Request data (`$_POST`, `$_GET`, `$_REQUEST`, `$_SERVER`) never touches logic raw: `wp_unslash()` first, then the type-correct sanitizer (`sanitize_text_field()`, `sanitize_key()`, `absint()`, `sanitize_email()`, …). Sanitization is not escaping; doing one never excuses the other.
52
+
53
+ 3. **Every state change proves identity and intent.** Form handlers, AJAX endpoints, and REST routes that change anything require BOTH a capability check (`current_user_can()`) AND a nonce (`check_admin_referer()`, `check_ajax_referer()`, or REST nonce handling). A nonce is not authorization. A REST `permission_callback` of `__return_true` on a writing route fails review.
54
+
55
+ 4. **`$wpdb->prepare()` for every query containing a variable.** Placeholders (`%s`, `%d`, `%f`, and `%i` for identifiers on WP ≥ 6.2), never interpolation or concatenation. Prefer `WP_Query`, the meta and options APIs over raw SQL when they can express the query.
56
+
57
+ ### Core API discipline
58
+
59
+ 5. **Use the platform; don't reinvent it.** Outbound HTTP via `wp_remote_get()`/`wp_remote_post()`, never curl. Assets via `wp_enqueue_script()`/`wp_enqueue_style()`, never echoed `<script>`/`<style>` tags. Scheduling via WP-Cron or Action Scheduler. Redirects via `wp_safe_redirect()` followed by `exit`. File writes via `WP_Filesystem`. Simple persistent data via options/transients, not a custom table.
60
+
61
+ 6. **Verify every hook and function exists.** Before `add_action()`, `add_filter()`, or calling a core/plugin function, confirm it exists in the supported versions — read the source or the project's installed code. Hallucinated hooks fail silently in WordPress: no error, no behavior. Also match the hook to the moment — front-end code does not load on `admin_init`, queries do not run before `init` expects them.
62
+
63
+ 7. **Prefix or namespace everything public.** Functions, classes, options, transients, meta keys, script handles, AJAX actions, REST namespaces — all carry the project prefix. Generic names (`get_settings`, `data`, `api_key`) are collisions waiting for the next active plugin.
64
+
65
+ 8. **Guard direct access.** Every PHP file that does work starts with the `ABSPATH` check (or equivalent project convention).
66
+
67
+ ### Internationalization
68
+
69
+ 9. **Every user-facing string is translation-ready.** The correct wrapper for the context (`__()`, `_e()`, `_x()`, `_n()`, or the escaping combos `esc_html__()`, `esc_attr__()`), a literal text domain matching the plugin slug — never a variable or constant — translator comments on every placeholder, `_n()` for plurals (never `sprintf` with a hardcoded singular/plural choice), and no sentence assembly by concatenation. Dates and numbers through `date_i18n()`/`wp_date()` and `number_format_i18n()`. Details and JS i18n: [references/i18n.md](references/i18n.md).
70
+
71
+ ### Performance
72
+
73
+ 10. **Query discipline.** No `posts_per_page => -1` and no `query_posts()`, ever. Use `'fields' => 'ids'` when only IDs are needed, `'no_found_rows' => true` when not paginating, and never query inside a loop what could be primed once (meta/term caches). Details: [references/performance.md](references/performance.md).
74
+
75
+ 11. **Cache expensive work, load assets where used.** Remote calls and heavy computations go behind transients or the object cache with a deliberate TTL. Options that are large or rarely read register with `autoload => false`. Scripts and styles enqueue only on the screens that use them.
76
+
77
+ ## Self-check before delivery
78
+
79
+ 1. Grep your diff for `echo`, `print`, `<?=`: is every variable output escaped with the context-correct function?
80
+ 2. Grep for `$_POST`, `$_GET`, `$_REQUEST`: unslashed? sanitized? nonce-verified? capability-checked?
81
+ 3. Grep for `$wpdb->`: every variable behind a placeholder?
82
+ 4. Any user-facing string outside an i18n wrapper? Any non-literal text domain?
83
+ 5. Any hook or function you did not verify exists?
84
+ 6. Any unbounded query, uncached remote call, or unconditional enqueue?
85
+ 7. Does every new public name carry the project prefix?
86
+ 8. Would this survive WPCS (`WordPress-Extra` + `WordPress-Security`) without warnings you cannot justify?
87
+
88
+ If any answer is wrong, fix it before showing the user.
89
+
90
+ ## Reporting format (review mode)
91
+
92
+ ```
93
+ **Rule N violation** in `path/file.php:<line or function>`
94
+ - What: <one sentence>
95
+ - Risk: <XSS / SQLi / CSRF / broken i18n / scaling — one phrase>
96
+ - Fix: <one sentence>
97
+ ```
98
+
99
+ Group by file, lead with security findings. If a file is clean, don't mention it.
100
+
101
+ ## Severity guide
102
+
103
+ - **Must fix:** Rules 1–4 — these are exploitable (XSS, SQLi, CSRF, privilege escalation)
104
+ - **Should fix:** Rules 5–9 — conflicts, silent failures, untranslatable releases
105
+ - **Worth noting:** Rules 10–11 — they decide whether the code survives traffic; block on them for code that runs on every request
106
+
107
+ ## References
108
+
109
+ - [references/security.md](references/security.md) — escaping/sanitization function tables, nonce lifecycle, REST permissions, `$wpdb->prepare` details, file uploads
110
+ - [references/i18n.md](references/i18n.md) — wrapper selection, text domain rules, plurals, translator comments, JS translations, RTL, multilingual-plugin gotchas
111
+ - [references/performance.md](references/performance.md) — WP_Query flags, transients vs object cache, autoload hygiene, asset loading, cron, scaling traps
112
+ - [references/review-checklist.md](references/review-checklist.md) — structured walk-through for review mode
113
+ - [references/sources.md](references/sources.md) — handbook and research URLs; read only when citing a source
114
+
115
+ ## What this skill does not do
116
+
117
+ - Run PHPCS, PHPStan, or Plugin Check — use the project's tooling for mechanical verification; this skill is the judgment layer above it.
118
+ - Decide plugin architecture or business logic — it guards how WordPress code ships, not what it does.
119
+ - Replace clean-code-guard or test-guard — generic code quality and test quality remain their jurisdiction.
@@ -0,0 +1,88 @@
1
+ # WP Guard — Internationalization Reference
2
+
3
+ ## Contents
4
+
5
+ - Wrapper selection
6
+ - Text domain rules
7
+ - Placeholders and translator comments
8
+ - Plurals
9
+ - Sentence assembly
10
+ - JavaScript i18n
11
+ - Dates, numbers, RTL
12
+ - Multilingual-plugin gotchas
13
+
14
+ ## Wrapper selection
15
+
16
+ | Situation | Use |
17
+ |---|---|
18
+ | Return a translated string | `__( 'Text', 'my-plugin' )` |
19
+ | Echo a translated string | `_e( 'Text', 'my-plugin' )` — or better, `esc_html_e()` |
20
+ | Translate + escape for HTML | `esc_html__()` / `esc_html_e()` |
21
+ | Translate + escape for attribute | `esc_attr__()` / `esc_attr_e()` |
22
+ | Ambiguous word needing context | `_x( 'Post', 'verb', 'my-plugin' )` |
23
+ | Plural | `_n( '%s item', '%s items', $count, 'my-plugin' )` |
24
+ | Plural + context | `_nx()` |
25
+
26
+ When a string is both translated and output, the combined wrappers (`esc_html__`) are required — translations are untrusted input like any other (a compromised translation file is an XSS vector).
27
+
28
+ ## Text domain rules
29
+
30
+ - Literal string, always: `__( 'Text', 'my-plugin' )`. Never `__( 'Text', PLUGIN_DOMAIN )`, never a variable — static analysis tools and translate.wordpress.org both fail on non-literal domains.
31
+ - Must match the plugin slug exactly (the WordPress.org directory enforces this).
32
+ - One domain per plugin/theme. AI agents copying snippets from other projects routinely import foreign text domains — grep for domains that don't match the project's.
33
+
34
+ ## Placeholders and translator comments
35
+
36
+ ```php
37
+ /* translators: 1: customer name, 2: order number. */
38
+ $message = sprintf(
39
+ __( 'Hi %1$s, your order #%2$d is on its way.', 'my-plugin' ),
40
+ $customer_name,
41
+ $order_id
42
+ );
43
+ ```
44
+
45
+ - Numbered placeholders (`%1$s`) whenever there is more than one — translators reorder words.
46
+ - A `/* translators: … */` comment on every string with placeholders, immediately above the line.
47
+ - Never put variables or HTML soup inside the translatable string when it can sit outside.
48
+
49
+ ## Plurals
50
+
51
+ `_n()` exists because languages have between one and six plural forms. Never:
52
+
53
+ ```php
54
+ // Wrong — English-only logic.
55
+ $label = $count === 1 ? __( 'item', 'my-plugin' ) : __( 'items', 'my-plugin' );
56
+ ```
57
+
58
+ Always `_n( '%s item', '%s items', $count, 'my-plugin' )`, then `sprintf()` with `number_format_i18n( $count )`.
59
+
60
+ ## Sentence assembly
61
+
62
+ Never build sentences by concatenation — word order differs across languages:
63
+
64
+ ```php
65
+ // Wrong: translators get fragments they cannot reorder.
66
+ echo __( 'Imported', 'my-plugin' ) . ' ' . $count . ' ' . __( 'products', 'my-plugin' );
67
+
68
+ // Right: one string, one placeholder, full context.
69
+ /* translators: %s: number of imported products. */
70
+ printf( esc_html__( 'Imported %s products.', 'my-plugin' ), number_format_i18n( $count ) );
71
+ ```
72
+
73
+ ## JavaScript i18n
74
+
75
+ - `wp_set_script_translations( 'my-handle', 'my-plugin' )` after enqueueing; use `__()` from `@wordpress/i18n` in the JS.
76
+ - Legacy pattern (`wp_localize_script` with pre-translated strings) is acceptable in legacy codebases — match the project.
77
+
78
+ ## Dates, numbers, RTL
79
+
80
+ - Dates: `wp_date()` / `date_i18n()` with the site's format options — never raw `date()` for display.
81
+ - Numbers: `number_format_i18n()`.
82
+ - CSS: logical properties (`margin-inline-start`, not `margin-left`) for new styles; don't hand-write directional CSS — build `-rtl.css` files with RTLCSS. Auto-loading them applies only to core styles and block.json-registered styles; classic plugin/theme handles must opt in with `wp_style_add_data( $handle, 'rtl', 'replace' )`.
83
+
84
+ ## Multilingual-plugin gotchas (WPML / Polylang)
85
+
86
+ - Strings stored in options/meta are NOT translated by `__()` — they need string registration (WPML String Translation / `pll_register_string`). Flag stored user-facing strings during review.
87
+ - IDs are language-specific: a hardcoded `page_id` points at one language's page. Resolve through the multilingual plugin's API or filters when the project uses one.
88
+ - Queries on multilingual sites are language-filtered by default — explicitly note when a query intentionally crosses languages.
@@ -0,0 +1,70 @@
1
+ # WP Guard — Performance Reference
2
+
3
+ ## Contents
4
+
5
+ - WP_Query discipline
6
+ - Meta and term cache priming
7
+ - Transients vs object cache
8
+ - Options autoload hygiene
9
+ - Asset loading
10
+ - Cron and background work
11
+ - Scaling traps checklist
12
+
13
+ ## WP_Query discipline
14
+
15
+ - `posts_per_page => -1` is forbidden. There is always a bound; if the caller "needs everything," page through with a loop or use a bounded cap the project agrees on.
16
+ - `query_posts()` is forbidden — it clobbers the main query. Use `WP_Query` or `pre_get_posts`.
17
+ - Only IDs needed → `'fields' => 'ids'` (skips row hydration and caches).
18
+ - Not paginating → `'no_found_rows' => true` (skips `SQL_CALC_FOUND_ROWS`).
19
+ - Not using meta/terms in the loop → `'update_post_meta_cache' => false`, `'update_post_term_cache' => false`.
20
+ - Avoid `'meta_query'` on unindexed scans for high-traffic paths — meta queries do not scale on large `postmeta` tables; consider a lookup table or taxonomy when the access pattern is hot.
21
+ - Never run queries inside `foreach` when one query (or cache priming) can fetch the set.
22
+
23
+ ## Meta and term cache priming
24
+
25
+ The N+1 killer. When iterating IDs and reading meta per item:
26
+
27
+ ```php
28
+ $ids = get_posts( array( 'fields' => 'ids', /* … */ ) );
29
+ update_meta_cache( 'post', $ids ); // one query primes the cache
30
+ foreach ( $ids as $id ) {
31
+ $sku = get_post_meta( $id, '_sku', true ); // served from cache
32
+ }
33
+ ```
34
+
35
+ `update_meta_cache()` and `update_object_term_cache()` exist for exactly this; on WP ≥ 6.1, `_prime_post_caches()` batches posts, meta, and terms in one call (public API since 6.1 despite the underscore). AI-generated loops skip them every time.
36
+
37
+ ## Transients vs object cache
38
+
39
+ - `set_transient()` / `get_transient()` — persistent cache with TTL; backed by the object cache when a drop-in exists, by the options table otherwise.
40
+ - `wp_cache_get()` / `wp_cache_set()` — request-scope by default, persistent only with an object-cache drop-in (Redis/Memcached). Use cache groups and deliberate TTLs.
41
+ - Expensive remote calls (Rule 11) always go behind one of these. Choose TTL consciously; never cache user-specific data in a shared key — include the user/locale in the key when output varies by them.
42
+ - On failure paths, decide explicitly whether to cache the failure (short TTL) or retry every request — and say which in a comment.
43
+
44
+ ## Options autoload hygiene
45
+
46
+ Every `autoload => true` option loads on EVERY request into `alloptions`. Rules:
47
+
48
+ - `add_option( 'ncs_big_report_cache', $data, '', false )` — large or rarely-read data never autoloads (pass `false` as the third arg of `update_option` too; the parameter exists since WP 4.2).
49
+ - Keep individual autoloaded options small; an `alloptions` blob over ~1 MB is a known site-killer on high-traffic sites.
50
+ - One serialized settings array per plugin beats twenty separate options.
51
+
52
+ ## Asset loading
53
+
54
+ - Enqueue only where used: check `is_admin()`, screen IDs (`get_current_screen()`), shortcode presence, or block usage before enqueueing.
55
+ - Front-end assets registered on `wp_enqueue_scripts`, admin on `admin_enqueue_scripts` with the `$hook_suffix` check.
56
+ - Version assets with the plugin version (cache busting); load non-critical JS with `defer`/`async` strategies (`wp_register_script` args on WP ≥ 6.3).
57
+
58
+ ## Cron and background work
59
+
60
+ - WP-Cron is traffic-driven and can stack: guard handlers against overlap (a lock transient), keep events idempotent.
61
+ - Long or high-volume jobs → Action Scheduler when WooCommerce (or the library) is present.
62
+ - Never `sleep()` in a request; never do batch work on `init` for every visitor.
63
+
64
+ ## Scaling traps checklist
65
+
66
+ - Unbounded `get_users()` / `get_terms()` on large sites — same rules as posts.
67
+ - `switch_to_blog()` in loops without batching (multisite).
68
+ - Per-request remote HTTP without caching — one slow third party becomes your TTFB.
69
+ - Writing to options on front-end requests (cache invalidation storm under traffic).
70
+ - Counting rows with `found_posts` when an indexed count query or cached counter would do.