@ai-kits/wp-ag-kit 1.0.2 → 1.0.3

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 (28) hide show
  1. package/README.md +12 -8
  2. package/STRUCTURE.md +9 -7
  3. package/agents/woocommerce-expert.md +32 -0
  4. package/agents/wordpress-expert.md +4 -2
  5. package/package.json +5 -3
  6. package/skills/woocommerce/SKILL.md +54 -0
  7. package/skills/woocommerce/references/backend-dev-guide.md +44 -0
  8. package/skills/woocommerce/references/code-entities.md +186 -0
  9. package/skills/woocommerce/references/code-quality.md +273 -0
  10. package/skills/woocommerce/references/code-review-guide.md +71 -0
  11. package/skills/woocommerce/references/coding-conventions.md +182 -0
  12. package/skills/woocommerce/references/copy-guidelines-guide.md +17 -0
  13. package/skills/woocommerce/references/data-integrity.md +164 -0
  14. package/skills/woocommerce/references/dependency-injection.md +102 -0
  15. package/skills/woocommerce/references/dev-cycle-guide.md +32 -0
  16. package/skills/woocommerce/references/file-entities.md +73 -0
  17. package/skills/woocommerce/references/hooks.md +87 -0
  18. package/skills/woocommerce/references/js-i18n-patterns.md +298 -0
  19. package/skills/woocommerce/references/markdown-guide.md +358 -0
  20. package/skills/woocommerce/references/markdown-linting.md +202 -0
  21. package/skills/woocommerce/references/php-i18n-patterns.md +83 -0
  22. package/skills/woocommerce/references/php-linting-patterns.md +304 -0
  23. package/skills/woocommerce/references/running-tests.md +249 -0
  24. package/skills/woocommerce/references/security-patterns.md +109 -0
  25. package/skills/woocommerce/references/sentence-case.md +177 -0
  26. package/skills/woocommerce/references/type-annotations.md +161 -0
  27. package/skills/woocommerce/references/unit-tests.md +362 -0
  28. package/skills/woocommerce/references/woocommerce-global-objects.md +89 -0
