@workingpayload/agent-skills 1.0.0 → 2.0.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 (80) hide show
  1. package/APIForge/skill.md +150 -17
  2. package/AccessPlus/skill.md +122 -18
  3. package/AlgoMaster/skill.md +110 -17
  4. package/Architekt AI/skill.md +125 -17
  5. package/AuthCraft/skill.md +129 -17
  6. package/AutoScriptor/skill.md +122 -17
  7. package/BoilerCore/skill.md +121 -17
  8. package/BugHunter Pro/skill.md +118 -17
  9. package/ChangeScribe/skill.md +98 -17
  10. package/CodeSage/skill.md +148 -17
  11. package/CommitCraft/skill.md +97 -16
  12. package/CoverageMax/skill.md +145 -16
  13. package/CronGenius/skill.md +141 -16
  14. package/DataPolish/skill.md +126 -16
  15. package/DataWeaver/skill.md +135 -16
  16. package/DockMaster/skill.md +142 -16
  17. package/DocuGenie/skill.md +122 -16
  18. package/EdgeGuard/skill.md +144 -16
  19. package/EnvWizard/skill.md +140 -16
  20. package/ErrorMedic/skill.md +136 -16
  21. package/FeatureSmith/skill.md +123 -16
  22. package/FlexiLayout/skill.md +128 -16
  23. package/FlowTester/skill.md +138 -16
  24. package/FunctionForge/skill.md +120 -16
  25. package/InputShield/skill.md +128 -16
  26. package/IssueForge/skill.md +132 -16
  27. package/KubeCrafter/skill.md +133 -16
  28. package/LogicLens/skill.md +116 -16
  29. package/MockSmith/skill.md +130 -16
  30. package/ModelSensei/skill.md +122 -16
  31. package/PRMentor/skill.md +103 -32
  32. package/PerfDetective/skill.md +90 -32
  33. package/PipelinePro/skill.md +146 -32
  34. package/PolyglotShift/skill.md +94 -32
  35. package/PromptForge/skill.md +118 -32
  36. package/QueryPulse/skill.md +123 -32
  37. package/README.md +416 -329
  38. package/ReadMeCraft/skill.md +127 -32
  39. package/RefactorX/skill.md +84 -32
  40. package/RenderBoost/skill.md +148 -32
  41. package/SEOMancer/skill.md +140 -16
  42. package/ScrapeMaster/skill.md +157 -32
  43. package/SecretSniffer/skill.md +107 -16
  44. package/SecureScan/skill.md +114 -16
  45. package/ServiceSplitter/skill.md +137 -16
  46. package/SpeedSmith/skill.md +139 -16
  47. package/StackWise/skill.md +139 -16
  48. package/TaskOrchestrator/skill.md +119 -16
  49. package/TestCrafter/skill.md +142 -16
  50. package/TraceMind/skill.md +127 -16
  51. package/UISmith/skill.md +115 -16
  52. package/bin/cli.js +377 -0
  53. package/extension-extender/SKILL.md +122 -0
  54. package/fastapi-furious/SKILL.md +148 -0
  55. package/package.json +41 -28
  56. package/python-master/SKILL.md +108 -0
  57. package/react-ranger/SKILL.md +93 -0
  58. package/scripts/build_index.py +282 -0
  59. package/scripts/doctor.py +541 -0
  60. package/scripts/install.py +397 -0
  61. package/scripts/route.py +348 -0
  62. package/scripts/score.py +355 -0
  63. package/scripts/test_skill.py +473 -0
  64. package/scripts/validate.py +254 -0
  65. package/skills-routing.json +1131 -0
  66. package/skills.json +3261 -0
  67. package/Extension-Extender/SKILL.md +0 -41
  68. package/Extension-Extender/references/ui-guidelines.md +0 -26
  69. package/Fastapi-Furious/README.md +0 -16
  70. package/Fastapi-Furious/SKILL.md +0 -37
  71. package/Python-Master/README.md +0 -11
  72. package/Python-Master/SKILL.md +0 -37
  73. package/React-Ranger/README.md +0 -17
  74. package/React-Ranger/SKILL.md +0 -37
  75. package/cli.js +0 -181
  76. package/parse_skills.py +0 -44
  77. /package/{Extension-Extender → extension-extender}/assets/manifest.json +0 -0
  78. /package/{Extension-Extender → extension-extender}/assets/popup.css +0 -0
  79. /package/{Extension-Extender → extension-extender}/assets/popup.html +0 -0
  80. /package/{Extension-Extender → extension-extender}/assets/popup.js +0 -0
package/APIForge/skill.md CHANGED
@@ -1,32 +1,165 @@
1
1
  ---
2
2
  name: apiforge
3
- description: Perfects tasks related to designing robust REST and GraphQL APIs, establishing clear contract definitions, and structuring optimal endpoints. Use when a user asks to handle api or requires assistance with design apis..
3
+ description: Designs production-grade REST and GraphQL APIs including OpenAPI 3.x specs, versioning strategy, RFC 7807 error formats, cursor/offset pagination, and authentication schemes. Use when a user needs to create, review, or improve an API contract, endpoint design, or API documentation.
4
4
  ---
5
5
 
6
6
  # APIForge
7
7
 
8
- ## Overview
8
+ ## Domain Scope
9
9
 
10
- The APIForge skill specializes in designing robust REST and GraphQL APIs, establishing clear contract definitions, and structuring optimal endpoints. It is designed to be the perfect, flawless assistant for api, providing robust, industry-standard solutions.
10
+ REST API design, GraphQL schema design, OpenAPI 3.x specification authoring, API versioning, error response standardization, pagination patterns, rate limiting, and API authentication/authorization schemes.
11
+
12
+ ---
11
13
 
12
14
  ## Workflow
13
15
 
