@h1dr0n/skill-pool 0.1.0

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 (189) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +296 -0
  3. package/bin/cli.js +157 -0
  4. package/package.json +41 -0
  5. package/skills/api/agents/backend-specialist.md +69 -0
  6. package/skills/api/agents/database-optimizer.md +176 -0
  7. package/skills/api/manifest.yaml +20 -0
  8. package/skills/api/rules/auth-security.md +45 -0
  9. package/skills/api/skills/api-patterns/SKILL.md +81 -0
  10. package/skills/api/skills/api-patterns/api-style.md +42 -0
  11. package/skills/api/skills/api-patterns/auth.md +24 -0
  12. package/skills/api/skills/api-patterns/documentation.md +26 -0
  13. package/skills/api/skills/api-patterns/graphql.md +41 -0
  14. package/skills/api/skills/api-patterns/rate-limiting.md +31 -0
  15. package/skills/api/skills/api-patterns/response.md +37 -0
  16. package/skills/api/skills/api-patterns/rest.md +40 -0
  17. package/skills/api/skills/api-patterns/scripts/api_validator.py +211 -0
  18. package/skills/api/skills/api-patterns/security-testing.md +122 -0
  19. package/skills/api/skills/api-patterns/trpc.md +41 -0
  20. package/skills/api/skills/api-patterns/versioning.md +22 -0
  21. package/skills/api/skills/database-patterns.md +126 -0
  22. package/skills/api/skills/deployment-patterns.md +105 -0
  23. package/skills/api/skills/docker-patterns.md +135 -0
  24. package/skills/common/agents/code-reviewer.md +78 -0
  25. package/skills/common/agents/planner.md +80 -0
  26. package/skills/common/agents/security-reviewer.md +82 -0
  27. package/skills/common/agents/software-architect.md +81 -0
  28. package/skills/common/manifest.yaml +25 -0
  29. package/skills/common/rules/coding-style.md +39 -0
  30. package/skills/common/rules/git-workflow.md +33 -0
  31. package/skills/common/rules/security.md +25 -0
  32. package/skills/common/skills/architecture/SKILL.md +55 -0
  33. package/skills/common/skills/architecture/context-discovery.md +43 -0
  34. package/skills/common/skills/architecture/examples.md +94 -0
  35. package/skills/common/skills/architecture/pattern-selection.md +68 -0
  36. package/skills/common/skills/architecture/patterns-reference.md +50 -0
  37. package/skills/common/skills/architecture/trade-off-analysis.md +77 -0
  38. package/skills/common/skills/brainstorming/SKILL.md +163 -0
  39. package/skills/common/skills/brainstorming/dynamic-questioning.md +350 -0
  40. package/skills/common/skills/clean-code.md +99 -0
  41. package/skills/common/skills/code-review-checklist.md +86 -0
  42. package/skills/common/skills/plan-writing/SKILL.md +152 -0
  43. package/skills/common/skills/skill-feedback.md +94 -0
  44. package/skills/common/skills/tdd-workflow.md +130 -0
  45. package/skills/common/skills/verification-loop.md +112 -0
  46. package/skills/cpp/agents/cpp-build-resolver.md +90 -0
  47. package/skills/cpp/agents/cpp-reviewer.md +72 -0
  48. package/skills/cpp/manifest.yaml +15 -0
  49. package/skills/cpp/skills/cpp-coding-standards.md +722 -0
  50. package/skills/cpp/skills/cpp-testing.md +323 -0
  51. package/skills/devops/agents/devops-automator.md +376 -0
  52. package/skills/devops/agents/sre.md +90 -0
  53. package/skills/devops/manifest.yaml +20 -0
  54. package/skills/devops/skills/deployment-patterns.md +427 -0
  55. package/skills/devops/skills/deployment-procedures/SKILL.md +241 -0
  56. package/skills/devops/skills/docker-patterns.md +364 -0
  57. package/skills/devops/skills/e2e-testing.md +326 -0
  58. package/skills/devops/skills/github-ops.md +144 -0
  59. package/skills/django/manifest.yaml +16 -0
  60. package/skills/django/skills/django-patterns.md +734 -0
  61. package/skills/django/skills/django-security.md +593 -0
  62. package/skills/django/skills/django-tdd.md +729 -0
  63. package/skills/django/skills/django-verification.md +469 -0
  64. package/skills/dotnet/agents/csharp-reviewer.md +101 -0
  65. package/skills/dotnet/manifest.yaml +14 -0
  66. package/skills/dotnet/skills/csharp-testing.md +321 -0
  67. package/skills/dotnet/skills/dotnet-patterns.md +321 -0
  68. package/skills/go/agents/code-reviewer.md +76 -0
  69. package/skills/go/agents/go-build-resolver.md +94 -0
  70. package/skills/go/agents/go-reviewer.md +76 -0
  71. package/skills/go/manifest.yaml +17 -0
  72. package/skills/go/rules/go-style.md +55 -0
  73. package/skills/go/skills/golang-patterns.md +674 -0
  74. package/skills/go/skills/golang-testing.md +720 -0
  75. package/skills/java/agents/java-build-resolver.md +153 -0
  76. package/skills/java/agents/java-reviewer.md +92 -0
  77. package/skills/java/manifest.yaml +18 -0
  78. package/skills/java/skills/java-coding-standards.md +147 -0
  79. package/skills/java/skills/jpa-patterns.md +151 -0
  80. package/skills/java/skills/springboot-patterns.md +314 -0
  81. package/skills/java/skills/springboot-security.md +272 -0
  82. package/skills/kotlin/agents/kotlin-build-resolver.md +118 -0
  83. package/skills/kotlin/agents/kotlin-reviewer.md +159 -0
  84. package/skills/kotlin/manifest.yaml +17 -0
  85. package/skills/kotlin/skills/kotlin-coroutines-flows.md +284 -0
  86. package/skills/kotlin/skills/kotlin-patterns.md +711 -0
  87. package/skills/kotlin/skills/kotlin-testing.md +824 -0
  88. package/skills/laravel/manifest.yaml +15 -0
  89. package/skills/laravel/skills/laravel-patterns.md +409 -0
  90. package/skills/laravel/skills/laravel-security.md +279 -0
  91. package/skills/laravel/skills/laravel-tdd.md +277 -0
  92. package/skills/laravel/skills/laravel-verification.md +173 -0
  93. package/skills/mobile/agents/dart-build-resolver.md +201 -0
  94. package/skills/mobile/agents/flutter-reviewer.md +243 -0
  95. package/skills/mobile/manifest.yaml +19 -0
  96. package/skills/mobile/skills/android-clean-architecture.md +339 -0
  97. package/skills/mobile/skills/dart-flutter-patterns.md +563 -0
  98. package/skills/mobile/skills/swiftui-patterns.md +259 -0
  99. package/skills/nestjs/manifest.yaml +13 -0
  100. package/skills/nestjs/skills/nestjs-patterns.md +230 -0
  101. package/skills/perl/manifest.yaml +13 -0
  102. package/skills/perl/skills/perl-patterns.md +504 -0
  103. package/skills/perl/skills/perl-security.md +503 -0
  104. package/skills/perl/skills/perl-testing.md +475 -0
  105. package/skills/python/agents/python-reviewer.md +98 -0
  106. package/skills/python/manifest.yaml +18 -0
  107. package/skills/python/rules/python-style.md +69 -0
  108. package/skills/python/skills/python-patterns/SKILL.md +441 -0
  109. package/skills/python/skills/python-patterns.md +90 -0
  110. package/skills/python/skills/python-testing.md +81 -0
  111. package/skills/rust/agents/rust-build-resolver.md +148 -0
  112. package/skills/rust/agents/rust-reviewer.md +94 -0
  113. package/skills/rust/manifest.yaml +16 -0
  114. package/skills/rust/rules/rust-style.md +107 -0
  115. package/skills/rust/skills/rust-patterns.md +499 -0
  116. package/skills/rust/skills/rust-testing.md +500 -0
  117. package/skills/security/agents/accessibility-auditor.md +316 -0
  118. package/skills/security/agents/security-reviewer.md +108 -0
  119. package/skills/security/manifest.yaml +19 -0
  120. package/skills/security/skills/red-team-tactics/SKILL.md +199 -0
  121. package/skills/security/skills/security-bounty-hunter.md +99 -0
  122. package/skills/security/skills/security-review.md +495 -0
  123. package/skills/security/skills/security-scan.md +165 -0
  124. package/skills/security/skills/vulnerability-scanner/SKILL.md +276 -0
  125. package/skills/security/skills/vulnerability-scanner/checklists.md +121 -0
  126. package/skills/security/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
  127. package/skills/swift/manifest.yaml +16 -0
  128. package/skills/swift/skills/swift-actor-persistence.md +142 -0
  129. package/skills/swift/skills/swift-concurrency.md +216 -0
  130. package/skills/swift/skills/swift-protocol-di-testing.md +190 -0
  131. package/skills/swift/skills/swiftui-patterns.md +259 -0
  132. package/skills/unity/agents/game-designer.md +167 -0
  133. package/skills/unity/agents/unity-architect.md +52 -0
  134. package/skills/unity/agents/unity-editor-tool-developer.md +310 -0
  135. package/skills/unity/agents/unity-multiplayer-engineer.md +321 -0
  136. package/skills/unity/agents/unity-shader-graph-artist.md +269 -0
  137. package/skills/unity/manifest.yaml +21 -0
  138. package/skills/unity/rules/csharp-patterns.md +48 -0
  139. package/skills/unity/rules/unity-specific.md +53 -0
  140. package/skills/unity/skills/systematic-debugging.md +92 -0
  141. package/skills/unity/skills/unity-architecture.md +173 -0
  142. package/skills/unreal/agents/level-designer.md +208 -0
  143. package/skills/unreal/agents/technical-artist.md +229 -0
  144. package/skills/unreal/agents/unreal-multiplayer-architect.md +313 -0
  145. package/skills/unreal/agents/unreal-systems-engineer.md +310 -0
  146. package/skills/unreal/agents/unreal-technical-artist.md +256 -0
  147. package/skills/unreal/agents/unreal-world-builder.md +273 -0
  148. package/skills/unreal/manifest.yaml +21 -0
  149. package/skills/unreal/skills/unreal-patterns.md +183 -0
  150. package/skills/web/agents/frontend-specialist.md +71 -0
  151. package/skills/web/agents/ui-designer.md +383 -0
  152. package/skills/web/agents/ux-architect.md +469 -0
  153. package/skills/web/manifest.yaml +22 -0
  154. package/skills/web/rules/accessibility.md +54 -0
  155. package/skills/web/rules/css-performance.md +52 -0
  156. package/skills/web/skills/e2e-testing.md +132 -0
  157. package/skills/web/skills/frontend-design/SKILL.md +452 -0
  158. package/skills/web/skills/frontend-design/animation-guide.md +331 -0
  159. package/skills/web/skills/frontend-design/color-system.md +311 -0
  160. package/skills/web/skills/frontend-design/decision-trees.md +418 -0
  161. package/skills/web/skills/frontend-design/motion-graphics.md +306 -0
  162. package/skills/web/skills/frontend-design/scripts/accessibility_checker.py +183 -0
  163. package/skills/web/skills/frontend-design/scripts/ux_audit.py +722 -0
  164. package/skills/web/skills/frontend-design/typography-system.md +345 -0
  165. package/skills/web/skills/frontend-design/ux-psychology.md +1116 -0
  166. package/skills/web/skills/frontend-design/visual-effects.md +383 -0
  167. package/skills/web/skills/react-nextjs.md +135 -0
  168. package/skills/web/skills/tailwind-patterns/SKILL.md +269 -0
  169. package/src/adapters/antigravity.js +164 -0
  170. package/src/adapters/claude.js +188 -0
  171. package/src/adapters/cursor.js +161 -0
  172. package/src/adapters/index.js +67 -0
  173. package/src/adapters/windsurf.js +158 -0
  174. package/src/commands/add.js +266 -0
  175. package/src/commands/create.js +127 -0
  176. package/src/commands/diff.js +78 -0
  177. package/src/commands/info.js +88 -0
  178. package/src/commands/init.js +224 -0
  179. package/src/commands/install.js +90 -0
  180. package/src/commands/list.js +54 -0
  181. package/src/commands/remove.js +101 -0
  182. package/src/commands/targets.js +32 -0
  183. package/src/commands/update.js +57 -0
  184. package/src/core/manifest.js +57 -0
  185. package/src/core/plugins.js +86 -0
  186. package/src/core/resolver.js +84 -0
  187. package/src/core/tracker.js +49 -0
  188. package/src/utils/fs.js +80 -0
  189. package/src/utils/git.js +52 -0
