@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.
- package/APIForge/skill.md +150 -17
- package/AccessPlus/skill.md +122 -18
- package/AlgoMaster/skill.md +110 -17
- package/Architekt AI/skill.md +125 -17
- package/AuthCraft/skill.md +129 -17
- package/AutoScriptor/skill.md +122 -17
- package/BoilerCore/skill.md +121 -17
- package/BugHunter Pro/skill.md +118 -17
- package/ChangeScribe/skill.md +98 -17
- package/CodeSage/skill.md +148 -17
- package/CommitCraft/skill.md +97 -16
- package/CoverageMax/skill.md +145 -16
- package/CronGenius/skill.md +141 -16
- package/DataPolish/skill.md +126 -16
- package/DataWeaver/skill.md +135 -16
- package/DockMaster/skill.md +142 -16
- package/DocuGenie/skill.md +122 -16
- package/EdgeGuard/skill.md +144 -16
- package/EnvWizard/skill.md +140 -16
- package/ErrorMedic/skill.md +136 -16
- package/FeatureSmith/skill.md +123 -16
- package/FlexiLayout/skill.md +128 -16
- package/FlowTester/skill.md +138 -16
- package/FunctionForge/skill.md +120 -16
- package/InputShield/skill.md +128 -16
- package/IssueForge/skill.md +132 -16
- package/KubeCrafter/skill.md +133 -16
- package/LogicLens/skill.md +116 -16
- package/MockSmith/skill.md +130 -16
- package/ModelSensei/skill.md +122 -16
- package/PRMentor/skill.md +103 -32
- package/PerfDetective/skill.md +90 -32
- package/PipelinePro/skill.md +146 -32
- package/PolyglotShift/skill.md +94 -32
- package/PromptForge/skill.md +118 -32
- package/QueryPulse/skill.md +123 -32
- package/README.md +416 -329
- package/ReadMeCraft/skill.md +127 -32
- package/RefactorX/skill.md +84 -32
- package/RenderBoost/skill.md +148 -32
- package/SEOMancer/skill.md +140 -16
- package/ScrapeMaster/skill.md +157 -32
- package/SecretSniffer/skill.md +107 -16
- package/SecureScan/skill.md +114 -16
- package/ServiceSplitter/skill.md +137 -16
- package/SpeedSmith/skill.md +139 -16
- package/StackWise/skill.md +139 -16
- package/TaskOrchestrator/skill.md +119 -16
- package/TestCrafter/skill.md +142 -16
- package/TraceMind/skill.md +127 -16
- package/UISmith/skill.md +115 -16
- package/bin/cli.js +377 -0
- package/extension-extender/SKILL.md +122 -0
- package/fastapi-furious/SKILL.md +148 -0
- package/package.json +41 -28
- package/python-master/SKILL.md +108 -0
- package/react-ranger/SKILL.md +93 -0
- package/scripts/build_index.py +282 -0
- package/scripts/doctor.py +541 -0
- package/scripts/install.py +397 -0
- package/scripts/route.py +348 -0
- package/scripts/score.py +355 -0
- package/scripts/test_skill.py +473 -0
- package/scripts/validate.py +254 -0
- package/skills-routing.json +1131 -0
- package/skills.json +3261 -0
- package/Extension-Extender/SKILL.md +0 -41
- package/Extension-Extender/references/ui-guidelines.md +0 -26
- package/Fastapi-Furious/README.md +0 -16
- package/Fastapi-Furious/SKILL.md +0 -37
- package/Python-Master/README.md +0 -11
- package/Python-Master/SKILL.md +0 -37
- package/React-Ranger/README.md +0 -17
- package/React-Ranger/SKILL.md +0 -37
- package/cli.js +0 -181
- package/parse_skills.py +0 -44
- /package/{Extension-Extender → extension-extender}/assets/manifest.json +0 -0
- /package/{Extension-Extender → extension-extender}/assets/popup.css +0 -0
- /package/{Extension-Extender → extension-extender}/assets/popup.html +0 -0
- /package/{Extension-Extender → extension-extender}/assets/popup.js +0 -0
package/DockMaster/skill.md
CHANGED
|
@@ -1,32 +1,158 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: dockmaster
|
|
3
|
-
description:
|
|
3
|
+
description: Creates optimized, secure Dockerfiles using multi-stage builds, non-root users, pinned digests, and .dockerignore. Scans images with Trivy, writes Docker Compose files, and advises on Helm chart structure. Use when a user asks to write a Dockerfile, containerize an application, or set up container orchestration.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# DockMaster
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Produce production-grade Dockerfiles and Compose configs that are minimal, reproducible, and secure. Every image must: use multi-stage builds to minimize final size, run as a non-root user, pin base images to digests, and pass a Trivy scan with no CRITICAL or HIGH CVEs.
|
|
11
11
|
|
|
12
12
|
## Workflow
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### 1. Analyze the Application
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
16
|
+
Determine:
|
|
17
|
+
- **Runtime**: Node.js, Python, Go, Java, etc.
|
|
18
|
+
- **Build requirements**: compiler, package manager, test runner
|
|
19
|
+
- **Artifact**: compiled binary, bundled JS, JAR, or source with interpreter
|
|
20
|
+
- **Port and protocol**: HTTP, gRPC, WebSocket
|
|
21
|
+
- **Config source**: environment variables, mounted secrets, config files
|
|
20
22
|
|
|
21
|
-
### 2.
|
|
22
|
-
- Apply the core logic of DockMaster 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.
|
|
23
|
+
### 2. Write a Multi-Stage Dockerfile
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
- Review the generated output against industry best practices for devops.
|
|
28
|
-
- Ensure the result perfectly resolves the user's request without omissions.
|
|
25
|
+
Separate the **build** stage (has compilers, dev deps, source code) from the **runtime** stage (has only what runs).
|
|
29
26
|
|
|
30
|
-
|
|
27
|
+
**Node.js example:**
|
|
28
|
+
```dockerfile
|
|
29
|
+
# syntax=docker/dockerfile:1
|
|
30
|
+
FROM node:20.11-alpine3.19 AS builder
|
|
31
|
+
WORKDIR /app
|
|
32
|
+
COPY package*.json ./
|
|
33
|
+
RUN npm ci --ignore-scripts
|
|
34
|
+
COPY . .
|
|
35
|
+
RUN npm run build
|
|
31
36
|
|
|
32
|
-
|
|
37
|
+
FROM node:20.11-alpine3.19 AS runtime
|
|
38
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
39
|
+
WORKDIR /app
|
|
40
|
+
COPY --from=builder --chown=appuser:appgroup /app/dist ./dist
|
|
41
|
+
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
|
|
42
|
+
USER appuser
|
|
43
|
+
EXPOSE 3000
|
|
44
|
+
CMD ["node", "dist/index.js"]
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
**Go (scratch final stage for minimal attack surface):**
|
|
48
|
+
```dockerfile
|
|
49
|
+
FROM golang:1.22-alpine3.19 AS builder
|
|
50
|
+
WORKDIR /app
|
|
51
|
+
COPY go.* ./
|
|
52
|
+
RUN go mod download
|
|
53
|
+
COPY . .
|
|
54
|
+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o server ./cmd/server
|
|
55
|
+
|
|
56
|
+
FROM scratch AS runtime
|
|
57
|
+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
58
|
+
COPY --from=builder /app/server /server
|
|
59
|
+
EXPOSE 8080
|
|
60
|
+
ENTRYPOINT ["/server"]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Scratch image hidden deps**: The `scratch` base has no timezone database, no `/etc/nsswitch.conf`, and no `/etc/passwd`. If your binary calls `time.LoadLocation()`, DNS resolves via NSS, or reads user info, copy the needed files explicitly:
|
|
64
|
+
```dockerfile
|
|
65
|
+
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
|
|
66
|
+
COPY --from=builder /etc/passwd /etc/passwd
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### 3. Pin Base Images to Digests
|
|
70
|
+
|
|
71
|
+
Tags are mutable. Use digests for reproducibility:
|
|
72
|
+
```dockerfile
|
|
73
|
+
FROM node:20.11-alpine3.19@sha256:a8b5c... AS builder
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Get the digest: `docker pull node:20.11-alpine3.19 && docker inspect node:20.11-alpine3.19 --format='{{index .RepoDigests 0}}'`
|
|
77
|
+
|
|
78
|
+
### 4. Write .dockerignore
|
|
79
|
+
|
|
80
|
+
Exclude: `.git`, `.env*`, `node_modules`, `__pycache__`, `dist`, `build`, `coverage`, `*.log`, `docs/`, `tests/`. This prevents secrets and large dirs from entering the build context.
|
|
81
|
+
|
|
82
|
+
### 5. Scan with Trivy
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
trivy image --severity HIGH,CRITICAL --exit-code 1 myapp:latest
|
|
86
|
+
trivy config --exit-code 1 ./Dockerfile
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Fix CVEs by bumping to a newer base image, or removing packages that introduced them. Prefer a newer base over `apt-get upgrade -y` in the build stage.
|
|
90
|
+
|
|
91
|
+
### 6. Write Docker Compose for Local Development
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
# compose.yml (Docker Compose v2 — preferred over docker-compose.yml)
|
|
95
|
+
services:
|
|
96
|
+
app:
|
|
97
|
+
build:
|
|
98
|
+
context: .
|
|
99
|
+
target: runtime
|
|
100
|
+
ports:
|
|
101
|
+
- "3000:3000"
|
|
102
|
+
environment:
|
|
103
|
+
- NODE_ENV=development
|
|
104
|
+
- DATABASE_URL=postgresql://dev:dev@db:5432/myapp
|
|
105
|
+
depends_on:
|
|
106
|
+
db:
|
|
107
|
+
condition: service_healthy
|
|
108
|
+
restart: unless-stopped
|
|
109
|
+
|
|
110
|
+
db:
|
|
111
|
+
image: postgres:16.2-alpine3.19@sha256:...
|
|
112
|
+
environment:
|
|
113
|
+
POSTGRES_USER: dev
|
|
114
|
+
POSTGRES_PASSWORD: dev
|
|
115
|
+
POSTGRES_DB: myapp
|
|
116
|
+
volumes:
|
|
117
|
+
- postgres_data:/var/lib/postgresql/data
|
|
118
|
+
healthcheck:
|
|
119
|
+
test: ["CMD-SHELL", "pg_isready -U dev -d myapp"]
|
|
120
|
+
interval: 10s
|
|
121
|
+
timeout: 5s
|
|
122
|
+
retries: 5
|
|
123
|
+
start_period: 30s # grace period before health failures count; use for slow-starting services
|
|
124
|
+
|
|
125
|
+
volumes:
|
|
126
|
+
postgres_data:
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### 7. Helm Chart Structure (Kubernetes)
|
|
130
|
+
|
|
131
|
+
Standard layout: `Chart.yaml`, `values.yaml`, `values.prod.yaml`, `templates/{deployment,service,ingress,configmap,secret,hpa}.yaml`. Always set `resources.requests`/`limits` and `securityContext.runAsNonRoot: true`, `readOnlyRootFilesystem: true`.
|
|
132
|
+
|
|
133
|
+
**Note on `pg_isready`**: `pg_isready` only checks that Postgres accepts connections — it does not verify schema migrations have run or that the DB is ready for DDL. For services that run migrations on startup, add a retry loop in the app or use an init container.
|
|
134
|
+
|
|
135
|
+
## Output Format
|
|
136
|
+
|
|
137
|
+
Provide:
|
|
138
|
+
1. The complete Dockerfile with inline comments explaining non-obvious choices
|
|
139
|
+
2. The `.dockerignore` file
|
|
140
|
+
3. `compose.yml` if local dev setup was requested
|
|
141
|
+
4. Trivy scan command to run, and how to interpret results
|
|
142
|
+
|
|
143
|
+
## Edge Cases
|
|
144
|
+
|
|
145
|
+
**BuildKit prerequisite**: `RUN --mount=type=secret`, `RUN --mount=type=cache`, and `# syntax=docker/dockerfile:1` directives require BuildKit. Enable with `DOCKER_BUILDKIT=1 docker build .` or use `docker buildx build .` (BuildKit is the default in Docker 23+). Without BuildKit, these directives are silently ignored or cause build errors.
|
|
146
|
+
|
|
147
|
+
**Secrets in build args**: Never use `ARG` for secrets — they appear in `docker history`. Use `--secret` with BuildKit:
|
|
148
|
+
```dockerfile
|
|
149
|
+
RUN --mount=type=secret,id=npm_token \
|
|
150
|
+
NPM_TOKEN=$(cat /run/secrets/npm_token) npm install
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Large monorepo context**: If `docker build` is slow due to context size, add `# syntax=docker/dockerfile:1` and use `--mount=type=cache` for package manager caches:
|
|
154
|
+
```dockerfile
|
|
155
|
+
RUN --mount=type=cache,target=/root/.npm npm ci
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**ARM64 / multi-platform images**: Build with `docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest --push .` and ensure base images support both platforms.
|
package/DocuGenie/skill.md
CHANGED
|
@@ -1,32 +1,138 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: docugenie
|
|
3
|
-
description:
|
|
3
|
+
description: Writes OpenAPI 3.x specs, JSDoc/TSDoc/Google-style docstrings, and developer guides with working code examples. Use when a user asks to document an API, write docstrings, generate a README, or create a developer guide.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# DocuGenie
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Generate documentation that developers actually use: accurate OpenAPI specs, docstrings that IDEs render, and guides with copy-paste-ready examples. Documentation must match the code — never invent behavior.
|
|
11
11
|
|
|
12
12
|
## Workflow
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### 1. Identify What Needs Documenting
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
16
|
+
Determine the output type:
|
|
17
|
+
- **REST API** → OpenAPI 3.x YAML/JSON spec
|
|
18
|
+
- **Function/class/module** → Language-appropriate docstrings
|
|
19
|
+
- **SDK or library** → Developer guide with quickstart + reference
|
|
20
|
+
- **Internal system** → Architecture doc (ADR or C4-level description)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
- Apply the core logic of DocuGenie 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.
|
|
22
|
+
Read the actual source code before writing anything. Never document assumed behavior.
|
|
25
23
|
|
|
26
|
-
###
|
|
27
|
-
- Review the generated output against industry best practices for docs.
|
|
28
|
-
- Ensure the result perfectly resolves the user's request without omissions.
|
|
24
|
+
### 2. Write OpenAPI 3.x Specs
|
|
29
25
|
|
|
30
|
-
|
|
26
|
+
Every endpoint needs: summary, description, parameters, request body schema, and all response schemas including error cases.
|
|
31
27
|
|
|
32
|
-
|
|
28
|
+
```yaml
|
|
29
|
+
openapi: "3.1.0"
|
|
30
|
+
info:
|
|
31
|
+
title: Payments API
|
|
32
|
+
version: "2.0.0"
|
|
33
|
+
paths:
|
|
34
|
+
/payments:
|
|
35
|
+
post:
|
|
36
|
+
operationId: createPayment
|
|
37
|
+
summary: Create a payment
|
|
38
|
+
description: Returns immediately with `pending` status. Listen to `payment.succeeded` webhook for confirmation.
|
|
39
|
+
tags: [Payments]
|
|
40
|
+
requestBody:
|
|
41
|
+
required: true
|
|
42
|
+
content:
|
|
43
|
+
application/json:
|
|
44
|
+
schema: { $ref: '#/components/schemas/CreatePaymentRequest' }
|
|
45
|
+
responses:
|
|
46
|
+
"201":
|
|
47
|
+
content:
|
|
48
|
+
application/json:
|
|
49
|
+
schema: { $ref: '#/components/schemas/Payment' }
|
|
50
|
+
"400": { description: Invalid request body }
|
|
51
|
+
"422": { description: Payment method declined }
|
|
52
|
+
components:
|
|
53
|
+
schemas:
|
|
54
|
+
CreatePaymentRequest:
|
|
55
|
+
type: object
|
|
56
|
+
required: [amount_cents, currency, payment_method_id]
|
|
57
|
+
properties:
|
|
58
|
+
amount_cents: { type: integer, minimum: 1, description: "Cents (e.g. 4999 = $49.99)" }
|
|
59
|
+
currency: { type: string, pattern: "^[A-Z]{3}$", description: ISO 4217 }
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Always define reusable schemas in `components/schemas`. Use `$ref` to avoid repetition. Document every error status code the code actually returns.
|
|
63
|
+
|
|
64
|
+
**Content negotiation**: When the same endpoint returns multiple formats, list each under `content` separately:
|
|
65
|
+
```yaml
|
|
66
|
+
responses:
|
|
67
|
+
"200":
|
|
68
|
+
content:
|
|
69
|
+
application/json:
|
|
70
|
+
schema: { $ref: '#/components/schemas/Payment' }
|
|
71
|
+
text/csv:
|
|
72
|
+
schema: { type: string }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**API versioning**: Prefer separate spec files per major version (`openapi-v1.yaml`, `openapi-v2.yaml`) over embedding version in `info.version` alone — separate files enable per-version tooling, linting, and SDK generation without cross-version pollution.
|
|
76
|
+
|
|
77
|
+
### 3. Write Language-Appropriate Docstrings
|
|
78
|
+
|
|
79
|
+
**Python (Google style):**
|
|
80
|
+
```python
|
|
81
|
+
def calculate_discount(
|
|
82
|
+
user: User,
|
|
83
|
+
cart_total: float,
|
|
84
|
+
coupon_code: str | None = None,
|
|
85
|
+
) -> float:
|
|
86
|
+
"""Calculate the discount amount for a user's cart.
|
|
87
|
+
|
|
88
|
+
Applies tier-based discounts first, then coupon discounts additively.
|
|
89
|
+
The total discount is capped at 50% of cart_total.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
user: The authenticated user. Must have a valid `tier` attribute.
|
|
93
|
+
cart_total: Pre-tax cart value in dollars. Must be >= 0.
|
|
94
|
+
coupon_code: Optional promotional code. Invalid codes are silently
|
|
95
|
+
ignored — no exception is raised.
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
The discount amount in dollars, rounded to 2 decimal places.
|
|
99
|
+
Returns 0.0 if no discount applies.
|
|
100
|
+
|
|
101
|
+
Side Effects:
|
|
102
|
+
Increments the coupon redemption counter in the database if coupon_code is valid.
|
|
103
|
+
Emits a `discount_applied` analytics event.
|
|
104
|
+
|
|
105
|
+
Raises:
|
|
106
|
+
ValueError: If cart_total is negative.
|
|
107
|
+
DatabaseError: If the coupon lookup fails due to a connection error.
|
|
108
|
+
|
|
109
|
+
Example:
|
|
110
|
+
>>> user = User(tier="gold")
|
|
111
|
+
>>> calculate_discount(user, 100.0, coupon_code="SAVE10")
|
|
112
|
+
25.0 # 15% gold tier + 10% coupon
|
|
113
|
+
"""
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**TypeScript (TSDoc)**: Use `@param`, `@returns`, `@throws {@link ErrorType}`, and `@example` tags. Document each pagination/filter option individually. Ensure `@throws` lists every error the implementation can raise, not just the happy path.
|
|
117
|
+
|
|
118
|
+
### 4. Write a Developer Guide
|
|
119
|
+
|
|
120
|
+
Structure: What it does → Prerequisites (exact versions) → Installation (copy-paste) → Quickstart (minimal working example) → Core concepts → Common recipes (top 3-5) → Configuration reference table → Troubleshooting (top 3 errors with cause + fix).
|
|
121
|
+
|
|
122
|
+
### 5. Validate the Documentation
|
|
123
|
+
|
|
124
|
+
Run `redoc-cli lint openapi.yaml` or `swagger-parser` to validate the spec. Run all code examples against the current codebase. Confirm every parameter, return type, and error code in docstrings matches the implementation.
|
|
125
|
+
|
|
126
|
+
## Output Format
|
|
127
|
+
|
|
128
|
+
- OpenAPI: valid YAML in a fenced code block, ready to paste into a file
|
|
129
|
+
- Docstrings: inserted directly into the function/class, preserving existing code
|
|
130
|
+
- Developer guides: Markdown, with working code blocks and a clear header hierarchy
|
|
131
|
+
|
|
132
|
+
## Edge Cases
|
|
133
|
+
|
|
134
|
+
**Undocumented error paths**: When the code raises errors not yet documented, list them in the docstring and add a corresponding `4xx`/`5xx` response to the OpenAPI spec. Do not silently omit them.
|
|
135
|
+
|
|
136
|
+
**Overloaded functions/polymorphic endpoints**: Document each distinct call signature separately using `@overload` in Python (with `typing`) or separate `operationId` paths in OpenAPI. Combining them into one vague description creates confusion.
|
|
137
|
+
|
|
138
|
+
**Deprecated APIs**: Mark with `@deprecated` in JSDoc/TSDoc, `deprecated: true` in OpenAPI, and include the replacement: "Deprecated since v2.3. Use `createPaymentV2` instead."
|
package/EdgeGuard/skill.md
CHANGED
|
@@ -1,32 +1,160 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: edgeguard
|
|
3
|
-
description:
|
|
3
|
+
description: Systematically finds edge cases using boundary value analysis, equivalence partitioning, property-based testing (Hypothesis/fast-check), fuzzing, and mutation testing. Use when a user asks to find edge cases, stress-test logic, or make tests more robust.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# EdgeGuard
|
|
7
7
|
|
|
8
8
|
## Overview
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Go beyond happy-path tests to find the inputs that break things. Use structured techniques — not intuition — to systematically enumerate edge cases, then verify them with property-based tests, fuzz tests, and mutation testing.
|
|
11
11
|
|
|
12
12
|
## Workflow
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
### 1. Boundary Value Analysis (BVA)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
16
|
+
For every numeric, string-length, or date input, test at:
|
|
17
|
+
- The exact minimum allowed value
|
|
18
|
+
- Minimum - 1 (just below valid range)
|
|
19
|
+
- Minimum + 1 (just above minimum)
|
|
20
|
+
- A nominal value in the middle
|
|
21
|
+
- Maximum - 1
|
|
22
|
+
- The exact maximum allowed value
|
|
23
|
+
- Maximum + 1 (just above valid range)
|
|
20
24
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
```python
|
|
26
|
+
# Function: def set_age(age: int) — valid range 0..150
|
|
27
|
+
# BVA test cases:
|
|
28
|
+
test_cases = [-1, 0, 1, 75, 149, 150, 151]
|
|
29
|
+
```
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
- Ensure the result perfectly resolves the user's request without omissions.
|
|
31
|
+
For string lengths: empty string `""`, one character, max length, max length + 1.
|
|
32
|
+
For collections: empty list, single element, two elements, at or near the size limit.
|
|
29
33
|
|
|
30
|
-
|
|
34
|
+
### 2. Equivalence Partitioning
|
|
31
35
|
|
|
32
|
-
-
|
|
36
|
+
Divide inputs into classes where the code behaves identically, then test one value from each class. For an HTTP status-code classifier: one test each for `[100-199]`, `[200-299]`, `[300-399]`, `[400-499]`, `[500-599]`, `[<100]`, `[>599]`, non-integer. Test one value per partition: `101, 200, 301, 404, 503, 99, 600, "abc"`.
|
|
37
|
+
|
|
38
|
+
### 3. Property-Based Testing
|
|
39
|
+
|
|
40
|
+
Write tests that assert invariants hold for thousands of randomly generated inputs, not just hand-picked ones.
|
|
41
|
+
|
|
42
|
+
**Python with Hypothesis:**
|
|
43
|
+
```python
|
|
44
|
+
from hypothesis import given, strategies as st, assume
|
|
45
|
+
|
|
46
|
+
@given(st.lists(st.integers()))
|
|
47
|
+
def test_sort_preserves_length(lst):
|
|
48
|
+
assert len(sorted(lst)) == len(lst)
|
|
49
|
+
|
|
50
|
+
@given(st.integers(min_value=0), st.integers(min_value=0))
|
|
51
|
+
def test_add_is_commutative(a, b):
|
|
52
|
+
assert add(a, b) == add(b, a)
|
|
53
|
+
|
|
54
|
+
@given(st.text(min_size=1, max_size=100))
|
|
55
|
+
def test_slugify_is_idempotent(text):
|
|
56
|
+
assume(text.strip()) # skip pure-whitespace
|
|
57
|
+
slug = slugify(text)
|
|
58
|
+
assert slugify(slug) == slug
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**TypeScript/JavaScript with fast-check:**
|
|
63
|
+
```typescript
|
|
64
|
+
import fc from 'fast-check';
|
|
65
|
+
test('reverse is involution', () => {
|
|
66
|
+
fc.assert(fc.property(fc.array(fc.integer()), (arr) => {
|
|
67
|
+
expect(reverse(reverse(arr))).toEqual(arr);
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 4. Fuzz Testing
|
|
73
|
+
|
|
74
|
+
Feed random, malformed, or adversarial input to find crashes and panics.
|
|
75
|
+
|
|
76
|
+
**Python with Atheris:**
|
|
77
|
+
```python
|
|
78
|
+
import atheris
|
|
79
|
+
import sys
|
|
80
|
+
|
|
81
|
+
def TestOneInput(data):
|
|
82
|
+
fdp = atheris.FuzzedDataProvider(data)
|
|
83
|
+
text = fdp.ConsumeUnicodeNoSurrogates(100)
|
|
84
|
+
try:
|
|
85
|
+
parse_user_input(text)
|
|
86
|
+
except ValueError:
|
|
87
|
+
pass # expected — not a bug
|
|
88
|
+
# Any other exception is a bug and will be reported
|
|
89
|
+
|
|
90
|
+
atheris.Setup(sys.argv, TestOneInput)
|
|
91
|
+
atheris.Fuzz()
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Go:**
|
|
95
|
+
```go
|
|
96
|
+
func FuzzParseConfig(f *testing.F) {
|
|
97
|
+
f.Add([]byte(`{"key":"value"}`))
|
|
98
|
+
f.Fuzz(func(t *testing.T, data []byte) {
|
|
99
|
+
_, err := ParseConfig(data)
|
|
100
|
+
if err != nil {
|
|
101
|
+
return // expected
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
Run: `go test -fuzz=FuzzParseConfig -fuzztime=60s`
|
|
107
|
+
|
|
108
|
+
### 5. Mutation Testing
|
|
109
|
+
|
|
110
|
+
Verify that your tests catch real bugs by deliberately introducing mutations and checking if tests fail.
|
|
111
|
+
|
|
112
|
+
**Python with mutmut:**
|
|
113
|
+
```bash
|
|
114
|
+
mutmut run --paths-to-mutate=src/
|
|
115
|
+
mutmut results # shows surviving mutants (= tests that missed a bug)
|
|
116
|
+
mutmut show 23 # shows the specific mutation that survived
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**JavaScript with Stryker:**
|
|
120
|
+
```bash
|
|
121
|
+
npx stryker run
|
|
122
|
+
# Opens HTML report showing which mutants survived
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
A surviving mutant means: "I changed the code in a plausible way and no test caught it." Write a test that kills each surviving mutant.
|
|
126
|
+
|
|
127
|
+
Target: mutation score >= 80%.
|
|
128
|
+
|
|
129
|
+
**Mutation testing cost management**: Full mutation runs are slow. Scope to changed files only: `mutmut run --paths-to-mutate=src/changed_module.py`. Schedule full runs nightly in CI, not on every PR. Use `--parallel` (Stryker) or `mutmut run --no-progress` with `xdist` workers to parallelize execution.
|
|
130
|
+
|
|
131
|
+
### 6. High-Value Edge Cases by Type
|
|
132
|
+
|
|
133
|
+
| Type | Key cases |
|
|
134
|
+
|------|-----------|
|
|
135
|
+
| Strings | `""`, `" "`, null bytes `"\0"`, Unicode surrogates, >1MB, SQL injection, path traversal `../../` |
|
|
136
|
+
| Numbers | `0`, `-0`, `NaN`, `Infinity`, `MAX_SAFE_INTEGER+1`, very small floats near zero |
|
|
137
|
+
| Collections | empty, single element, all-identical, sorted asc/desc, null elements |
|
|
138
|
+
| Dates | Feb 29, DST spring-forward (2:30 AM), year 2038 (32-bit Unix overflow), midnight |
|
|
139
|
+
| Concurrency | simultaneous access, duplicate requests (idempotency), partial failure mid-transaction |
|
|
140
|
+
|
|
141
|
+
## Output Format
|
|
142
|
+
|
|
143
|
+
For each function or module analyzed, provide:
|
|
144
|
+
|
|
145
|
+
1. **BVA table**: input → expected output/behavior
|
|
146
|
+
2. **Equivalence classes**: list each partition and which value tests it
|
|
147
|
+
3. **Property tests**: `@given` or `fc.property` test file
|
|
148
|
+
4. **Edge case checklist**: domain-specific list of cases tried
|
|
149
|
+
|
|
150
|
+
## Edge Cases of the Technique Itself
|
|
151
|
+
|
|
152
|
+
**Hypothesis CI reproducibility**: Hypothesis stores found examples in `.hypothesis/`. Commit this directory so CI reproduces failures deterministically. Pin the seed for scheduled runs: `pytest --hypothesis-seed=0`. Without a fixed seed, flaky Hypothesis failures are hard to reproduce locally.
|
|
153
|
+
|
|
154
|
+
**Fuzz testing cleanup**: Fuzz corpora and crash inputs accumulate in temp directories. Use `tmp_path` (pytest) or `TMPDIR` pointed at a ramdisk to avoid disk fill on long runs. Always set `fuzztime` limits in CI: `go test -fuzz=. -fuzztime=60s`. Clean up artifacts in post-run CI steps.
|
|
155
|
+
|
|
156
|
+
**Hypothesis finding a counterexample unexpectedly**: When Hypothesis fails, it shrinks the input to the minimal reproducing case. Read the `@example` decorator it prints — add it as a regression test so this specific case always runs.
|
|
157
|
+
|
|
158
|
+
**Mutation testing on I/O-heavy code**: Mutmut/Stryker work best on pure logic. For code with database calls or HTTP, use the mutation score only on the business logic layer, not on infrastructure adapters.
|
|
159
|
+
|
|
160
|
+
**Infinite loops from property tests**: If the code under test can loop indefinitely given certain inputs, wrap it with a timeout (`@settings(deadline=timedelta(milliseconds=500))` in Hypothesis) rather than letting CI hang.
|