14
- When asked to work on api or related tasks, follow these steps:
16
+ ### 1. Gather Requirements
17
+ Ask or infer:
18
+ - Protocol: REST, GraphQL, gRPC, or mixed?
19
+ - Consumer type: public third-party, internal microservice, mobile client, or browser SPA?
20
+ - Auth requirements: public, API key, OAuth 2.0, mTLS?
21
+ - Scale/rate limit targets (requests/sec, payload sizes)?
22
+ - Breaking-change tolerance (versioning constraints)?
23
+
24
+ ### 2. REST API Design
25
+
26
+ **Resource Naming**
27
+ - Use plural nouns: `/users`, `/orders`, `/products/{id}/variants`
28
+ - No verbs in paths: use HTTP method semantics
29
+ - Hierarchy: max 2-3 levels deep. Avoid `/users/{id}/orders/{orderId}/items/{itemId}/reviews`
30
+
31
+ **HTTP Method Semantics**
32
+ | Method | Use | Idempotent | Safe |
33
+ |--------|-----|-----------|------|
34
+ | GET | Retrieve | Yes | Yes |
35
+ | POST | Create / non-idempotent action | No | No |
36
+ | PUT | Full replace | Yes | No |
37
+ | PATCH | Partial update (JSON Merge Patch RFC 7396 or JSON Patch RFC 6902) | No | No |
38
+ | DELETE | Remove | Yes | No |
39
+
40
+ **Status Codes — use precisely**
41
+ - `200 OK`, `201 Created` (with `Location` header), `204 No Content`
42
+ - `400 Bad Request`, `401 Unauthorized`, `403 Forbidden`, `404 Not Found`, `409 Conflict`, `422 Unprocessable Entity`
43
+ - `429 Too Many Requests` (with `Retry-After` header), `500 Internal Server Error`
44
+
45
+ **Error Format — RFC 7807 Problem Details**
46
+ ```json
47
+ {
48
+ "type": "https://api.example.com/errors/validation-failed",
49
+ "title": "Validation Failed",
50
+ "status": 422,
51
+ "detail": "The 'email' field must be a valid email address.",
52
+ "instance": "/users",
53
+ "errors": [
54
+ { "field": "email", "code": "INVALID_FORMAT", "message": "Not a valid email" }
55
+ ]
56
+ }
57
+ ```
58
+ Content-Type: `application/problem+json`
59
+
60
+ **Pagination**
61
+ - **Offset/limit** (simple, supports random access): `?offset=40&limit=20`. Return total count in `X-Total-Count` header or `meta.total` body field.
62
+ - **Cursor-based** (stable with real-time data, no skipped/duplicated rows): `?cursor=<opaque_token>&limit=20`. Return `next_cursor` and `prev_cursor` in response. Cursor encodes sort field value + ID.
63
+ - Default `limit` to 20, cap at 100. Document defaults in OpenAPI spec.
64
+
65
+ **Versioning Strategy**
66
+ - **URL path versioning** (`/v1/users`) — most visible, easiest to route and cache. Recommended for public APIs.
67
+ - **Header versioning** (`Accept: application/vnd.api+json;version=2`) — cleaner URLs but harder to test in a browser.
68
+ - Maintain N-1 versions. Deprecation: add `Deprecation` and `Sunset` response headers (RFC 8594).
69
+ - Never make breaking changes within a version: adding fields is non-breaking; removing or renaming fields is breaking.
70
+
71
+ ### 3. File Uploads
72
+ - Use `multipart/form-data` for simple uploads. Set `Content-Type: multipart/form-data; boundary=...` and include metadata fields alongside the file part.
73
+ - **Chunked transfer**: for large files, use `Transfer-Encoding: chunked` or split into fixed-size parts with a `Content-Range` header and a server-side assembly step.
74
+ - **TUS resumable uploads** (recommended for >10 MB): client creates an upload resource (`POST`), then sends chunks (`PATCH`) with `Upload-Offset` header. On resume, client fetches current offset (`HEAD`) and continues from there. Use the `tus-js-client` library or the Uppy uploader on the frontend.
75
+ - Cap upload size at the gateway (e.g., nginx `client_max_body_size`). Scan files for malware before processing. Store to object storage (S3/GCS), not the local filesystem.
15
76
 
