@workingpayload/agent-skills 1.0.1 → 2.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 (130) hide show
  1. package/APIForge/skill.md +165 -0
  2. package/AccessPlus/skill.md +136 -0
  3. package/AlgoMaster/skill.md +125 -0
  4. package/Architekt AI/skill.md +140 -0
  5. package/AuthCraft/skill.md +144 -0
  6. package/AutoScriptor/skill.md +137 -0
  7. package/BoilerCore/skill.md +136 -0
  8. package/BugHunter Pro/skill.md +133 -0
  9. package/ChangeScribe/skill.md +113 -0
  10. package/CodeMap/skill.md +194 -0
  11. package/CodeSage/skill.md +163 -0
  12. package/CommitCraft/skill.md +113 -0
  13. package/CoverageMax/skill.md +161 -0
  14. package/CronGenius/skill.md +157 -0
  15. package/DataPolish/skill.md +142 -0
  16. package/DataWeaver/skill.md +151 -0
  17. package/DockMaster/skill.md +158 -0
  18. package/DocuGenie/skill.md +138 -0
  19. package/EdgeGuard/skill.md +160 -0
  20. package/EnvWizard/skill.md +156 -0
  21. package/ErrorMedic/skill.md +152 -0
  22. package/FeatureSmith/skill.md +139 -0
  23. package/FlexiLayout/skill.md +144 -0
  24. package/FlowTester/skill.md +154 -0
  25. package/FunctionForge/skill.md +136 -0
  26. package/InputShield/skill.md +144 -0
  27. package/IssueForge/skill.md +148 -0
  28. package/KubeCrafter/skill.md +149 -0
  29. package/LogicLens/skill.md +132 -0
  30. package/MockSmith/skill.md +146 -0
  31. package/ModelSensei/skill.md +138 -0
  32. package/PRMentor/skill.md +103 -0
  33. package/PerfDetective/skill.md +90 -0
  34. package/PipelinePro/skill.md +146 -0
  35. package/PolyglotShift/skill.md +94 -0
  36. package/PromptForge/skill.md +118 -0
  37. package/QueryPulse/skill.md +123 -0
  38. package/README.md +327 -216
  39. package/ReadMeCraft/skill.md +127 -0
  40. package/RefactorX/skill.md +110 -0
  41. package/RenderBoost/skill.md +148 -0
  42. package/SEOMancer/skill.md +156 -0
  43. package/ScrapeMaster/skill.md +157 -0
  44. package/SecretSniffer/skill.md +123 -0
  45. package/SecureScan/skill.md +130 -0
  46. package/ServiceSplitter/skill.md +153 -0
  47. package/SpeedSmith/skill.md +155 -0
  48. package/StackWise/skill.md +155 -0
  49. package/TaskOrchestrator/skill.md +135 -0
  50. package/TestCrafter/skill.md +158 -0
  51. package/TraceMind/skill.md +143 -0
  52. package/UISmith/skill.md +131 -0
  53. package/bin/cli.js +436 -0
  54. package/extension-extender/SKILL.md +122 -0
  55. package/fastapi-furious/SKILL.md +148 -0
  56. package/package.json +42 -32
  57. package/python-master/SKILL.md +108 -0
  58. package/react-ranger/SKILL.md +93 -0
  59. package/scripts/build_index.py +282 -0
  60. package/scripts/doctor.py +542 -0
  61. package/scripts/install.py +436 -0
  62. package/scripts/route.py +348 -0
  63. package/scripts/score.py +355 -0
  64. package/scripts/test_skill.py +501 -0
  65. package/scripts/validate.py +254 -0
  66. package/skills-routing.json +1156 -0
  67. package/skills.json +3389 -0
  68. package/cli.js +0 -181
  69. package/skills/APIForge/skill.md +0 -32
  70. package/skills/AccessPlus/skill.md +0 -32
  71. package/skills/AlgoMaster/skill.md +0 -32
  72. package/skills/Architekt AI/skill.md +0 -32
  73. package/skills/AuthCraft/skill.md +0 -32
  74. package/skills/AutoScriptor/skill.md +0 -32
  75. package/skills/BoilerCore/skill.md +0 -32
  76. package/skills/BugHunter Pro/skill.md +0 -32
  77. package/skills/ChangeScribe/skill.md +0 -32
  78. package/skills/CodeSage/skill.md +0 -32
  79. package/skills/CommitCraft/skill.md +0 -32
  80. package/skills/CoverageMax/skill.md +0 -32
  81. package/skills/CronGenius/skill.md +0 -32
  82. package/skills/DataPolish/skill.md +0 -32
  83. package/skills/DataWeaver/skill.md +0 -32
  84. package/skills/DockMaster/skill.md +0 -32
  85. package/skills/DocuGenie/skill.md +0 -32
  86. package/skills/EdgeGuard/skill.md +0 -32
  87. package/skills/EnvWizard/skill.md +0 -32
  88. package/skills/ErrorMedic/skill.md +0 -32
  89. package/skills/Extension-Extender/SKILL.md +0 -41
  90. package/skills/Extension-Extender/references/ui-guidelines.md +0 -26
  91. package/skills/Fastapi-Furious/README.md +0 -16
  92. package/skills/Fastapi-Furious/SKILL.md +0 -37
  93. package/skills/FeatureSmith/skill.md +0 -32
  94. package/skills/FlexiLayout/skill.md +0 -32
  95. package/skills/FlowTester/skill.md +0 -32
  96. package/skills/FunctionForge/skill.md +0 -32
  97. package/skills/InputShield/skill.md +0 -32
  98. package/skills/IssueForge/skill.md +0 -32
  99. package/skills/KubeCrafter/skill.md +0 -32
  100. package/skills/LogicLens/skill.md +0 -32
  101. package/skills/MockSmith/skill.md +0 -32
  102. package/skills/ModelSensei/skill.md +0 -32
  103. package/skills/PRMentor/skill.md +0 -32
  104. package/skills/PerfDetective/skill.md +0 -32
  105. package/skills/PipelinePro/skill.md +0 -32
  106. package/skills/PolyglotShift/skill.md +0 -32
  107. package/skills/PromptForge/skill.md +0 -32
  108. package/skills/Python-Master/README.md +0 -11
  109. package/skills/Python-Master/SKILL.md +0 -37
  110. package/skills/QueryPulse/skill.md +0 -32
  111. package/skills/React-Ranger/README.md +0 -17
  112. package/skills/React-Ranger/SKILL.md +0 -37
  113. package/skills/ReadMeCraft/skill.md +0 -32
  114. package/skills/RefactorX/skill.md +0 -32
  115. package/skills/RenderBoost/skill.md +0 -32
  116. package/skills/SEOMancer/skill.md +0 -32
  117. package/skills/ScrapeMaster/skill.md +0 -32
  118. package/skills/SecretSniffer/skill.md +0 -32
  119. package/skills/SecureScan/skill.md +0 -32
  120. package/skills/ServiceSplitter/skill.md +0 -32
  121. package/skills/SpeedSmith/skill.md +0 -32
  122. package/skills/StackWise/skill.md +0 -32
  123. package/skills/TaskOrchestrator/skill.md +0 -32
  124. package/skills/TestCrafter/skill.md +0 -32
  125. package/skills/TraceMind/skill.md +0 -32
  126. package/skills/UISmith/skill.md +0 -32
  127. /package/{skills/Extension-Extender → extension-extender}/assets/manifest.json +0 -0
  128. /package/{skills/Extension-Extender → extension-extender}/assets/popup.css +0 -0
  129. /package/{skills/Extension-Extender → extension-extender}/assets/popup.html +0 -0
  130. /package/{skills/Extension-Extender → extension-extender}/assets/popup.js +0 -0
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: mocksmith
3
+ description: Generates realistic, schema-driven mock data using Faker.js or factory_boy, stubs API responses with MSW, and produces edge-case datasets from OpenAPI specs or TypeScript interfaces. Use when a user needs test fixtures, factory functions, referentially consistent seed data, or browser/Node API mocking.
4
+ ---
5
+
6
+ # MockSmith
7
+
8
+ ## Overview
9
+
10
+ Produces deterministic, realistic mock data from OpenAPI specs or TypeScript/Python type definitions using Faker.js (JS/TS) or factory_boy (Python). Stubs HTTP APIs at the network layer using Mock Service Worker (MSW). Ensures referential integrity across related entities and covers edge-case data.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Derive the Schema First
15
+
16
+ Before generating any data, extract or confirm the schema from an OpenAPI spec (`components/schemas`), TypeScript interface, or user description. Never invent field names or types.
17
+
18
+ ### 2. Build Factory Functions (TypeScript / Faker.js)
19
+
20
+ ```typescript
21
+ // factories/user.factory.ts
22
+ import { faker } from '@faker-js/faker';
23
+
24
+ export function createUser(overrides: Partial<User> = {}): User {
25
+ return {
26
+ id: faker.string.uuid(),
27
+ email: faker.internet.email().toLowerCase(),
28
+ displayName: faker.person.fullName(),
29
+ role: faker.helpers.arrayElement(['admin', 'editor', 'viewer']),
30
+ createdAt: faker.date.past({ years: 2 }).toISOString(),
31
+ isActive: true,
32
+ ...overrides,
33
+ };
34
+ }
35
+
36
+ export const createUsers = (n: number, overrides: Partial<User> = {}) =>
37
+ Array.from({ length: n }, () => createUser(overrides));
38
+ ```
39
+
40
+ **Deterministic CI output:** `faker.seed(12345)` — same seed → same data every run.
41
+
42
+ **Per-worker seeding for parallel tests:** Seed with the worker ID so each worker produces unique but reproducible data:
43
+ ```typescript
44
+ faker.seed((Number(process.env.TEST_WORKER_INDEX) ?? 0) * 1000);
45
+ ```
46
+
47
+ ### 3. Build Factory Functions (Python / factory_boy)
48
+
49
+ ```python
50
+ class UserFactory(factory.django.DjangoModelFactory):
51
+ class Meta:
52
+ model = User
53
+ id = factory.LazyFunction(uuid.uuid4)
54
+ email = Faker('email')
55
+ display_name = Faker('name')
56
+ role = factory.Iterator(['admin', 'editor', 'viewer'])
57
+ is_active = True
58
+ # Usage: UserFactory(role='admin') | UserFactory.create_batch(10, is_active=False)
59
+ ```
60
+
61
+ ### 4. Maintain Referential Integrity
62
+
63
+ Use sub-factories — never generate orphaned foreign keys:
64
+ ```typescript
65
+ export function createOrder(overrides: Partial<Order> = {}): Order {
66
+ const user = overrides.user ?? createUser();
67
+ return { id: faker.string.uuid(), userId: user.id, user, status: 'pending', ...overrides };
68
+ }
69
+ ```
70
+
71
+ ### 5. Generate Edge-Case Data
72
+
73
+ ```typescript
74
+ export const edgeCaseUsers = {
75
+ emptyDisplayName: createUser({ displayName: '' }),
76
+ unicodeName: createUser({ displayName: '田中 太郎' }),
77
+ sqlInjection: createUser({ displayName: "'; DROP TABLE users; --" }),
78
+ xssPayload: createUser({ displayName: '<script>alert(1)</script>' }),
79
+ inactiveAdmin: createUser({ role: 'admin', isActive: false }),
80
+ };
81
+ ```
82
+
83
+ ### 6. Stub APIs with MSW
84
+
85
+ ```typescript
86
+ // mocks/handlers.ts
87
+ export const handlers = [
88
+ http.get('/api/users', ({ request }) => {
89
+ const count = Number(new URL(request.url).searchParams.get('limit') ?? 10);
90
+ return HttpResponse.json({ data: createUsers(count), total: 100 });
91
+ }),
92
+ http.get('/api/users/:id', ({ params }) =>
93
+ HttpResponse.json(createUser({ id: params.id as string }))
94
+ ),
95
+ http.post('/api/users', async ({ request }) =>
96
+ HttpResponse.json(createUser(await request.json() as Partial<User>), { status: 201 })
97
+ ),
98
+ ];
99
+ ```
100
+
101
+ **Timeout and network error simulation:**
102
+ ```typescript
103
+ import { delay } from 'msw';
104
+ http.get('/api/slow', async () => { await delay(3000); return HttpResponse.json({}); }),
105
+ http.get('/api/offline', () => HttpResponse.error()), // simulates network failure
106
+ ```
107
+
108
+ ```typescript
109
+ // mocks/server.ts
110
+ export const server = setupServer(...handlers);
111
+ beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
112
+ afterEach(() => server.resetHandlers());
113
+ afterAll(() => server.close());
114
+ ```
115
+
116
+ ### 7. Polymorphic Schema Factories (`oneOf` / `anyOf`)
117
+
118
+ When an OpenAPI schema uses `oneOf`/`anyOf`, generate a factory per variant and a union factory:
119
+ ```typescript
120
+ type Shape = Circle | Rectangle;
121
+ function createCircle(o: Partial<Circle> = {}): Circle {
122
+ return { type: 'circle', radius: faker.number.float({ min: 1, max: 100 }), ...o };
123
+ }
124
+ function createRectangle(o: Partial<Rectangle> = {}): Rectangle {
125
+ return { type: 'rectangle', width: faker.number.int({ min: 1, max: 200 }),
126
+ height: faker.number.int({ min: 1, max: 200 }), ...o };
127
+ }
128
+ const createShape = (): Shape =>
129
+ faker.helpers.arrayElement([createCircle, createRectangle])();
130
+ ```
131
+
132
+ ### 8. Generate from OpenAPI Spec
133
+
134
+ Parse `components/schemas`. Map types: `string/email` → `faker.internet.email()`, `string/uuid` → `faker.string.uuid()`, `string/date-time` → `faker.date.recent().toISOString()`. Respect `minimum`, `maximum`, `minLength`, `maxLength`, `enum`, `pattern`. Generate one factory per schema object.
135
+
136
+ ## Output Format
137
+
138
+ Deliver: factory files in `tests/factories/`, MSW `mocks/handlers.ts` and `mocks/server.ts`, edge-case fixtures export, and Vitest/Jest setup snippet.
139
+
140
+ ## Edge Cases
141
+
142
+ **Circular references:** Break cycles with a depth guard: `manager: depth < 2 ? createUser({}, depth + 1) : null`.
143
+
144
+ **Date consistency:** Generate `createdAt` first, then `updatedAt = faker.date.between({ from: createdAt, to: new Date() })`.
145
+
146
+ **MSW in SSR / Next.js:** Use `msw/node` `setupServer` for API route tests and `msw/browser` `setupWorker` for client-side tests. Share handler definitions in a single `handlers.ts`.
@@ -0,0 +1,138 @@
1
+ ---
2
+ name: modelsensei
3
+ description: Designs domain-driven data models using DDD aggregates and value objects, produces ORM mappings for SQLAlchemy/Prisma/ActiveRecord, prevents N+1 queries, and generates database migration files. Use when a user needs help with data modeling, ORM schema design, query optimization, or database migrations.
4
+ ---
5
+
6
+ # ModelSensei
7
+
8
+ ## Overview
9
+
10
+ Designs data models using Domain-Driven Design (DDD) tactical patterns — aggregates, entities, value objects, repositories — then maps them to ORM schemas (SQLAlchemy, Prisma, ActiveRecord). Identifies N+1 problems and generates migration files.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Model the Domain First (DDD Tactical Patterns)
15
+
16
+ - **Aggregate Root:** Entry point for a cluster of related objects. All external references go through the root.
17
+ - **Entity:** Has unique identity that persists over time (`Order`, `User`).
18
+ - **Value Object:** Defined by attributes, no identity, immutable (`Money`, `Address`).
19
+
20
+ ```typescript
21
+ class Money { // Value Object
22
+ constructor(readonly amount: number, readonly currency: 'USD' | 'EUR') {
23
+ if (amount < 0) throw new DomainError('Amount cannot be negative');
24
+ }
25
+ add(other: Money): Money {
26
+ if (other.currency !== this.currency) throw new DomainError('Currency mismatch');
27
+ return new Money(this.amount + other.amount, this.currency);
28
+ }
29
+ }
30
+ class Order { // Aggregate Root
31
+ private _items: OrderItem[] = [];
32
+ addItem(item: OrderItem): void {
33
+ if (this._status !== 'draft') throw new DomainError('Cannot modify non-draft order');
34
+ this._items.push(item);
35
+ }
36
+ }
37
+ ```
38
+
39
+ Aggregate rules: only the root has a repository; external aggregates reference each other by ID only; keep aggregates small.
40
+
41
+ ### 2. Map to ORM Schema
42
+
43
+ **Prisma:**
44
+ ```prisma
45
+ model Order {
46
+ id String @id @default(uuid())
47
+ customerId String
48
+ customer Customer @relation(fields: [customerId], references: [id])
49
+ status OrderStatus @default(DRAFT)
50
+ totalAmount Decimal @db.Decimal(12, 2)
51
+ items OrderItem[]
52
+ createdAt DateTime @default(now())
53
+ updatedAt DateTime @updatedAt
54
+ @@index([customerId, status])
55
+ }
56
+ ```
57
+
58
+ **SQLAlchemy:** Use `selectinload` for collections, `joinedload` for single relations. **ActiveRecord:** Use `includes(:items, :customer)`.
59
+
60
+ ### 3. Prevent N+1 Queries
61
+
62
+ Detect N+1 by finding queries inside loops. Fix with eager loading:
63
+ ```typescript
64
+ // Prisma fix — 2 queries instead of 1+N
65
+ const orders = await prisma.order.findMany({
66
+ include: { items: true, customer: { select: { id: true, name: true } } },
67
+ where: { status: 'pending' }, take: 50,
68
+ });
69
+ ```
70
+ Rule: `joinedload`/`joins` for to-one; `selectinload`/`includes` for to-many.
71
+
72
+ ### 4. Generate Migrations
73
+
74
+ ```bash
75
+ npx prisma migrate dev --name add_order_currency_index
76
+ alembic revision --autogenerate -m "add_order_currency_index"
77
+ rails generate migration AddCurrencyIndexToOrders
78
+ ```
79
+
80
+ Migration rules: always provide a `downgrade`/`down` method; never drop a column in the same migration that removes it from code; large table index additions must use `CONCURRENTLY` (Postgres).
81
+
82
+ **Zero-downtime NOT NULL column addition on large tables:** Never add `NOT NULL` with a `DEFAULT` in a single migration on a large table — it locks the table for the full backfill. Instead:
83
+ 1. Add the column as nullable: `ALTER TABLE orders ADD COLUMN notes TEXT`.
84
+ 2. Backfill in batches: `UPDATE orders SET notes = '' WHERE id BETWEEN $1 AND $2`.
85
+ 3. Add the `NOT NULL` constraint using `NOT VALID` to skip historical rows: `ALTER TABLE orders ADD CONSTRAINT orders_notes_not_null CHECK (notes IS NOT NULL) NOT VALID`.
86
+ 4. Validate in a separate transaction: `ALTER TABLE orders VALIDATE CONSTRAINT orders_notes_not_null`.
87
+
88
+ ### 5. Hierarchical Data Modeling
89
+
90
+ Choose the right pattern for tree/hierarchy data:
91
+
92
+ | Pattern | Best for | Recursive CTE? |
93
+ |---|---|---|
94
+ | Adjacency list (`parent_id`) | Simple, shallow trees; easy updates | Yes (`WITH RECURSIVE`) |
95
+ | Closure table | Fast ancestor/descendant queries | No |
96
+ | Nested sets (left/right) | Frequent reads, infrequent writes | No |
97
+
98
+ ```sql
99
+ -- Adjacency list with recursive CTE (Postgres)
100
+ WITH RECURSIVE tree AS (
101
+ SELECT id, name, parent_id, 0 AS depth FROM categories WHERE parent_id IS NULL
102
+ UNION ALL
103
+ SELECT c.id, c.name, c.parent_id, t.depth + 1
104
+ FROM categories c JOIN tree t ON c.parent_id = t.id
105
+ )
106
+ SELECT * FROM tree ORDER BY depth, name;
107
+ ```
108
+
109
+ ### 6. Outbox Pattern for Reliable Domain Events
110
+
111
+ Never publish domain events directly inside a transaction — the event may fire even if the DB commit fails. Use the outbox pattern:
112
+
113
+ 1. Within the same DB transaction that modifies the aggregate, insert a row into an `outbox_events` table.
114
+ 2. A background poller (or Debezium CDC) reads unpublished outbox rows and publishes them to the message broker.
115
+ 3. Mark rows as `published_at = NOW()` after successful broker acknowledgement.
116
+
117
+ ```sql
118
+ CREATE TABLE outbox_events (
119
+ id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
120
+ aggregate TEXT NOT NULL,
121
+ event_type TEXT NOT NULL,
122
+ payload JSONB NOT NULL,
123
+ created_at TIMESTAMPTZ DEFAULT NOW(),
124
+ published_at TIMESTAMPTZ
125
+ );
126
+ ```
127
+
128
+ ## Output Format
129
+
130
+ Deliver: domain model (plain classes, no ORM dependency), ORM schema, migration file(s) with up/down, index strategy justification, and N+1 risks with fixes.
131
+
132
+ ## Edge Cases
133
+
134
+ **Value objects in relational DBs:** Map as embedded columns on the owning entity (`money_amount`, `money_currency`), not separate tables. Only extract to a table if the value object is queried independently.
135
+
136
+ **Soft delete:** Add a partial unique index to exclude soft-deleted rows: `CREATE UNIQUE INDEX ON users (email) WHERE deleted_at IS NULL`.
137
+
138
+ **Oversized aggregates:** If an `Order` could have thousands of `OrderItem` rows, split into a separate aggregate and enforce cross-aggregate invariants asynchronously via domain events.
@@ -0,0 +1,103 @@
1
+ ---
2
+ name: prmentor
3
+ description: Review pull requests with structured diff analysis, tiered feedback (blocking/suggestion/nit), scope checks, test coverage delta, and a merge readiness checklist. Use when a user wants a PR reviewed, wants to write better PRs, or needs feedback on code changes.
4
+ ---
5
+
6
+ # PRMentor
7
+
8
+ ## Overview
9
+
10
+ PRMentor performs thorough, actionable PR reviews using a severity-tiered feedback model. Every review ends with a clear merge readiness verdict.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Read the Diff Holistically First
15
+
16
+ Before commenting on individual lines:
17
+ - Understand the stated purpose of the PR (title, description, linked issue).
18
+ - Identify the scope: is this a bug fix, feature addition, refactor, or dependency update?
19
+ - Check that the changes are coherent — a PR should do one thing. Flag scope creep explicitly.
20
+
21
+ ### 2. Analyze the Diff
22
+
23
+ Work through the diff systematically:
24
+
25
+ **Correctness:**
26
+ - Does the logic match the intended behavior?
27
+ - Are there off-by-one errors, missing null checks, or incorrect conditionals?
28
+ - Does error handling cover all failure modes (network timeout, empty input, concurrent access)?
29
+
30
+ **Test Coverage Delta:**
31
+ - Identify new functions/branches added. Do they have corresponding tests?
32
+ - If using a coverage tool (Istanbul/nyc, pytest-cov, JaCoCo), estimate whether coverage went up or down.
33
+ - A PR that adds logic without tests is a suggestion-level concern; a PR that removes tests is blocking.
34
+
35
+ **Security:**
36
+ - New inputs: are they validated and sanitized?
37
+ - New secrets or credentials: are they in environment variables, not hardcoded?
38
+ - SQL: parameterized queries only? New endpoints: authenticated?
39
+
40
+ **Performance:**
41
+ - New loops over collections: is there an N+1 query risk?
42
+ - New synchronous operations on the hot path that should be async?
43
+
44
+ **Readability & maintainability:**
45
+ - Function length > 40 lines or cyclomatic complexity > 10 → suggest extraction.
46
+ - Variable names that are ambiguous or single-letter (outside obvious iterators).
47
+
48
+ ### 3. Apply Severity Tiers
49
+
50
+ Label every comment with one of three tiers:
51
+
52
+ - **[BLOCKING]** — Must be resolved before merge. Examples: logic bug, security vulnerability, test regression, broken API contract, hardcoded secret.
53
+ - **[SUGGESTION]** — Strongly recommended but not a merge blocker. Examples: missing test for new branch, inefficient query, unclear error message, missing docstring on public API.
54
+ - **[NIT]** — Minor style or preference. Examples: variable naming, comment wording, import ordering. Batch nits at the end; do not scatter them through the review.
55
+
56
+ ### 4. Check Conventional Commits & PR Hygiene
57
+
58
+ - PR title should follow Conventional Commits: `feat:`, `fix:`, `chore:`, `refactor:`, `docs:`, `test:`, `perf:`, `ci:`.
59
+ - PR body should include: what changed, why it changed, how to test it, and any migration notes.
60
+ - Branch should be up to date with `main`/`master` (no merge conflicts).
61
+ - CI checks should be green before review is finalized.
62
+
63
+ ### 5. Deliver the Review
64
+
65
+ Structure the output as:
66
+
67
+ ```
68
+ ## PR Summary
69
+ <1–2 sentences on what the PR does and overall impression>
70
+
71
+ ## Blocking Issues
72
+ - [BLOCKING] <file>:<line> — <problem> → <required fix>
73
+
74
+ ## Suggestions
75
+ - [SUGGESTION] <file>:<line> — <observation> → <recommended change>
76
+
77
+ ## Nits
78
+ - [NIT] <file>:<line> — <minor item>
79
+
80
+ ## Merge Readiness Checklist
81
+ - [ ] All blocking issues resolved
82
+ - [ ] New logic has test coverage
83
+ - [ ] No hardcoded secrets
84
+ - [ ] CI passing
85
+ - [ ] PR title follows Conventional Commits
86
+ - [ ] Migration/breaking-change notes included (if applicable)
87
+
88
+ ## Verdict: APPROVE / REQUEST CHANGES / NEEDS DISCUSSION
89
+ ```
90
+
91
+ ## Edge Cases
92
+
93
+ **1. Large PRs (>500 lines changed).** Request a split into smaller PRs if scope allows. If the PR cannot be split, review in layers: data model first, business logic second, UI/API surface third. Note that the size increases review risk.
94
+
95
+ **2. PR touches files you lack full context for.** State explicitly: "[SUGGESTION] I cannot fully verify this — recommend an additional review from someone with [X] domain expertise." Do not rubber-stamp it.
96
+
97
+ **3. PR fixes a bug but introduces a regression elsewhere.** Scan callers of modified functions. If a signature or return type changes, grep all call sites and flag missed updates as [BLOCKING].
98
+
99
+ **4. IaC review (Terraform/Pulumi/CDK).** Always request the `terraform plan` output alongside the diff. Flag: resource deletions (`-/+` or `-` lines on stateful resources like RDS, S3), security group rule additions (ingress `0.0.0.0/0`), and unintended cost increases. Mark resource deletions as [BLOCKING] unless explicitly approved.
100
+
101
+ **5. First-time contributors.** Use constructive framing — explain *why* a change is needed, not just *what* to fix. Prefer: "This could cause a race condition when X and Y happen concurrently — consider using a mutex here" over "This is wrong, use a mutex." Nits should be prefixed with "Optional:" so the contributor knows what is truly required vs. stylistic preference.
102
+
103
+ **6. Breaking API change detection.** Flag as [BLOCKING]: adding a required field to an existing request schema (breaks existing callers), changing a field type (e.g., `string` → `number`), removing or renaming a response field, and changing an endpoint's HTTP method or URL. Suggest using API versioning (`/v2/`) or a deprecation period with a sunset header instead of in-place breaking changes.
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: perfdetective
3
+ description: Profile application performance, identify CPU/memory/I/O bottlenecks, and deliver optimized code with before/after benchmarks. Use when a user needs to find performance issues, reduce latency, lower memory usage, or speed up slow functions/endpoints.
4
+ ---
5
+
6
+ # PerfDetective
7
+
8
+ ## Overview
9
+
10
+ PerfDetective diagnoses and resolves performance bottlenecks across Python, JVM, Node.js, and browser environments using profiling tools, flamegraph analysis, and targeted optimization patterns.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Identify the Runtime & Collect a Profile
15
+
16
+ Choose the right profiler for the environment:
17
+
18
+ - **Python**: `py-spy record -o profile.svg --pid <PID>` (sampling, no code changes) or `cProfile` + `snakeviz` for function-level stats. For async code use `austin` or `yappi`.
19
+ - **JVM (Java/Kotlin/Scala)**: `async-profiler` (`asprof -e cpu -f flamegraph.html <PID>`); for heap leaks use `jmap -histo` + Eclipse MAT or VisualVM.
20
+ - **Node.js**: `node --prof app.js` + `node --prof-process` or `clinic.js flame` (Clinic.js Doctor for I/O). Use Chrome DevTools Performance tab for in-process profiling.
21
+ - **Browser JS/rendering**: Chrome DevTools Performance panel — record a session, look at the "Bottom-Up" and "Call Tree" tabs for hot functions.
22
+ - **Benchmarking**: Python → `pytest-benchmark`; JS → `Benchmark.js`; JVM → JMH. Always run 5+ iterations and report median ± p95.
23
+
24
+ ### 2. Read the Flamegraph
25
+
26
+ - The **width** of a frame = total CPU time consumed (self + children).
27
+ - Look for **plateaus** (wide flat tops): that function is the bottleneck.
28
+ - Distinguish **CPU-bound** (thick application frames) from **I/O-bound** (thin frames, large gaps, or kernel/syscall stacks like `epoll_wait`, `recv`, `fsync`).
29
+ - Identify **unexpected callers**: a utility function appearing high in the stack often signals a hot loop.
30
+
31
+ ### 3. Apply Targeted Optimizations
32
+
33
+ **CPU-bound hot loops:**
34
+ - Memoize pure functions with `functools.lru_cache` (Python) or a `Map`-based cache (JS).
35
+ - Replace interpreted loops with vectorized operations: NumPy/pandas for Python, SIMD-friendly array methods in JS/Rust.
36
+ - Move heavy computation off the main thread: `concurrent.futures.ProcessPoolExecutor` (Python), Worker Threads (Node.js).
37
+
38
+ **I/O-bound bottlenecks:**
39
+ - Batch database queries: replace N+1 ORM calls with `SELECT ... WHERE id IN (...)` or `DataLoader` (GraphQL).
40
+ - Use connection pooling: `psycopg2.pool`, HikariCP, `pg-pool`.
41
+ - Add async I/O: `asyncio`/`aiohttp` (Python), `Promise.all` over sequential `await` (JS).
42
+ - Cache repeated external calls with Redis (`redis-py`, `ioredis`) using a TTL appropriate to data freshness.
43
+
44
+ **Memory pressure:**
45
+ - Profile heap with `tracemalloc` (Python) or heap snapshots in Chrome DevTools.
46
+ - Replace large in-memory collections with generators/streams.
47
+ - Fix leaks: deregister event listeners, clear caches, use `WeakRef`/`WeakMap`.
48
+
49
+ ### 4. Benchmark Before & After
50
+
51
+ Always produce a side-by-side comparison:
52
+
53
+ ```
54
+ Function: process_records()
55
+ Before: 842 ms median (p95: 1,204 ms), RSS: 340 MB
56
+ After: 91 ms median (p95: 118 ms), RSS: 112 MB
57
+ Improvement: 9.3× faster, 67% less memory
58
+ ```
59
+
60
+ Report the profiling command used so results are reproducible.
61
+
62
+ ### 5. Deliver the Output
63
+
64
+ Provide:
65
+ 1. Root-cause summary (1–3 sentences naming the bottleneck and why it's slow).
66
+ 2. Diff or rewritten function with inline comments explaining each change.
67
+ 3. Benchmark table (before/after).
68
+ 4. Any follow-up work (e.g., "add a Redis layer if this endpoint is called >50 req/s").
69
+
70
+ ## Edge Cases
71
+
72
+ **1. Profiler overhead skews results.** Sampling profilers (py-spy, async-profiler) have <1% overhead; instrumentation profilers (cProfile, JVM agents) can add 10–50%. Switch to a sampling profiler if numbers look suspiciously slow.
73
+
74
+ **2. Optimization invalidated by the compiler/JIT.** JVM JIT and V8 TurboFan can eliminate dead code. Always benchmark the production build. Micro-benchmarks eliminated by the optimizer give false wins.
75
+
76
+ **3. The fix is an architectural change, not a code tweak.** If the flamegraph shows 80%+ in a DB round-trip inside a loop, the right fix is query restructuring or caching — not micro-optimizing the loop body.
77
+
78
+ **4. JVM GC pause analysis.** Enable GC logging: `-Xlog:gc*:file=gc.log:time,uptime`. Analyze with GCViewer or the online GC Easy tool. Prolonged pauses (>200 ms) in G1 usually indicate too-small heap regions or humongous allocations. Switch to ZGC (`-XX:+UseZGC`) for sub-millisecond pauses on heaps >4 GB; use Shenandoah for moderate heaps with low-latency requirements. Set `-XX:MaxGCPauseMillis` as a target, not a guarantee.
79
+
80
+ **5. Async Python profiling.** `cProfile` measures wall clock per call but attributes async I/O wait time to the event loop, not the awaiting coroutine — misleading for async code. Use `yappi` with wall-clock mode:
81
+ ```python
82
+ import yappi
83
+ yappi.set_clock_type("wall")
84
+ yappi.start()
85
+ await your_async_function()
86
+ yappi.stop()
87
+ yappi.get_func_stats().print_all()
88
+ ```
89
+
90
+ **6. Long-running memory leak strategy.** Single heap snapshots miss slow leaks. Take three snapshots: at startup, after 30 minutes of load, and after 60 minutes. Compare object counts between snapshots 2 and 3 — objects that grow continuously are the leak candidates. In Python use `tracemalloc`; in Node.js use `--heap-prof` or Chrome DevTools Memory tab (heap snapshot diff); in JVM use Eclipse MAT's "Leak Suspects" report on a heap dump from `jcmd <pid> VM.heap_dump`.
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: pipelinepro
3
+ description: Design and implement CI/CD pipelines using GitHub Actions or GitLab CI, including pipeline stages, secrets management, deployment strategies (blue-green, canary), artifact pinning, and rollback procedures. Use when a user needs to build, fix, or improve a CI/CD pipeline or deployment workflow.
4
+ ---
5
+
6
+ # PipelinePro
7
+
8
+ ## Overview
9
+
10
+ PipelinePro builds production-grade CI/CD pipelines for GitHub Actions and GitLab CI, covering the full lifecycle from commit to production deployment with safety controls.
11
+
12
+ ## Workflow
13
+
14
+ ### 1. Gather Requirements
15
+
16
+ Before writing any YAML, confirm:
17
+ - **Platform**: GitHub Actions (`.github/workflows/`) or GitLab CI (`.gitlab-ci.yml`)?
18
+ - **Build target**: Docker image, npm package, Python wheel, binary, Terraform plan?
19
+ - **Environments**: dev / staging / production? Any approval gates?
20
+ - **Deployment strategy**: rolling, blue-green, or canary?
21
+ - **Secret sources**: GitHub/GitLab secret store, AWS Secrets Manager, Vault, or `.env` file?
22
+
23
+ ### 2. Structure the Pipeline Stages
24
+
25
+ Use this canonical stage order:
26
+
27
+ ```
28
+ lint → test → build → security-scan → publish-artifact → deploy-staging → [approval] → deploy-production
29
+ ```
30
+
31
+ **GitHub Actions skeleton:**
32
+ ```yaml
33
+ on: { push: { branches: [main] }, pull_request: {} }
34
+ jobs:
35
+ lint:
36
+ runs-on: ubuntu-latest
37
+ steps: [{ uses: actions/checkout@v4 }, { run: npm ci && npm run lint }]
38
+ test:
39
+ needs: lint
40
+ runs-on: ubuntu-latest
41
+ steps: [{ uses: actions/checkout@v4 }, { run: npm ci && npm test -- --coverage }]
42
+ build:
43
+ needs: test
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: docker/build-push-action@v5
48
+ with: { push: true, tags: "ghcr.io/${{ github.repository }}:${{ github.sha }}" }
49
+ ```
50
+
51
+ ### 3. Secrets Injection — OIDC-Based Cloud Auth (Preferred)
52
+
53
+ Never use static cloud credentials in CI. Use OIDC to assume short-lived roles:
54
+
55
+ **GitHub Actions → AWS:**
56
+ ```yaml
57
+ permissions:
58
+ id-token: write
59
+ contents: read
60
+ steps:
61
+ - uses: aws-actions/configure-aws-credentials@v4
62
+ with:
63
+ role-to-assume: arn:aws:iam::123456789012:role/github-ci-role
64
+ aws-region: us-east-1
65
+ ```
66
+
67
+ **GitHub Actions → GCP:**
68
+ ```yaml
69
+ - uses: google-github-actions/auth@v2
70
+ with:
71
+ workload_identity_provider: projects/123/locations/global/workloadIdentityPools/github/providers/github
72
+ service_account: ci@my-project.iam.gserviceaccount.com
73
+ ```
74
+
75
+ For static secrets (API keys, DB passwords): store in GitHub/GitLab secret store or Vault (`hashicorp/vault-action@v3`). Use `environment:` scoping so production secrets are only available in the production job. Never echo secrets; use `::add-mask::` for dynamic values.
76
+
77
+ ### 4. Artifact Pinning
78
+
79
+ - Pin third-party actions to a full commit SHA, not a mutable tag:
80
+ ```yaml
81
+ uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
82
+ ```
83
+ - Pin Docker base images to digest: `FROM node:20-alpine@sha256:abc123...`
84
+ - Use `actions/upload-artifact@v4` / `download-artifact@v4` to pass build outputs between jobs rather than rebuilding.
85
+
86
+ ### 5. Deployment Strategies
87
+
88
+ **Blue-Green:** Deploy to idle environment → smoke test → swap load balancer target → keep old live 10–15 min for instant rollback.
89
+
90
+ **Canary:** Deploy at 1–5% traffic weight (Argo Rollouts, Flagger) → monitor error rate + p99 for 5–30 min → auto-promote or rollback on threshold breach.
91
+
92
+ **Rollback:** `kubectl rollout undo deployment/my-app`. Store previous image SHA as a pipeline artifact for deterministic rollback.
93
+
94
+ ### 6. Output Artifacts
95
+
96
+ Deliver:
97
+ 1. Complete, runnable YAML file(s) with inline comments.
98
+ 2. List of secrets/variables that must be configured and where.
99
+ 3. Deployment strategy diagram (text-based if needed).
100
+ 4. Rollback command or job snippet.
101
+
102
+ ### 6. DB Migration Sequencing
103
+
104
+ Run migrations before the new code deploys — never after. The pattern:
105
+ ```yaml
106
+ migrate:
107
+ needs: build
108
+ steps:
109
+ - run: |
110
+ npx prisma migrate deploy # or: alembic upgrade head / rails db:migrate
111
+ if [ $? -ne 0 ]; then echo "Migration failed — aborting deploy"; exit 1; fi
112
+ deploy:
113
+ needs: migrate
114
+ ```
115
+ For rollback: always provide a `down` migration and keep the previous image SHA as a pipeline artifact so `kubectl rollout undo` or a re-deploy of the prior image is deterministic.
116
+
117
+ ### 7. Container Image Vulnerability Scanning
118
+
119
+ Scan images after build, before publish. Fail the pipeline on critical or high CVEs:
120
+ ```yaml
121
+ scan:
122
+ needs: build
123
+ steps:
124
+ - uses: aquasecurity/trivy-action@master
125
+ with:
126
+ image-ref: ghcr.io/${{ github.repository }}:${{ github.sha }}
127
+ format: table
128
+ exit-code: '1' # fail pipeline
129
+ severity: CRITICAL,HIGH
130
+ ignore-unfixed: true # skip CVEs with no fix available
131
+ ```
132
+ Grype alternative: `grype ghcr.io/myorg/myapp:sha --fail-on high`. Review and suppress false positives via `.trivyignore` or `grype.db` exceptions with documented justification.
133
+
134
+ ## Edge Cases
135
+
136
+ **1. Self-hosted runners with no internet access.** Cache dependencies explicitly (`actions/cache@v4`, `pip download --dest`, npm `--prefer-offline`) and mirror Docker images to an internal registry. Document the exact registry URL as an environment variable.
137
+
138
+ **2. Flaky tests causing false deployment failures.** Add a retry mechanism (`retry: 2` in GitLab; a step-level `continue-on-error` + re-run logic in GitHub Actions) only for known-flaky test suites. Mark the job with a `flaky` label and open a tracking issue — never silently suppress test failures in gates.
139
+
140
+ **3. Monorepo with multiple independently deployable services.** Use path filters to trigger only affected pipelines:
141
+ ```yaml
142
+ on:
143
+ push:
144
+ paths: ['services/api/**']
145
+ ```
146
+ Or use tools like `nx affected`, `turborepo`, or GitLab's `rules: changes:` to skip unaffected jobs.