@@ -0,0 +1,475 @@
1
+ ---
2
+ name: perl-testing
3
+ description: Perl testing patterns using Test2::V0, Test::More, prove runner, mocking, coverage with Devel::Cover, and TDD methodology.
4
+ origin: ECC
5
+ ---
6
+
7
+ # Perl Testing Patterns
8
+
9
+ Comprehensive testing strategies for Perl applications using Test2::V0, Test::More, prove, and TDD methodology.
10
+
11
+ ## When to Activate
12
+
13
+ - Writing new Perl code (follow TDD: red, green, refactor)
14
+ - Designing test suites for Perl modules or applications
15
+ - Reviewing Perl test coverage
16
+ - Setting up Perl testing infrastructure
17
+ - Migrating tests from Test::More to Test2::V0
18
+ - Debugging failing Perl tests
19
+
20
+ ## TDD Workflow
21
+
22
+ Always follow the RED-GREEN-REFACTOR cycle.
23
+
24
+ ```perl
25
+ # Step 1: RED — Write a failing test
26
+ # t/unit/calculator.t
27
+ use v5.36;
28
+ use Test2::V0;
29
+
30
+ use lib 'lib';
31
+ use Calculator;
32
+
33
+ subtest 'addition' => sub {
34
+ my $calc = Calculator->new;
35
+ is($calc->add(2, 3), 5, 'adds two numbers');
36
+ is($calc->add(-1, 1), 0, 'handles negatives');
37
+ };
38
+
39
+ done_testing;
40
+
41
+ # Step 2: GREEN — Write minimal implementation
42
+ # lib/Calculator.pm
43
+ package Calculator;
44
+ use v5.36;
45
+ use Moo;
46
+
47
+ sub add($self, $a, $b) {
48
+ return $a + $b;
49
+ }
50
+
51
+ 1;
52
+
53
+ # Step 3: REFACTOR — Improve while tests stay green
54
+ # Run: prove -lv t/unit/calculator.t
55
+ ```
56
+
57
+ ## Test::More Fundamentals
58
+
59
+ The standard Perl testing module — widely used, ships with core.
60
+
61
+ ### Basic Assertions
62
+
63
+ ```perl
64
+ use v5.36;
65
+ use Test::More;
66
+
67
+ # Plan upfront or use done_testing
68
+ # plan tests => 5; # Fixed plan (optional)
69
+
70
+ # Equality
71
+ is($result, 42, 'returns correct value');
72
+ isnt($result, 0, 'not zero');
73
+
74
+ # Boolean
75
+ ok($user->is_active, 'user is active');
76
+ ok(!$user->is_banned, 'user is not banned');
77
+
78
+ # Deep comparison
79
+ is_deeply(
80
+ $got,
81
+ { name => 'Alice', roles => ['admin'] },
82
+ 'returns expected structure'
83
+ );
84
+
85
+ # Pattern matching
86
+ like($error, qr/not found/i, 'error mentions not found');
87
+ unlike($output, qr/password/, 'output hides password');
88
+
89
+ # Type check
90
+ isa_ok($obj, 'MyApp::User');
91
+ can_ok($obj, 'save', 'delete');
92
+
93
+ done_testing;
94
+ ```
95
+
96
+ ### SKIP and TODO
97
+
98
+ ```perl
99
+ use v5.36;
100
+ use Test::More;
101
+
102
+ # Skip tests conditionally
103
+ SKIP: {
104
+ skip 'No database configured', 2 unless $ENV{TEST_DB};
105
+
106
+ my $db = connect_db();
107
+ ok($db->ping, 'database is reachable');
108
+ is($db->version, '15', 'correct PostgreSQL version');
109
+ }
110
+
111
+ # Mark expected failures
112
+ TODO: {
113
+ local $TODO = 'Caching not yet implemented';
114
+ is($cache->get('key'), 'value', 'cache returns value');
115
+ }
116
+
117
+ done_testing;
118
+ ```
119
+
120
+ ## Test2::V0 Modern Framework
121
+
122
+ Test2::V0 is the modern replacement for Test::More — richer assertions, better diagnostics, and extensible.
123
+
124
+ ### Why Test2?
125
+
126
+ - Superior deep comparison with hash/array builders
127
+ - Better diagnostic output on failures
128
+ - Subtests with cleaner scoping
129
+ - Extensible via Test2::Tools::* plugins
130
+ - Backward-compatible with Test::More tests
131
+
132
+ ### Deep Comparison with Builders
133
+
134
+ ```perl
135
+ use v5.36;
136
+ use Test2::V0;
137
+
138
+ # Hash builder — check partial structure
139
+ is(
140
+ $user->to_hash,
141
+ hash {
142
+ field name => 'Alice';
143
+ field email => match(qr/\@example\.com$/);
144
+ field age => validator(sub { $_ >= 18 });
145
+ # Ignore other fields
146
+ etc();
147
+ },
148
+ 'user has expected fields'
149
+ );
150
+
151
+ # Array builder
152
+ is(
153
+ $result,
154
+ array {
155
+ item 'first';
156
+ item match(qr/^second/);
157
+ item DNE(); # Does Not Exist — verify no extra items
158
+ },
159
+ 'result matches expected list'
160
+ );
161
+
162
+ # Bag — order-independent comparison
163
+ is(
164
+ $tags,
165
+ bag {
166
+ item 'perl';
167
+ item 'testing';
168
+ item 'tdd';
169
+ },
170
+ 'has all required tags regardless of order'
171
+ );
172
+ ```
173
+
174
+ ### Subtests
175
+
176
+ ```perl
177
+ use v5.36;
178
+ use Test2::V0;
179
+
180
+ subtest 'User creation' => sub {
181
+ my $user = User->new(name => 'Alice', email => 'alice@example.com');
182
+ ok($user, 'user object created');
183
+ is($user->name, 'Alice', 'name is set');
184
+ is($user->email, 'alice@example.com', 'email is set');
185
+ };
186
+
187
+ subtest 'User validation' => sub {
188
+ my $warnings = warns {
189
+ User->new(name => '', email => 'bad');
190
+ };
191
+ ok($warnings, 'warns on invalid data');
192
+ };
193
+
194
+ done_testing;
195
+ ```
196
+
197
+ ### Exception Testing with Test2
198
+
199
+ ```perl
200
+ use v5.36;
201
+ use Test2::V0;
202
+
203
+ # Test that code dies
204
+ like(
205
+ dies { divide(10, 0) },
206
+ qr/Division by zero/,
207
+ 'dies on division by zero'
208
+ );
209
+
210
+ # Test that code lives
211
+ ok(lives { divide(10, 2) }, 'division succeeds') or note($@);
212
+
213
+ # Combined pattern
214
+ subtest 'error handling' => sub {
215
+ ok(lives { parse_config('valid.json') }, 'valid config parses');
216
+ like(
217
+ dies { parse_config('missing.json') },
218
+ qr/Cannot open/,
219
+ 'missing file dies with message'
220
+ );
221
+ };
222
+
223
+ done_testing;
224
+ ```
225
+
226
+ ## Test Organization and prove
227
+
228
+ ### Directory Structure
229
+
230
+ ```text
231
+ t/
232
+ ├── 00-load.t # Verify modules compile
233
+ ├── 01-basic.t # Core functionality
234
+ ├── unit/
235
+ │ ├── config.t # Unit tests by module
236
+ │ ├── user.t
237
+ │ └── util.t
238
+ ├── integration/
239
+ │ ├── database.t
240
+ │ └── api.t
241
+ ├── lib/
242
+ │ └── TestHelper.pm # Shared test utilities
243
+ └── fixtures/
244
+ ├── config.json # Test data files
245
+ └── users.csv
246
+ ```
247
+
248
+ ### prove Commands
249
+
250
+ ```bash
251
+ # Run all tests
252
+ prove -l t/
253
+
254
+ # Verbose output
255
+ prove -lv t/
256
+
257
+ # Run specific test
258
+ prove -lv t/unit/user.t
259
+
260
+ # Recursive search
261
+ prove -lr t/
262
+
263
+ # Parallel execution (8 jobs)
264
+ prove -lr -j8 t/
265
+
266
+ # Run only failing tests from last run
267
+ prove -l --state=failed t/
268
+
269
+ # Colored output with timer
270
+ prove -l --color --timer t/
271
+
272
+ # TAP output for CI
273
+ prove -l --formatter TAP::Formatter::JUnit t/ > results.xml
274
+ ```
275
+
276
+ ### .proverc Configuration
277
+
278
+ ```text
279
+ -l
280
+ --color
281
+ --timer
282
+ -r
283
+ -j4
284
+ --state=save
285
+ ```
286
+
287
+ ## Fixtures and Setup/Teardown
288
+
289
+ ### Subtest Isolation
290
+
291
+ ```perl
292
+ use v5.36;
293
+ use Test2::V0;
294
+ use File::Temp qw(tempdir);
295
+ use Path::Tiny;
296
+
297
+ subtest 'file processing' => sub {
298
+ # Setup
299
+ my $dir = tempdir(CLEANUP => 1);
300
+ my $file = path($dir, 'input.txt');
301
+ $file->spew_utf8("line1\nline2\nline3\n");
302
+
303
+ # Test
304
+ my $result = process_file("$file");
305
+ is($result->{line_count}, 3, 'counts lines');
306
+
307
+ # Teardown happens automatically (CLEANUP => 1)
308
+ };
309
+ ```
310
+
311
+ ### Shared Test Helpers
312
+
313
+ Place reusable helpers in `t/lib/TestHelper.pm` and load with `use lib 't/lib'`. Export factory functions like `create_test_db()`, `create_temp_dir()`, and `fixture_path()` via `Exporter`.
314
+
315
+ ## Mocking
316
+
317
+ ### Test::MockModule
318
+
319
+ ```perl
320
+ use v5.36;
321
+ use Test2::V0;
322
+ use Test::MockModule;
323
+
324
+ subtest 'mock external API' => sub {
325
+ my $mock = Test::MockModule->new('MyApp::API');
326
+
327
+ # Good: Mock returns controlled data
328
+ $mock->mock(fetch_user => sub ($self, $id) {
329
+ return { id => $id, name => 'Mock User', email => 'mock@test.com' };
330
+ });
331
+
332
+ my $api = MyApp::API->new;
333
+ my $user = $api->fetch_user(42);
334
+ is($user->{name}, 'Mock User', 'returns mocked user');
335
+
336
+ # Verify call count
337
+ my $call_count = 0;
338
+ $mock->mock(fetch_user => sub { $call_count++; return {} });
339
+ $api->fetch_user(1);
340
+ $api->fetch_user(2);
341
+ is($call_count, 2, 'fetch_user called twice');
342
+
343
+ # Mock is automatically restored when $mock goes out of scope
344
+ };
345
+
346
+ # Bad: Monkey-patching without restoration
347
+ # *MyApp::API::fetch_user = sub { ... }; # NEVER — leaks across tests
348
+ ```
349
+
350
+ For lightweight mock objects, use `Test::MockObject` to create injectable test doubles with `->mock()` and verify calls with `->called_ok()`.
351
+
352
+ ## Coverage with Devel::Cover
353
+
354
+ ### Running Coverage
355
+
356
+ ```bash
357
+ # Basic coverage report
358
+ cover -test
359
+
360
+ # Or step by step
361
+ perl -MDevel::Cover -Ilib t/unit/user.t
362
+ cover
363
+
364
+ # HTML report
365
+ cover -report html
366
+ open cover_db/coverage.html
367
+
368
+ # Specific thresholds
369
+ cover -test -report text | grep 'Total'
370
+
371
+ # CI-friendly: fail under threshold
372
+ cover -test && cover -report text -select '^lib/' \
373
+ | perl -ne 'if (/Total.*?(\d+\.\d+)/) { exit 1 if $1 < 80 }'
374
+ ```
375
+
376
+ ### Integration Testing
377
+
378
+ Use in-memory SQLite for database tests, mock HTTP::Tiny for API tests.
379
+
380
+ ```perl
381
+ use v5.36;
382
+ use Test2::V0;
383
+ use DBI;
384
+
385
+ subtest 'database integration' => sub {
386
+ my $dbh = DBI->connect('dbi:SQLite:dbname=:memory:', '', '', {
387
+ RaiseError => 1,
388
+ });
389
+ $dbh->do('CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT)');
390
+
391
+ $dbh->prepare('INSERT INTO users (name) VALUES (?)')->execute('Alice');
392
+ my $row = $dbh->selectrow_hashref('SELECT * FROM users WHERE name = ?', undef, 'Alice');
393
+ is($row->{name}, 'Alice', 'inserted and retrieved user');
394
+ };
395
+
396
+ done_testing;
397
+ ```
398
+
399
+ ## Best Practices
400
+
401
+ ### DO
402
+
403
+ - **Follow TDD**: Write tests before implementation (red-green-refactor)
404
+ - **Use Test2::V0**: Modern assertions, better diagnostics
405
+ - **Use subtests**: Group related assertions, isolate state
406
+ - **Mock external dependencies**: Network, database, file system
407
+ - **Use `prove -l`**: Always include lib/ in `@INC`
408
+ - **Name tests clearly**: `'user login with invalid password fails'`
409
+ - **Test edge cases**: Empty strings, undef, zero, boundary values
410
+ - **Aim for 80%+ coverage**: Focus on business logic paths
411
+ - **Keep tests fast**: Mock I/O, use in-memory databases
412
+
413
+ ### DON'T
414
+
415
+ - **Don't test implementation**: Test behavior and output, not internals
416
+ - **Don't share state between subtests**: Each subtest should be independent
417
+ - **Don't skip `done_testing`**: Ensures all planned tests ran
418
+ - **Don't over-mock**: Mock boundaries only, not the code under test
419
+ - **Don't use `Test::More` for new projects**: Prefer Test2::V0
420
+ - **Don't ignore test failures**: All tests must pass before merge
421
+ - **Don't test CPAN modules**: Trust libraries to work correctly
422
+ - **Don't write brittle tests**: Avoid over-specific string matching
423
+
424
+ ## Quick Reference
425
+
426
+ | Task | Command / Pattern |
427
+ |---|---|
428
+ | Run all tests | `prove -lr t/` |
429
+ | Run one test verbose | `prove -lv t/unit/user.t` |
430
+ | Parallel test run | `prove -lr -j8 t/` |
431
+ | Coverage report | `cover -test && cover -report html` |
432
+ | Test equality | `is($got, $expected, 'label')` |
433
+ | Deep comparison | `is($got, hash { field k => 'v'; etc() }, 'label')` |
434
+ | Test exception | `like(dies { ... }, qr/msg/, 'label')` |
435
+ | Test no exception | `ok(lives { ... }, 'label')` |
436
+ | Mock a method | `Test::MockModule->new('Pkg')->mock(m => sub { ... })` |
437
+ | Skip tests | `SKIP: { skip 'reason', $count unless $cond; ... }` |
438
+ | TODO tests | `TODO: { local $TODO = 'reason'; ... }` |
439
+
440
+ ## Common Pitfalls
441
+
442
+ ### Forgetting `done_testing`
443
+
444
+ ```perl
445
+ # Bad: Test file runs but doesn't verify all tests executed
446
+ use Test2::V0;
447
+ is(1, 1, 'works');
448
+ # Missing done_testing — silent bugs if test code is skipped
449
+
450
+ # Good: Always end with done_testing
451
+ use Test2::V0;
452
+ is(1, 1, 'works');
453
+ done_testing;
454
+ ```
455
+
456
+ ### Missing `-l` Flag
457
+
458
+ ```bash
459
+ # Bad: Modules in lib/ not found
460
+ prove t/unit/user.t
461
+ # Can't locate MyApp/User.pm in @INC
462
+
463
+ # Good: Include lib/ in @INC
464
+ prove -l t/unit/user.t
465
+ ```
466
+
467
+ ### Over-Mocking
468
+
469
+ Mock the *dependency*, not the code under test. If your test only verifies that a mock returns what you told it to, it tests nothing.
470
+
471
+ ### Test Pollution
472
+
473
+ Use `my` variables inside subtests — never `our` — to prevent state leaking between tests.
474
+
475
+ **Remember**: Tests are your safety net. Keep them fast, focused, and independent. Use Test2::V0 for new projects, prove for running, and Devel::Cover for accountability.
@@ -0,0 +1,98 @@
1
+ ---
2
+ name: python-reviewer
3
+ description: Expert Python code reviewer specializing in PEP 8 compliance, Pythonic idioms, type hints, security, and performance. Use for all Python code changes. MUST BE USED for Python projects.
4
+ tools: ["Read", "Grep", "Glob", "Bash"]
5
+ model: sonnet
6
+ ---
7
+
8
+ You are a senior Python code reviewer ensuring high standards of Pythonic code and best practices.
9
+
10
+ When invoked:
11
+ 1. Run `git diff -- '*.py'` to see recent Python file changes
12
+ 2. Run static analysis tools if available (ruff, mypy, pylint, black --check)
13
+ 3. Focus on modified `.py` files
14
+ 4. Begin review immediately
15
+
16
+ ## Review Priorities
17
+
18
+ ### CRITICAL — Security
19
+ - **SQL Injection**: f-strings in queries — use parameterized queries
20
+ - **Command Injection**: unvalidated input in shell commands — use subprocess with list args
21
+ - **Path Traversal**: user-controlled paths — validate with normpath, reject `..`
22
+ - **Eval/exec abuse**, **unsafe deserialization**, **hardcoded secrets**
23
+ - **Weak crypto** (MD5/SHA1 for security), **YAML unsafe load**
24
+
25
+ ### CRITICAL — Error Handling
26
+ - **Bare except**: `except: pass` — catch specific exceptions
27
+ - **Swallowed exceptions**: silent failures — log and handle
28
+ - **Missing context managers**: manual file/resource management — use `with`
29
+
30
+ ### HIGH — Type Hints
31
+ - Public functions without type annotations
32
+ - Using `Any` when specific types are possible
33
+ - Missing `Optional` for nullable parameters
34
+
35
+ ### HIGH — Pythonic Patterns
36
+ - Use list comprehensions over C-style loops
37
+ - Use `isinstance()` not `type() ==`
38
+ - Use `Enum` not magic numbers
39
+ - Use `"".join()` not string concatenation in loops
40
+ - **Mutable default arguments**: `def f(x=[])` — use `def f(x=None)`
41
+
42
+ ### HIGH — Code Quality
43
+ - Functions > 50 lines, > 5 parameters (use dataclass)
44
+ - Deep nesting (> 4 levels)
45
+ - Duplicate code patterns
46
+ - Magic numbers without named constants
47
+
48
+ ### HIGH — Concurrency
49
+ - Shared state without locks — use `threading.Lock`
50
+ - Mixing sync/async incorrectly
51
+ - N+1 queries in loops — batch query
52
+
53
+ ### MEDIUM — Best Practices
54
+ - PEP 8: import order, naming, spacing
55
+ - Missing docstrings on public functions
56
+ - `print()` instead of `logging`
57
+ - `from module import *` — namespace pollution
58
+ - `value == None` — use `value is None`
59
+ - Shadowing builtins (`list`, `dict`, `str`)
60
+
61
+ ## Diagnostic Commands
62
+
63
+ ```bash
64
+ mypy . # Type checking
65
+ ruff check . # Fast linting
66
+ black --check . # Format check
67
+ bandit -r . # Security scan
68
+ pytest --cov=app --cov-report=term-missing # Test coverage
69
+ ```
70
+
71
+ ## Review Output Format
72
+
73
+ ```text
74
+ [SEVERITY] Issue title
75
+ File: path/to/file.py:42
76
+ Issue: Description
77
+ Fix: What to change
78
+ ```
79
+
80
+ ## Approval Criteria
81
+
82
+ - **Approve**: No CRITICAL or HIGH issues
83
+ - **Warning**: MEDIUM issues only (can merge with caution)
84
+ - **Block**: CRITICAL or HIGH issues found
85
+
86
+ ## Framework Checks
87
+
88
+ - **Django**: `select_related`/`prefetch_related` for N+1, `atomic()` for multi-step, migrations
89
+ - **FastAPI**: CORS config, Pydantic validation, response models, no blocking in async
90
+ - **Flask**: Proper error handlers, CSRF protection
91
+
92
+ ## Reference
93
+
94
+ For detailed Python patterns, security examples, and code samples, see skill: `python-patterns`.
95
+
96
+ ---
97
+
98
+ Review with the mindset: "Would this code pass review at a top Python shop or open-source project?"
@@ -0,0 +1,18 @@
1
+ name: python
2
+ version: 0.3.0
3
+ description: Python development - PEP 8, type hints, patterns, Django/FastAPI, testing, debugging
4
+ depends:
5
+ - common
6
+ tags:
7
+ - python
8
+ - django
9
+ - fastapi
10
+ - pytest
11
+ rules:
12
+ - rules/python-style.md
13
+ skills:
14
+ - skills/python-patterns.md
15
+ - skills/python-testing.md
16
+ - skills/python-patterns
17
+ agents:
18
+ - agents/python-reviewer.md
@@ -0,0 +1,69 @@
1
+ # Python Style
2
+
3
+ ## Standards
4
+
5
+ - Follow PEP 8 conventions
6
+ - Use type annotations on all function signatures
7
+ - Format with `black`, sort imports with `isort`, lint with `ruff`
8
+
9
+ ## Type Hints
10
+
11
+ ```python
12
+ def get_user(user_id: str) -> User | None:
13
+ ...
14
+
15
+ def process_items(items: list[str], *, limit: int = 10) -> dict[str, int]:
16
+ ...
17
+ ```
18
+
19
+ - Use `|` union syntax (Python 3.10+) over `Optional`/`Union`
20
+ - Use `from __future__ import annotations` for older versions
21
+ - Add return types to all public functions
22
+
23
+ ## Immutability
24
+
25
+ ```python
26
+ from dataclasses import dataclass
27
+
28
+ @dataclass(frozen=True)
29
+ class User:
30
+ name: str
31
+ email: str
32
+
33
+ from typing import NamedTuple
34
+
35
+ class Point(NamedTuple):
36
+ x: float
37
+ y: float
38
+ ```
39
+
40
+ - Prefer frozen dataclasses and NamedTuples
41
+ - Use tuples over lists for fixed collections
42
+ - Avoid mutating function arguments
43
+
44
+ ## Error Handling
45
+
46
+ ```python
47
+ # Specific exceptions, not bare except
48
+ try:
49
+ result = risky_operation()
50
+ except ValueError as e:
51
+ logger.error("Invalid value: %s", e)
52
+ raise
53
+ except Exception:
54
+ logger.exception("Unexpected error")
55
+ raise
56
+ ```
57
+
58
+ - Never use bare `except:`
59
+ - Catch specific exceptions
60
+ - Use `raise` to re-raise, `raise X from Y` for chaining
61
+ - Use custom exceptions for domain errors
62
+
63
+ ## Naming
64
+
65
+ - `snake_case` for functions, variables, modules
66
+ - `PascalCase` for classes
67
+ - `UPPER_SNAKE_CASE` for constants
68
+ - `_private` prefix for internal use
69
+ - Avoid single-letter names except in comprehensions