@@ -0,0 +1,358 @@
1
+
2
+ # WooCommerce Markdown Guidelines
3
+
4
+ This skill provides guidance for creating and editing markdown files in the WooCommerce project.
5
+
6
+ ## Critical Rules
7
+
8
+ 1. **Always lint after changes** - Run `markdownlint --fix` then `markdownlint` to verify
9
+ 2. **Run from repository root** - Ensures `.markdownlint.json` config is loaded
10
+ 3. **Use UTF-8 encoding** - Especially for directory trees and special characters
11
+ 4. **Follow WooCommerce markdown standards** - See configuration rules below
12
+
13
+ ## WooCommerce Markdown Configuration
14
+
15
+ The project uses markdownlint with these specific rules (from `.markdownlint.json`):
16
+
17
+ ### Enabled Rules
18
+
19
+ - **MD003**: Heading style must be ATX (`# Heading` not `Heading\n===`)
20
+ - **MD007**: Unordered list indentation must be 4 spaces
21
+ - **MD013**: Line length limit disabled (set to 9999)
22
+ - **MD024**: Multiple headings with same content allowed (only check siblings)
23
+ - **MD031**: Fenced code blocks must be surrounded by blank lines
24
+ - **MD032**: Lists must be surrounded by blank lines
25
+ - **MD033**: HTML allowed for `<video>` elements only
26
+ - **MD036**: Emphasis (bold/italic) should not be used as headings - use proper heading tags
27
+ - **MD040**: Fenced code blocks should specify language
28
+ - **MD047**: Files must end with a single newline
29
+
30
+ ### Disabled Rules
31
+
32
+ - **no-hard-tabs**: Tabs are allowed
33
+ - **whitespace**: Trailing whitespace rules disabled
34
+
35
+ ## Markdown Writing Guidelines
36
+
37
+ ### Headings
38
+
39
+ ```markdown
40
+ # Main Title (H1) - Only one per file
41
+
42
+ ## Section (H2)
43
+
44
+ ### Subsection (H3)
45
+
46
+ #### Minor Section (H4)
47
+ ```
48
+
49
+ - Use ATX style (`#`) not underline style
50
+ - One H1 per file (usually the title)
51
+ - Maintain heading hierarchy (don't skip levels)
52
+
53
+ ### Lists
54
+
55
+ **Unordered lists:**
56
+
57
+ ```markdown
58
+ - Item one
59
+ - Item two
60
+ - Nested item (4 spaces)
61
+ - Another nested item
62
+ - Item three
63
+ ```
64
+
65
+ **Ordered lists:**
66
+
67
+ ```markdown
68
+ 1. First item
69
+ 2. Second item
70
+ 3. Third item
71
+ ```
72
+
73
+ **Important:**
74
+
75
+ - Use 4 spaces for nested list items
76
+ - Add blank line before and after lists
77
+ - Use `-` for unordered lists (not `*` or `+`)
78
+
79
+ ### Code Blocks
80
+
81
+ **Always specify the language:**
82
+
83
+ ````markdown
84
+ ```bash
85
+ pnpm test:php:env
86
+ ```
87
+
88
+ ```php
89
+ public function process_order( int $order_id ) {
90
+ // code here
91
+ }
92
+ ```
93
+
94
+ ```javascript
95
+ const result = calculateTotal(items);
96
+ ```
97
+ ````
98
+
99
+ **Common language identifiers:**
100
+
101
+ - `bash` - Shell commands
102
+ - `php` - PHP code
103
+ - `javascript` or `js` - JavaScript
104
+ - `typescript` or `ts` - TypeScript
105
+ - `json` - JSON data
106
+ - `sql` - SQL queries
107
+ - `markdown` or `md` - Markdown examples
108
+
109
+ **Code block rules:**
110
+
111
+ - Add blank line before the opening fence
112
+ - Add blank line after the closing fence
113
+ - Always specify language (never use plain ` ``` `)
114
+
115
+ ### Inline Code
116
+
117
+ Use backticks for inline code:
118
+
119
+ ```markdown
120
+ Use the `process_order()` method to handle orders.
121
+ The `$order_id` parameter must be an integer.
122
+ ```
123
+
124
+ ### Links
125
+
126
+ ```markdown
127
+ [Link text](https://example.com)
128
+
129
+ [Internal link](../path/to/file.md)
130
+
131
+ [Link with title](https://example.com "Optional title")
132
+ ```
133
+
134
+ ### Tables
135
+
136
+ ```markdown
137
+ | Column 1 | Column 2 | Column 3 |
138
+ |----------|----------|----------|
139
+ | Value 1 | Value 2 | Value 3 |
140
+ | Value 4 | Value 5 | Value 6 |
141
+ ```
142
+
143
+ - Use pipes (`|`) for column separators
144
+ - Header separator row required
145
+ - Alignment optional (`:---`, `:---:`, `---:`)
146
+
147
+ ### Directory Trees
148
+
149
+ **Always use UTF-8 box-drawing characters:**
150
+
151
+ ```markdown
152
+ src/
153
+ ├── Internal/
154
+ │ ├── Admin/
155
+ │ │ └── Controller.php
156
+ │ └── Utils/
157
+ │ └── Helper.php
158
+ └── External/
159
+ └── API.php
160
+ ```
161
+
162
+ **Never use:**
163
+
164
+ - ASCII art (`+--`, `|--`)
165
+ - Spaces or tabs for tree structure
166
+ - Control characters
167
+
168
+ ### Emphasis
169
+
170
+ ```markdown
171
+ **Bold text** for strong emphasis
172
+ *Italic text* for regular emphasis
173
+ ***Bold and italic*** for very strong emphasis
174
+ ```
175
+
176
+ ## Workflow for Editing Markdown
177
+
178
+ 1. **Make your changes** to the markdown file
179
+ 2. **Auto-fix linting issues:**
180
+
181
+ ```bash
182
+ markdownlint --fix path/to/file.md
183
+ ```
184
+
185
+ 3. **Check for remaining issues:**
186
+
187
+ ```bash
188
+ markdownlint path/to/file.md
189
+ ```
190
+
191
+ 4. **Manually fix** what remains (usually language specs for code blocks)
192
+ 5. **Verify clean** - No output means success
193
+ 6. **Commit changes**
194
+
195
+ ## Common Linting Errors and Fixes
196
+
197
+ ### MD007: List indentation
198
+
199
+ **Problem:**
200
+
201
+ ```markdown
202
+ - Item
203
+ - Nested (only 2 spaces)
204
+ ```
205
+
206
+ **Fix:**
207
+
208
+ ```markdown
209
+ - Item
210
+ - Nested (4 spaces)
211
+ ```
212
+
213
+ ### MD031: Code blocks need blank lines
214
+
215
+ **Problem:**
216
+
217
+ ````markdown
218
+ Some text
219
+ ```bash
220
+ command
221
+ ```
222
+ More text
223
+ ````
224
+
225
+ **Fix:**
226
+
227
+ ````markdown
228
+ Some text
229
+
230
+ ```bash
231
+ command
232
+ ```
233
+
234
+ More text
235
+ ````
236
+
237
+ ### MD032: Lists need blank lines
238
+
239
+ **Problem:**
240
+
241
+ ````markdown
242
+ Some text
243
+ - List item
244
+ ````
245
+
246
+ **Fix:**
247
+
248
+ ````markdown
249
+ Some text
250
+
251
+ - List item
252
+ ````
253
+
254
+ ### MD036: Emphasis as heading
255
+
256
+ **Problem:**
257
+
258
+ ```markdown
259
+ **Example: Using bold as a heading**
260
+
261
+ Some content here
262
+ ```
263
+
264
+ **Fix:**
265
+
266
+ ```markdown
267
+ #### Example: Using a proper heading
268
+
269
+ Some content here
270
+ ```
271
+
272
+ ### MD040: Code needs language
273
+
274
+ **Problem:**
275
+
276
+ ````markdown
277
+ ```
278
+ code here
279
+ ```
280
+ ````
281
+
282
+ **Fix:**
283
+
284
+ ````markdown
285
+ ```bash
286
+ code here
287
+ ```
288
+ ````
289
+
290
+ ## Special Cases
291
+
292
+ ### CLAUDE.md Files
293
+
294
+ CLAUDE.md files are AI assistant documentation:
295
+
296
+ - Must be well-formatted for optimal parsing by AI
297
+ - Follow all markdownlint rules strictly
298
+ - Use clear, hierarchical structure
299
+ - Include table of contents for long files
300
+
301
+ ### README Files
302
+
303
+ - Start with H1 title
304
+ - Include brief description
305
+ - Add installation/usage sections
306
+ - Keep concise and scannable
307
+
308
+ ### Changelog Files
309
+
310
+ - Follow Keep a Changelog format
311
+ - Use consistent date formatting
312
+ - Group changes by type (Added, Changed, Fixed, etc.)
313
+
314
+ ## Troubleshooting
315
+
316
+ ### File Shows as "data" Instead of Text
317
+
318
+ **Problem:** File is corrupted with control characters
319
+
320
+ **Fix:**
321
+
322
+ ```bash
323
+ tr -d '\000-\037' < file.md > file.clean.md && mv file.clean.md file.md
324
+ file file.md # Verify shows "UTF-8 text"
325
+ ```
326
+
327
+ ### Linting Shows Unexpected Errors
328
+
329
+ **Problem:** Not running from repository root
330
+
331
+ **Fix:**
332
+
333
+ ```bash
334
+ # Always run from root
335
+ cd /path/to/woocommerce
336
+ markdownlint path/to/file.md
337
+
338
+ # NOT like this
339
+ markdownlint /absolute/path/to/file.md
340
+ ```
341
+
342
+ ### Auto-fix Doesn't Work
343
+
344
+ **Problem:** Some issues require manual intervention
345
+
346
+ **Fix:**
347
+
348
+ - Language specs for code blocks must be added manually
349
+ - Long lines may need manual rewrapping
350
+ - Some structural issues require content reorganization
351
+
352
+ ## Notes
353
+
354
+ - Most markdown issues are auto-fixable with `markdownlint --fix`
355
+ - Always run markdownlint from repository root
356
+ - UTF-8 encoding is critical for special characters
357
+ - CLAUDE.md files must pass linting for optimal AI parsing
358
+ - See `woocommerce-dev-cycle` skill for markdown linting commands
@@ -0,0 +1,202 @@
1
+ # Markdown Linting
2
+
3
+ ## Table of Contents
4
+
5
+ - [Critical Rule](#critical-rule)
6
+ - [Installation](#installation)
7
+ - [Basic Commands](#basic-commands)
8
+ - [Important: Always Run from Repository Root](#important-always-run-from-repository-root)
9
+ - [Recommended Workflow](#recommended-workflow)
10
+ - [Common Markdown Linting Issues](#common-markdown-linting-issues)
11
+ - [Character Encoding in Markdown Files](#character-encoding-in-markdown-files)
12
+ - [Examples](#examples)
13
+ - [Notes](#notes)
14
+
15
+ ## Critical Rule
16
+
17
+ **ALWAYS lint markdown files after changes.** They must pass markdownlint validation.
18
+
19
+ ## Installation
20
+
21
+ If markdownlint is not available:
22
+
23
+ ```bash
24
+ npm install -g markdownlint-cli
25
+ ```
26
+
27
+ ## Basic Commands
28
+
29
+ ```bash
30
+ # Check markdown file (run from repo root)
31
+ markdownlint plugins/woocommerce/CLAUDE.md
32
+
33
+ # RECOMMENDED: Auto-fix issues first (handles most errors)
34
+ markdownlint --fix plugins/woocommerce/CLAUDE.md
35
+
36
+ # Check multiple files
37
+ markdownlint packages/js/CLAUDE.md plugins/woocommerce/CLAUDE.md
38
+
39
+ # Lint all CLAUDE.md files
40
+ markdownlint packages/js/CLAUDE.md plugins/woocommerce/CLAUDE.md \
41
+ plugins/woocommerce/client/admin/CLAUDE.md
42
+ ```
43
+
44
+ ## Important: Always Run from Repository Root
45
+
46
+ **CRITICAL:** Always run markdownlint from the repository root so the `.markdownlint.json` config file is loaded.
47
+
48
+ Using absolute paths bypasses the config and may show incorrect errors.
49
+
50
+ ```bash
51
+ # ✅ CORRECT - run from repo root
52
+ cd /path/to/woocommerce
53
+ markdownlint plugins/woocommerce/CLAUDE.md
54
+
55
+ # ❌ WRONG - bypasses config
56
+ markdownlint /absolute/path/to/plugins/woocommerce/CLAUDE.md
57
+ ```
58
+
59
+ ## Recommended Workflow
60
+
61
+ 1. Make markdown changes
62
+ 2. Run `markdownlint --fix path/to/file.md` (auto-fixes most issues)
63
+ 3. Check remaining: `markdownlint path/to/file.md`
64
+ 4. Manually fix what remains (language specs, long lines)
65
+ 5. Verify clean, then commit
66
+
67
+ ## Common Markdown Linting Issues
68
+
69
+ | Code | Issue | Description | Fix |
70
+ |------|-------|-------------|-----|
71
+ | **MD007** | List indentation | Wrong indentation level | Use 4 spaces for nested items |
72
+ | **MD013** | Line length limit | Line exceeds 80 chars | Break into multiple lines |
73
+ | **MD031** | Code blocks need blank lines | Missing blank lines | Add blank above/below code blocks |
74
+ | **MD032** | Lists need blank lines | Missing blank lines | Add blank before/after lists |
75
+ | **MD036** | Emphasis as heading | Using bold instead of heading | Use `###` not bold |
76
+ | **MD040** | Code needs language | Missing language spec | Add: \`\`\`bash, \`\`\`php, etc. |
77
+ | **MD047** | Need trailing newline | File doesn't end with newline | File must end with newline |
78
+
79
+ ## Character Encoding in Markdown Files
80
+
81
+ ### Critical: Use Proper UTF-8 Characters
82
+
83
+ **NEVER allow control characters or null bytes into markdown files.**
84
+
85
+ ### Directory Trees
86
+
87
+ Use UTF-8 box-drawing characters, not spaces, tabs, or ASCII art:
88
+
89
+ ```markdown
90
+ ✅ CORRECT - UTF-8 box-drawing:
91
+ .ai/skills/
92
+ ├── woocommerce-backend/
93
+ │ ├── SKILL.md
94
+ │ └── file-entities.md
95
+ └── woocommerce-dev-cycle/
96
+ └── SKILL.md
97
+
98
+ ❌ WRONG - ASCII art or spaces:
99
+ .ai/skills/
100
+ +-- woocommerce-backend/
101
+ | +-- SKILL.md
102
+ +-- file-entities.md
103
+ ```
104
+
105
+ ### Avoiding File Corruption
106
+
107
+ **NEVER use Edit tool after `markdownlint --fix`** if the file contains directory trees.
108
+
109
+ **Always check file encoding first:**
110
+
111
+ ```bash
112
+ file path/to/file.md
113
+ # Should show: "UTF-8 text" or "ASCII text"
114
+ # NEVER: "data"
115
+ ```
116
+
117
+ ### Fixing Corrupted Files
118
+
119
+ If a file becomes corrupted (shows as "data" instead of text):
120
+
121
+ ```bash
122
+ # Remove control characters and null bytes
123
+ tr -d '\000-\037' < file.md > file.clean.md && mv file.clean.md file.md
124
+
125
+ # Verify encoding after fix
126
+ file file.md
127
+ ```
128
+
129
+ ## Examples
130
+
131
+ ### Adding Language Specs to Code Blocks
132
+
133
+ **Before:**
134
+
135
+ ````markdown
136
+ ```
137
+ pnpm test:php:env
138
+ ```
139
+ ````
140
+
141
+ **After:**
142
+
143
+ ````markdown
144
+ ```bash
145
+ pnpm test:php:env
146
+ ```
147
+ ````
148
+
149
+ Common language specs:
150
+
151
+ - `bash` - Shell commands
152
+ - `php` - PHP code
153
+ - `javascript` or `js` - JavaScript
154
+ - `typescript` or `ts` - TypeScript
155
+ - `json` - JSON data
156
+ - `markdown` or `md` - Markdown examples
157
+
158
+ ### Breaking Long Lines
159
+
160
+ **Before:**
161
+
162
+ ```markdown
163
+ This is a very long line that exceeds the 80 character limit and needs to be broken into multiple lines for better readability.
164
+ ```
165
+
166
+ **After:**
167
+
168
+ ```markdown
169
+ This is a very long line that exceeds the 80 character limit and needs to be
170
+ broken into multiple lines for better readability.
171
+ ```
172
+
173
+ ### Blank Lines Around Code Blocks
174
+
175
+ **Before:**
176
+
177
+ ````markdown
178
+ Some text here
179
+ ```bash
180
+ command here
181
+ ```
182
+ More text
183
+ ````
184
+
185
+ **After:**
186
+
187
+ ````markdown
188
+ Some text here
189
+
190
+ ```bash
191
+ command here
192
+ ```
193
+
194
+ More text
195
+ ````
196
+
197
+ ## Notes
198
+
199
+ - `markdownlint --fix` automatically handles most issues
200
+ - CLAUDE.md files are AI assistant documentation and must be well-formatted for optimal parsing
201
+ - Only a few issues require manual fixing (language specs, long lines)
202
+ - Always verify encoding after edits to prevent corruption
@@ -0,0 +1,83 @@
1
+ # PHP i18n Patterns for WooCommerce
2
+
3
+ This guide covers internationalization (i18n) standards for WooCommerce backend PHP development.
4
+
5
+ ## Core Functions
6
+
7
+ ### Basic Translation
8
+
9
+ Always use the `woocommerce` text domain for WooCommerce-related strings.
10
+
11
+ ```php
12
+ // Simple string
13
+ __( 'Save changes', 'woocommerce' );
14
+
15
+ // Echoed string
16
+ _e( 'Order details', 'woocommerce' );
17
+ ```
18
+
19
+ ### Contextual Translation
20
+
21
+ Use `_x` when a word has multiple meanings and needs context for translators.
22
+
23
+ ```php
24
+ _x( 'Post', 'verb', 'woocommerce' );
25
+ _x( 'Post', 'noun', 'woocommerce' );
26
+ ```
27
+
28
+ ### Pluralization
29
+
30
+ ```php
31
+ printf(
32
+ _n( '%d item', '%d items', $count, 'woocommerce' ),
33
+ $count
34
+ );
35
+ ```
36
+
37
+ ### Strings with Placeholders
38
+
39
+ Use `printf` or `sprintf` with `__()`. **Never** use variables directly inside translation functions.
40
+
41
+ ```php
42
+ // ✅ CORRECT
43
+ printf(
44
+ /* translators: %s: customer name */
45
+ __( 'Hello %s', 'woocommerce' ),
46
+ $customer_name
47
+ );
48
+
49
+ // ❌ WRONG
50
+ __( "Hello $customer_name", 'woocommerce' );
51
+ ```
52
+
53
+ ## Translator Comments
54
+
55
+ Always provide context for placeholders. The comment must be immediately above the line with the translation function.
56
+
57
+ ```php
58
+ /* translators: 1: product name 2: category name */
59
+ $message = sprintf( __( '%1$s in %2$s', 'woocommerce' ), $product_name, $category_name );
60
+ ```
61
+
62
+ ## Brand Names
63
+
64
+ Brand names like "WooCommerce" or "WooPayments" should often be treated as constants or placeholders if they are used frequently, but in many cases, they are kept in the string if they shouldn't be translated.
65
+
66
+ ```php
67
+ sprintf(
68
+ /* translators: %s: product name */
69
+ __( 'Buy %s on WooCommerce', 'woocommerce' ),
70
+ $product_name
71
+ );
72
+ ```
73
+
74
+ ## Best Practices
75
+
76
+ 1. **No HTML in strings**: Keep HTML outside of translatable strings when possible to avoid translation breakage.
77
+ 2. **Full Sentences**: Don't break sentences into multiple translation calls. Translators need the full context.
78
+ 3. **Escaping**: Always escape translated strings that are being output to the browser.
79
+ ```php
80
+ echo esc_html__( 'Text', 'woocommerce' );
81
+ echo esc_attr__( 'Title', 'woocommerce' );
82
+ ```
83
+ 4. **Text Domain**: Ensure you use the correct text domain. If building a plugin, use your plugin's text domain.