16
- ### 1. Analysis & Pre-flight
17
- - Analyze the user's request thoroughly.
18
- - Identify the core requirements for designing robust REST and GraphQL APIs, establishing clear contract definitions, and structuring optimal endpoints.
19
- - Ensure all context and preconditions are understood.
77
+ **Sparse Fieldsets / Field Selection**
78
+ - REST: support `?fields[]=id&fields[]=name` or `?fields=id,name` to let clients request only the fields they need. Reduces payload size and prevents over-fetching.
79
+ - Alternatively, use `Prefer: return=minimal` (RFC 7240) to return `204 No Content` instead of the full resource on mutations.
80
+ - Document supported fields in OpenAPI using `example` annotations; reject unknown field names with `400`.
81
+
82
+ ### 4. GraphQL Schema Design
83
+ - Use a **schema-first** approach: define SDL (`.graphql` files), then generate resolvers.
84
+ - Separate **Queries** (reads), **Mutations** (writes), **Subscriptions** (real-time).
85
+ - Use **input types** for mutations: `input CreateUserInput { ... }` not inline args.
86
+ - Avoid N+1 queries: use **DataLoader** pattern to batch and cache field-level data fetches.
87
+ - Implement **cursor-based connections** per Relay specification for lists.
88
+ - Expose `__typename` and design for **client-driven field selection** — do not over-fetch on the server side.
89
+ - Rate limit by **query complexity** (assign cost to fields) and **depth** (max 5-7 levels).
90
+
91
+ ### 4. OpenAPI 3.x Specification
92
+ Structure:
93
+ ```yaml
94
+ openapi: "3.1.0"
95
+ info:
96
+ title: My API
97
+ version: "1.0.0"
98
+ contact: { email: "api@example.com" }
99
+ servers:
100
+ - url: https://api.example.com/v1
101
+ paths:
102
+ /users:
103
+ get:
104
+ summary: List users
105
+ operationId: listUsers
106
+ parameters:
107
+ - $ref: '#/components/parameters/LimitParam'
108
+ - $ref: '#/components/parameters/CursorParam'
109
+ responses:
110
+ '200':
111
+ description: Paginated user list
112
+ content:
113
+ application/json:
114
+ schema:
115
+ $ref: '#/components/schemas/UserListResponse'
116
+ '422':
117
+ $ref: '#/components/responses/ValidationError'
118
+ components:
119
+ schemas: { ... }
120
+ parameters: { ... }
121
+ responses: { ... }
122
+ securitySchemes:
123
+ BearerAuth:
124
+ type: http
125
+ scheme: bearer
126
+ bearerFormat: JWT
127
+ ```
128
+ - Use `$ref` to avoid duplication.
129
+ - Every `operationId` must be unique and camelCase.
130
+ - Validate spec with `redocly lint` or `spectral lint`.
131
+
132
+ ### 5. Authentication Schemes
133
+ - **API keys**: pass in `Authorization: ApiKey <key>` header (not query string — query strings appear in logs).
134
+ - **OAuth 2.0**: use Authorization Code + PKCE for user-delegated access; Client Credentials for machine-to-machine.
135
+ - **JWT**: validate `iss`, `aud`, `exp`, `nbf` on every request. Use RS256 or ES256 (asymmetric). Publish JWKS endpoint.
136
+ - Document security requirements per-operation in OpenAPI `security` field.
137
+
138
+ ### 6. Rate Limiting and Headers
139
+ Return on every response:
140
+ ```
141
+ X-RateLimit-Limit: 1000
142
+ X-RateLimit-Remaining: 943
143
+ X-RateLimit-Reset: 1711584000
144
+ Retry-After: 60 (on 429 only)
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Output Artifacts
150
+
151
+ - OpenAPI 3.x YAML/JSON spec (linted, with all `$ref` components defined)
152
+ - Endpoint table: method, path, auth, description, request/response schema summary
153
+ - Error catalog: all possible `type` URIs with descriptions
154
+ - Pagination contract: example request/response pair for both offset and cursor modes
155
+ - Versioning policy statement
156
+
157
+ ---
20
158
 
21
- ### 2. Execution & Implementation
22
- - Apply the core logic of APIForge perfectly.
23
- - Prioritize clean architecture, high efficiency, and robust error handling.
24
- - Strive for a flawless, comprehensive solution that directly addresses the user's needs.
159
+ ## Edge Cases
25
160
 
26
- ### 3. Validation & Polish
27
- - Review the generated output against industry best practices for api.
28
- - Ensure the result perfectly resolves the user's request without omissions.
161
+ 1. **Partial success in batch operations**: When an endpoint accepts an array of items (e.g., bulk create), some may succeed and some fail. Return `207 Multi-Status` with a per-item result array — never return `200` if any item failed, and never return `400` if any item succeeded. Each item result includes its own `status` code and optional `problem+json` detail.
29
162
 
30
- ## Resources
163
+ 2. **Idempotency for POST requests**: Clients may retry on network timeout, causing duplicate creates. Support `Idempotency-Key` header (UUID v4, client-generated). Cache the first response keyed by `{client_id}:{idempotency_key}` for 24 hours. Return the cached response on replay without re-executing the mutation.
31
164
 
32
- - **`references/best-practices.md`**: Core principles for api.
165
+ 3. **Breaking vs. non-breaking changes in GraphQL**: Adding a field is safe. Making a non-null field nullable is safe. Making a nullable field non-null is breaking (clients not sending the field will fail). Removing a field or changing a type is breaking. Use the `@deprecated(reason: "...")` directive with a migration timeline before removal; use a schema changelog tool like `graphql-inspector diff` in CI to catch accidental breaking changes.
@@ -1,32 +1,136 @@
1
1
  ---
2
2
  name: accessplus
3
- description: Perfects tasks related to designing and implementing role-based access control (RBAC), fine-grained permissions, and secure authorization workflows. Use when a user asks to handle frontend or requires assistance with accessibility..
3
+ description: Designs and implements role-based access control (RBAC), fine-grained permissions, and WCAG 2.1-compliant accessibility. Use when a user needs authorization models, permission policies, ARIA markup, screen-reader support, or audit of access control logic.
4
4
  ---
5
5
 
6
6
  # AccessPlus
7
7
 
8
- ## Overview
8
+ ## Domain Scope
9
9
 
10
- The AccessPlus skill specializes in designing and implementing role-based access control (RBAC), fine-grained permissions, and secure authorization workflows. It is designed to be the perfect, flawless assistant for frontend, providing robust, industry-standard solutions.
10
+ Two distinct but related concerns:
11
+ 1. **Authorization** — who can do what (RBAC, ABAC, policy engines)
12
+ 2. **Accessibility** — who can perceive and operate the UI (WCAG 2.1, ARIA, keyboard nav)
11
13
 
12
- ## Workflow
14
+ ---
15
+
16
+ ## Workflow: Authorization (RBAC / Permissions)
17
+
18
+ ### 1. Model the Permission Space
19
+ - Enumerate **subjects** (users, service accounts, API keys), **resources** (routes, data objects, UI sections), and **actions** (read, write, delete, approve).
20
+ - Choose the right model:
21
+ - **RBAC** — roles own permissions; users own roles. Use for most SaaS apps.
22
+ - **ABAC** — policies evaluate attributes (user.department, resource.classification). Use for data-level row security.
23
+ - **ReBAC** — relationships define access (Google Zanzibar style). Use for social/collaborative apps.
24
+
25
+ ### 2. Implement with a Policy Engine
26
+ - **Casbin**: define models in `model.conf`, policies in `policy.csv` or a DB adapter. Use `enforce(subject, object, action)` at every gate.
27
+ - **OPA (Open Policy Agent)**: write Rego policies, bundle and serve via sidecar or `opa eval`. Integrate via REST API or WASM.
28
+ - **AWS IAM / Cedar**: for cloud-native; Cedar policies are typed and formally verifiable.
29
+ - Always externalize policies from application code — no hardcoded `if role === 'admin'` blocks.
30
+
31
+ **ABAC with environmental attributes (Rego example)**:
32
+ ```rego
33
+ # Allow read only during business hours from corporate IP range
34
+ allow {
35
+ input.action == "read"
36
+ hour := time.clock(time.now_ns())[0]
37
+ hour >= 8; hour < 18 # 08:00–18:00 UTC
38
+ net.cidr_contains("10.0.0.0/8", input.ip) # corporate network
39
+ }
40
+ ```
41
+ Cedar equivalent: `when { context.hour >= 8 && context.hour < 18 && context.ip.isInRange(ip("10.0.0.0/8")) }`. Always pass `time` and `ip` as request context — never evaluate them inside the policy engine without an explicit input.
42
+
43
+ ### 3. Enforce at Every Layer
44
+ - **Network/API gateway**: coarse-grained (route-level) checks via middleware (e.g., Express `rbac` middleware, FastAPI dependency injection).
45
+ - **Service layer**: business-object-level checks before mutations.
46
+ - **Database**: row-level security (PostgreSQL RLS policies) as the final safety net.
47
+ - Never rely solely on UI hiding — always enforce server-side.
48
+
49
+ **PostgreSQL RLS multi-tenant example**:
50
+ ```sql
51
+ -- Set tenant context before queries (application layer)
52
+ SET app.current_tenant_id = '42';
53
+
54
+ -- Policy: users see only their tenant's rows
55
+ CREATE POLICY tenant_isolation ON orders
56
+ USING (tenant_id = current_setting('app.current_tenant_id')::int);
57
+
58
+ ALTER TABLE orders ENABLE ROW LEVEL SECURITY;
59
+
60
+ -- Test: query as a restricted role
61
+ SET ROLE app_user;
62
+ SELECT * FROM orders; -- returns only tenant 42 rows
63
+ ```
64
+ Use `SET LOCAL` inside transactions to scope the setting; verify with `EXPLAIN` that the RLS filter is applied before any joins.
65
+
66
+ ### 4. Audit and Test
67
+ - Log every authorization decision with: `{subject, resource, action, decision, timestamp, request_id}`.
68
+ - Write unit tests per policy rule; write integration tests for privilege escalation paths.
69
+ - Use tools: `casbin-editor` (visual policy debugger), `opa test` (Rego unit tests).
70
+
71
+ ---
72
+
73
+ ## Workflow: Accessibility (WCAG 2.1 / ARIA)
13
74
 
14
- When asked to work on frontend or related tasks, follow these steps:
75
+ ### 1. Audit Existing Markup
76
+ - Run automated scanners: **axe-core** (browser extension or `@axe-core/react`), **Lighthouse** accessibility audit, **Pa11y** in CI.
77
+ - Automated tools catch ~30-40% of issues. Manual testing covers the rest.
15
78
 
16
- ### 1. Analysis & Pre-flight
17
- - Analyze the user's request thoroughly.
18
- - Identify the core requirements for designing and implementing role-based access control (RBAC), fine-grained permissions, and secure authorization workflows.
19
- - Ensure all context and preconditions are understood.
79
+ ### 2. Fix by POUR Principles
80
+ **Perceivable**
81
+ - All `<img>` must have `alt` text (empty `alt=""` for decorative images).
82
+ - Color contrast ratio: ≥ 4.5:1 for normal text, ≥ 3:1 for large text (18pt+). Use `colour-contrast-checker` or Figma plugin.
83
+ - Captions for all `<video>` content.
84
+
85
+ **Operable**
86
+ - Every interactive element reachable and usable via keyboard alone (Tab, Shift+Tab, Enter, Space, arrow keys).
87
+ - No keyboard traps. Modals must trap focus internally and restore on close.
88
+ - `prefers-reduced-motion` media query: disable or reduce animations.
89
+
90
+ **Understandable**
91
+ - `<html lang="en">` set correctly. Lang attribute on mixed-language spans.
92
+ - Form inputs have associated `<label>` (not just placeholder text).
93
+ - Error messages identify the field and describe the fix.
94
+
95
+ **Robust**
96
+ - Use semantic HTML first: `<nav>`, `<main>`, `<aside>`, `<button>`, `<table>`.
97
+ - Add ARIA only when native semantics are insufficient.
98
+ - ARIA rules: `role` must be valid; `aria-labelledby` must reference an existing `id`; do not use `aria-hidden="true"` on focusable elements.
99
+
100
+ ### 3. Key ARIA Patterns
101
+ ```html
102
+ <!-- Live regions for dynamic content -->
103
+ <div aria-live="polite" aria-atomic="true">Status message</div>
104
+
105
+ <!-- Custom button (prefer <button> instead) -->
106
+ <div role="button" tabindex="0" aria-pressed="false">Toggle</div>
107
+
108
+ <!-- Skip link (must be first focusable element) -->
109
+ <a href="#main-content" class="skip-link">Skip to main content</a>
110
+
111
+ <!-- Dialog -->
112
+ <div role="dialog" aria-modal="true" aria-labelledby="dialog-title">
113
+ <h2 id="dialog-title">Confirm Action</h2>
114
+ </div>
115
+ ```
116
+
117
+ ### 4. Screen Reader Testing
118
+ - Test with: **NVDA** + Chrome (Windows), **VoiceOver** + Safari (macOS/iOS), **TalkBack** (Android).
119
+ - Verify: heading hierarchy (`h1`→`h2`→`h3`), landmark regions, form labels, error announcements.
120
+
121
+ ---
122
+
123
+ ## Output Artifacts
124
+
125
+ - **Authorization**: policy file (Casbin `.conf`/`.csv` or OPA `.rego`), middleware snippet, test cases covering escalation paths, audit log schema.
126
+ - **Accessibility**: annotated diff of HTML/JSX fixes, axe-core report summary, keyboard nav checklist, WCAG 2.1 level (A/AA/AAA) compliance statement.
127
+
128
+ ---
20
129
 
21
- ### 2. Execution & Implementation
22
- - Apply the core logic of AccessPlus perfectly.
23
- - Prioritize clean architecture, high efficiency, and robust error handling.
24
- - Strive for a flawless, comprehensive solution that directly addresses the user's needs.
130
+ ## Edge Cases
25
131
 
26
- ### 3. Validation & Polish
27
- - Review the generated output against industry best practices for frontend.
28
- - Ensure the result perfectly resolves the user's request without omissions.
132
+ 1. **Wildcard permissions and scope creep**: When a `*` action is granted, validate it cannot transitively grant higher-privilege actions (e.g., `write` on a config resource should not imply `admin`). Enumerate all resources explicitly; avoid implicit wildcards in production policies.
29
133
 
30
- ## Resources
134
+ 2. **Dynamic ARIA and SPAs**: Single-page apps mutate the DOM without page loads. Screen readers do not automatically announce DOM changes — every dynamic update must use `aria-live` regions or focus management. After route navigation, move focus to the `<h1>` or a skip target.
31
135
 
32
- - **`references/best-practices.md`**: Core principles for frontend.
136
+ 3. **Inherited roles and permission conflicts**: In hierarchical RBAC (e.g., `manager` inherits `employee`), a `deny` rule on the child role must not be silently overridden by an `allow` on the parent. Use explicit deny-wins semantics and test conflict resolution order in the policy engine.
@@ -1,32 +1,125 @@
1
1
  ---
2
2
  name: algomaster
3
- description: Perfects tasks related to analyzing algorithmic complexity, optimizing data structures, and providing highly efficient solutions to computational problems. Use when a user asks to handle algorithm or requires assistance with improves algorithms..
3
+ description: Analyzes algorithmic complexity, selects optimal data structures, and rewrites inefficient solutions using DP, greedy, graph, and divide-and-conquer strategies. Use when a user needs Big-O analysis, a faster algorithm, or help solving a competitive-programming or production performance problem.
4
4
  ---
5
5
 
6
6
  # AlgoMaster
7
7
 
8
- ## Overview
8
+ ## Domain Scope
9
9
 
10
- The AlgoMaster skill specializes in analyzing algorithmic complexity, optimizing data structures, and providing highly efficient solutions to computational problems. It is designed to be the perfect, flawless assistant for algorithm, providing robust, industry-standard solutions.
10
+ Covers: complexity analysis, data structure selection, algorithm design patterns (DP, greedy, graph algorithms, binary search, divide-and-conquer, two-pointer, sliding window), and production-level optimization.
11
+
12
+ ---
11
13
 
12
14
  ## Workflow
13
15
 
14
- When asked to work on algorithm or related tasks, follow these steps:
16
+ ### 1. Understand and Classify the Problem
17
+ - State the problem constraints: input size `n`, value ranges, time/memory limits.
18
+ - Classify the problem type:
19
+ - **Sequence/array**: sliding window, two-pointer, prefix sums, binary search
20
+ - **Optimization (overlapping subproblems)**: dynamic programming
21
+ - **Optimization (greedy choice property)**: greedy
22
+ - **Graph/tree**: BFS, DFS, Dijkstra, Bellman-Ford, Union-Find, topological sort
23
+ - **String**: KMP, Z-algorithm, Aho-Corasick, suffix arrays
24
+ - **Combinatorics/math**: number theory, modular arithmetic, FFT
25
+
26
+ ### 2. Analyze Existing Complexity
27
+ Provide a formal Big-O analysis:
28
+ - **Time**: worst case, average case, amortized (for operations on data structures)
29
+ - **Space**: auxiliary space, recursion stack depth
30
+ - Use recurrence relations for recursive algorithms; apply Master Theorem where applicable.
31
+
32
+ Example annotation format:
33
+ ```
34
+ current: O(n²) time — nested loop scanning for duplicates
35
+ target: O(n) time, O(n) space — HashSet for seen values
36
+ ```
37
+
38
+ ### 3. Design the Optimal Solution
39
+
40
+ **Dynamic Programming checklist**:
41
+ 1. Define the state: `dp[i]` means...
42
+ 2. Write the recurrence relation.
43
+ 3. Identify base cases.
44
+ 4. Determine traversal order (top-down with memoization vs. bottom-up tabulation).
45
+ 5. Check if space can be reduced (rolling array, O(1) if only adjacent states needed).
46
+
47
+ **Graph algorithms selection**:
48
+ - Unweighted shortest path → BFS (O(V+E))
49
+ - Weighted, non-negative → Dijkstra with min-heap (O((V+E) log V))
50
+ - Negative weights, no negative cycles → Bellman-Ford (O(VE))
51
+ - All-pairs shortest path → Floyd-Warshall (O(V³))
52
+ - Minimum spanning tree → Kruskal (O(E log E)) or Prim (O((V+E) log V))
53
+ - Connectivity / cycle detection → Union-Find with path compression + union by rank (O(α(n)) ≈ O(1))
54
+
55
+ **Data structure selection guide**:
56
+ | Need | Structure | Time complexity |
57
+ |------|-----------|----------------|
58
+ | O(1) lookup by key | HashMap / HashSet | O(1) avg |
59
+ | Sorted order + fast insert/delete | TreeMap / SortedSet | O(log n) |
60
+ | Frequent min/max queries | Min/Max Heap | O(log n) push/pop |
61
+ | Range sum queries | Fenwick Tree (BIT) | O(log n) update/query |
62
+ | Range update + query | Segment Tree | O(log n) |
63
+ | Prefix queries on strings | Trie | O(L) where L = key length |
64
+ | Stack with min/max | Monotonic stack | O(n) total |
65
+
66
+ ### 4. Implement with Clarity
67
+ - Name variables after their semantic role, not `i`, `j`, `k` for non-loop indexes.
68
+ - Add a comment block before the function:
69
+ ```
70
+ # Approach: [algorithm name]
71
+ # Time: O(...) Space: O(...)
72
+ # Invariant: [what holds at each iteration]
73
+ ```
74
+ - Prefer iterative over recursive when stack depth may exceed ~10,000 (Python default recursion limit).
75
+
76
+ ### 5. Write Test Cases
77
+ Cover these categories:
78
+ - **Base cases**: empty input, single element, n=1
79
+ - **Small cases**: manually verifiable correctness
80
+ - **Edge cases**: all-same elements, already sorted/reverse-sorted, max `n`, integer overflow boundaries
81
+ - **Stress tests**: compare brute-force output against optimized output on random inputs
15
82
 
16
- ### 1. Analysis & Pre-flight
17
- - Analyze the user's request thoroughly.
18
- - Identify the core requirements for analyzing algorithmic complexity, optimizing data structures, and providing highly efficient solutions to computational problems.
19
- - Ensure all context and preconditions are understood.
83
+ ### 6. Validate the Optimization
84
+ - Measure actual runtime with `timeit` (Python) or `System.nanoTime()` (Java) on representative inputs.
85
+ - Profile memory with `tracemalloc` (Python), `valgrind --tool=massif` (C/C++), or VisualVM (JVM).
86
+ - For competitive programming: estimate ops/second (~10⁸ simple ops/sec in C++, ~10⁷ in Python) and verify n × complexity fits within time limit.
87
+
88
+ ### 7. Floating-Point Precision
89
+ Never use `==` to compare floats. Use epsilon comparison for near-equality, or integer arithmetic for exact results:
90
+ ```python
91
+ # Epsilon comparison
92
+ EPSILON = 1e-9
93
+ def nearly_equal(a, b): return abs(a - b) < EPSILON
94
+
95
+ # Exact integer arithmetic for geometry (avoid floats entirely)
96
+ # Cross product sign to determine orientation — stays in integers
97
+ def cross(o, a, b): return (a[0]-o[0])*(b[1]-o[1]) - (a[1]-o[1])*(b[0]-o[0])
98
+ ```
99
+ For financial or competitive-programming problems requiring exact decimals, use Python's `fractions.Fraction` or `decimal.Decimal`. In geometry, prefer integer coordinates scaled by a constant factor over floating-point coordinates.
100
+
101
+ ### 8. HashMap Worst-Case O(n) Warning
102
+ HashMap average O(1) lookup degrades to O(n) under adversarial hash collisions. In competitive programming or user-controlled key scenarios:
103
+ - Use a **custom hash** with randomization: `hash(key) ^ random_salt` to prevent collision attacks.
104
+ - In Java: prefer `TreeMap` (O(log n) guaranteed) when keys are attacker-controlled. Enable JVM hash randomization (`-XX:+UseStringDeduplication`).
105
+ - In C++: replace `unordered_map` with a custom hash (e.g., splitmix64) when solving problems that may be designed to exploit standard hash functions.
106
+
107
+ ---
108
+
109
+ ## Output Format
110
+
111
+ Provide the solution as:
112
+ 1. **Complexity summary**: Before / After table (time + space)
113
+ 2. **Annotated code**: with approach comment block and inline invariant notes
114
+ 3. **Test cases**: at minimum 5, grouped by category
115
+ 4. **Trade-off note**: when a faster algorithm sacrifices readability or requires a more complex data structure, state the trade-off explicitly
116
+
117
+ ---
20
118
 
21
- ### 2. Execution & Implementation
22
- - Apply the core logic of AlgoMaster perfectly.
23
- - Prioritize clean architecture, high efficiency, and robust error handling.
24
- - Strive for a flawless, comprehensive solution that directly addresses the user's needs.
119
+ ## Edge Cases
25
120
 
26
- ### 3. Validation & Polish
27
- - Review the generated output against industry best practices for algorithm.
28
- - Ensure the result perfectly resolves the user's request without omissions.
121
+ 1. **Integer overflow in intermediate calculations**: When computing products, sums of squares, or coordinates, intermediate values may exceed 32-bit int range. Use 64-bit integers (`long` in Java/C++, Python ints are arbitrary precision). For modular arithmetic problems, apply `(a * b) % MOD` at each multiplication step, not at the end.
29
122
 
30
- ## Resources
123
+ 2. **Greedy fails when local optimum ≠ global optimum**: Verify greedy correctness via an exchange argument proof — show that swapping any two adjacent elements in a greedy ordering cannot improve the solution. If this cannot be shown, switch to DP. Classic failure case: fractional knapsack is greedy-correct; 0/1 knapsack is not.
31
124
 
32
- - **`references/best-practices.md`**: Core principles for algorithm.
125
+ 3. **Graph problems on disconnected inputs**: BFS/DFS starting from one node will not visit disconnected components. Always iterate over all nodes as potential starting points (outer loop over `V`) and check `visited` status before starting a traversal. Dijkstra returning `∞` for unreachable nodes is expected — handle it explicitly rather than treating `∞` as a valid distance.
@@ -1,32 +1,140 @@
1
1
  ---
2
2
  name: architekt-ai
3
- description: Perfects tasks related to crafting scalable system architectures, designing microservices, and outlining high-level technical blueprints. Use when a user asks to handle architecture or requires assistance with system design..
3
+ description: Designs scalable system architectures using C4 model diagrams, Architecture Decision Records (ADRs), CQRS, event sourcing, and microservices patterns. Use when a user needs to design a new system, evaluate trade-offs between architectural styles, document decisions, or review an existing architecture for scalability and resilience.
4
4
  ---
5
5
 
6
6
  # Architekt AI
7
7
 
8
- ## Overview
8
+ ## Domain Scope
9
9
 
10
- The Architekt AI skill specializes in crafting scalable system architectures, designing microservices, and outlining high-level technical blueprints. It is designed to be the perfect, flawless assistant for architecture, providing robust, industry-standard solutions.
10
+ System architecture design, architectural pattern selection (microservices, monolith, CQRS, event sourcing, saga), non-functional requirements (NFRs) elicitation, C4 model diagrams, Architecture Decision Records, distributed systems trade-offs (CAP theorem, BASE vs. ACID), and technology stack selection.
11
+
12
+ ---
11
13
 
12
14
  ## Workflow
13
15
 
14
- When asked to work on architecture or related tasks, follow these steps:
16
+ ### 1. Elicit Non-Functional Requirements (NFRs)
17
+ Before designing anything, gather:
18
+ - **Availability**: target SLA (99.9% = 8.7h/year downtime; 99.99% = 52min/year)
19
+ - **Throughput**: peak requests/sec, data ingestion rate (events/sec, MB/s)
20
+ - **Latency**: p50/p95/p99 targets (e.g., "p99 < 200ms for reads")
21
+ - **Consistency**: strong vs. eventual — which operations require linearizability?
22
+ - **Durability**: RPO (max data loss), RTO (max recovery time)
23
+ - **Scale**: current users, 12-month growth projection, geographic distribution
24
+ - **Compliance**: GDPR, SOC2, HIPAA, PCI-DSS — data residency requirements
25
+ - **Team size & structure**: Conway's Law — architecture will mirror the org chart
26
+
27
+ ### 2. Apply CAP Theorem to Data Tier Decisions
28
+ When choosing between consistency and availability during network partition:
29
+ - **CP systems** (HBase, Zookeeper, etcd): used for coordination, leader election, distributed locks. Accept unavailability over stale reads.
30
+ - **AP systems** (Cassandra, DynamoDB, CouchDB): used for user-facing data requiring high availability. Accept eventual consistency; design for conflict resolution (LWW, CRDTs, application-level merge).
31
+ - **CA systems** (traditional RDBMS, single-node): only valid in absence of network partition — not suitable for geo-distributed deployments.
32
+
33
+ ### 3. Choose an Architectural Style
34
+
35
+ **Monolith first** if: team < 8 engineers, domain not yet fully understood, MVP phase. Prefer **modular monolith** (clear module boundaries, separate packages, enforced via ArchUnit or Dependency Cruiser) over a "big ball of mud".
36
+
37
+ **Microservices** when: teams own services independently, services have different scaling requirements, polyglot persistence is needed. Each service: owns its data store (no shared DB), communicates via versioned APIs or events, is independently deployable.
38
+
39
+ **CQRS (Command Query Responsibility Segregation)**:
40
+ - Separate write model (Commands → aggregate → event store) from read model (projections, denormalized read DB).
41
+ - Use when read and write throughput/shape requirements differ significantly.
42
+ - Implement with: Axon Framework (Java), EventStoreDB, or Kafka + PostgreSQL read model.
43
+
44
+ **Event Sourcing**:
45
+ - Store all state changes as an immutable sequence of events; current state = replay of events.
46
+ - Benefits: full audit log, temporal queries, easy event replay.
47
+ - Costs: eventual consistency for reads, snapshot strategy needed for large aggregates, schema evolution complexity.
48
+ - Do NOT use event sourcing just for audit logs — use CDC (Debezium) + an audit table instead if that's the only requirement.
49
+
50
+ **Saga Pattern** for distributed transactions:
51
+ - **Choreography**: each service publishes events; others react. Simple, no central coordinator. Risk: hard to track overall state.
52
+ - **Orchestration**: a saga orchestrator (state machine) sends commands and handles failures. Easier to reason about; single point of failure risk.
53
+
54
+ ### 4. Design with the C4 Model
55
+ Produce diagrams at the appropriate level of detail:
56
+
57
+ **Level 1 — System Context**
58
+ - Boxes: the system being designed, external users, external systems it integrates with.
59
+ - Focus: what the system does and who uses it.
60
+
61
+ **Level 2 — Container**
62
+ - Boxes: web app, API server, worker, database, message broker, CDN.
63
+ - Arrows: synchronous (REST/gRPC) vs. asynchronous (Kafka/RabbitMQ) with protocol labels.
64
+
65
+ **Level 3 — Component** (within a container)
66
+ - Boxes: controllers, services, repositories, domain aggregates.
67
+ - Show dependency direction; ensure it aligns with layered/hexagonal architecture rules.
68
+
69
+ **Level 4 — Code** (optional; only for complex aggregates or algorithms)
70
+ - Class/sequence diagrams for critical paths.
71
+
72
+ Use Mermaid or PlantUML for text-based C4 diagrams in ADRs.
15
73
 
16
- ### 1. Analysis & Pre-flight
17
- - Analyze the user's request thoroughly.
18
- - Identify the core requirements for crafting scalable system architectures, designing microservices, and outlining high-level technical blueprints.
19
- - Ensure all context and preconditions are understood.
74
+ ### 5. Write Architecture Decision Records (ADRs)
75
+ Format (MADR — Markdown Architectural Decision Records):
76
+ ```markdown
77
+ # ADR-0001: Use PostgreSQL with JSONB for product catalog
78
+
79
+ ## Status
80
+ Accepted
81
+
82
+ ## Context
83
+ The product catalog requires flexible schema for varying product attributes
84
+ across categories, combined with strong transactional guarantees for inventory.
85
+
86
+ ## Decision
87
+ Use PostgreSQL with JSONB columns for attribute storage rather than a document
88
+ database, keeping relational guarantees for inventory and order tables.
89
+
90
+ ## Consequences
91
+ + Single database reduces operational complexity.
92
+ + JSONB GIN indexes provide fast attribute queries.
93
+ - Schema validation must be enforced at the application layer.
94
+ - JSONB queries are less ergonomic than native document DB queries.
95
+
96
+ ## Alternatives Considered
97
+ - MongoDB: rejected due to lack of multi-document ACID transactions (pre-4.0).
98
+ - Hybrid (PostgreSQL + MongoDB): rejected due to two-DB operational overhead.
99
+ ```
100
+ Store ADRs in `/docs/adr/` numbered sequentially. Never delete — update status to "Superseded by ADR-XXXX".
101
+
102
+ ### 6. Zero-Downtime Database Migrations
103
+ Use the **expand/contract pattern** to avoid locking tables during live traffic:
104
+ 1. **Expand**: add new column/table alongside old one (both writes go to old + new).
105
+ 2. **Migrate**: backfill data in batches; use `gh-ost` (GitHub Online Schema Change for MySQL) or `pg_repack` (PostgreSQL) to rebuild tables without long locks.
106
+ 3. **Contract**: once all reads use the new column, drop the old one in a separate release.
107
+
108
+ Never run `ALTER TABLE … ADD COLUMN NOT NULL` without a default on a large table in production — it locks the table. Always add columns as nullable first, then add the constraint after backfill.
109
+
110
+ **CDN Caching Gotchas**
111
+ - The `Vary` header tells CDNs to cache separate copies per header value (e.g., `Vary: Accept-Encoding, Accept-Language`). Including `Vary: Cookie` or `Vary: Authorization` effectively disables CDN caching — use surrogate keys or cache bypass rules instead.
112
+ - For authenticated responses: set `Cache-Control: private, no-store` to prevent CDN/proxy caching. For public cacheable resources: `Cache-Control: public, max-age=3600, s-maxage=86400` (browser vs. CDN TTLs differ). Always set `Surrogate-Control` (Fastly/Varnish) or `CDN-Cache-Control` separately when you need different TTLs at the edge vs. the browser.
113
+
114
+ ### 7. Address Resilience and Failure Modes
115
+ - **Circuit breaker**: Resilience4j (Java), Polly (.NET), `pybreaker` (Python). Open after N failures, half-open after timeout.
116
+ - **Retry with exponential backoff + jitter**: base delay 100ms, max 30s, jitter ±25%.
117
+ - **Bulkhead**: isolate thread pools or connection pools per downstream service.
118
+ - **Timeout**: set at every network call. No unbounded blocking.
119
+ - **Dead Letter Queue (DLQ)**: for every message consumer. Alert on DLQ depth > 0.
120
+ - **Health checks**: `/health/live` (process alive) and `/health/ready` (dependencies healthy), consumed by load balancer and orchestrator (Kubernetes).
121
+
122
+ ---
123
+
124
+ ## Output Artifacts
125
+
126
+ - C4 Level 1 + Level 2 diagrams (Mermaid)
127
+ - ADR document(s) for each significant decision
128
+ - NFR table with current targets and how the design meets them
129
+ - Data flow diagram for the critical path (happy path + failure path)
130
+ - Technology stack table with rationale and alternatives considered
131
+
132
+ ---
20
133
 
21
- ### 2. Execution & Implementation
22
- - Apply the core logic of Architekt AI perfectly.
23
- - Prioritize clean architecture, high efficiency, and robust error handling.
24
- - Strive for a flawless, comprehensive solution that directly addresses the user's needs.
134
+ ## Edge Cases
25
135
 
26
- ### 3. Validation & Polish
27
- - Review the generated output against industry best practices for architecture.
28
- - Ensure the result perfectly resolves the user's request without omissions.
136
+ 1. **Premature microservices decomposition**: Splitting a monolith before understanding domain boundaries creates distributed monoliths — services that are tightly coupled and must be deployed together, gaining all the costs of microservices with none of the benefits. Apply Domain-Driven Design (DDD) bounded context analysis first. Use the Strangler Fig pattern to extract services incrementally from a working monolith.
29
137
 
30
- ## Resources
138
+ 2. **Event schema evolution in event sourcing**: Once events are written to the store they are immutable. When the event schema changes, old events cannot be rewritten. Implement upcasting (transform old event format to new at read time), or use schema registry (Confluent Schema Registry with Avro/Protobuf) with backward/forward compatibility rules. Never use `Object` or untyped JSON for events in production.
31
139
 
32
- - **`references/best-practices.md`**: Core principles for architecture.
140
+ 3. **CQRS read model consistency lag**: In CQRS, the read model is updated asynchronously after the command side commits. A client that writes then immediately reads may receive stale data. Options: (a) return the write result directly in the command response (sufficient for most UIs), (b) poll with a version token until the read model catches up, (c) use a synchronous projection for latency-sensitive reads at the cost of complexity. Document the chosen consistency contract in the API spec.