agentscamp 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +64 -0
- package/content/agents/accessibility-auditor.md +66 -0
- package/content/agents/agent-architect.md +65 -0
- package/content/agents/agent-reliability-reviewer.md +40 -0
- package/content/agents/agent-tool-integration-engineer.md +38 -0
- package/content/agents/api-architect.md +84 -0
- package/content/agents/backend-developer.md +92 -0
- package/content/agents/browser-agent-engineer.md +37 -0
- package/content/agents/cloud-architect.md +72 -0
- package/content/agents/code-reviewer.md +69 -0
- package/content/agents/data-engineer.md +67 -0
- package/content/agents/data-scientist.md +79 -0
- package/content/agents/debugger.md +89 -0
- package/content/agents/dependency-manager.md +64 -0
- package/content/agents/devops-engineer.md +94 -0
- package/content/agents/documentation-engineer.md +52 -0
- package/content/agents/finetuning-engineer.md +43 -0
- package/content/agents/frontend-developer.md +78 -0
- package/content/agents/git-github-expert.md +66 -0
- package/content/agents/golang-pro.md +72 -0
- package/content/agents/graphql-architect.md +85 -0
- package/content/agents/kubernetes-specialist.md +87 -0
- package/content/agents/llm-cost-optimizer.md +39 -0
- package/content/agents/llm-evaluation-engineer.md +42 -0
- package/content/agents/llm-inference-engineer.md +42 -0
- package/content/agents/llm-integration-engineer.md +39 -0
- package/content/agents/llm-observability-engineer.md +41 -0
- package/content/agents/mcp-server-engineer.md +43 -0
- package/content/agents/ml-engineer.md +67 -0
- package/content/agents/mobile-developer.md +89 -0
- package/content/agents/performance-engineer.md +79 -0
- package/content/agents/postgres-migration-engineer.md +42 -0
- package/content/agents/prompt-engineer.md +58 -0
- package/content/agents/prompt-injection-auditor.md +42 -0
- package/content/agents/python-pro.md +77 -0
- package/content/agents/rag-pipeline-engineer.md +42 -0
- package/content/agents/react-specialist.md +83 -0
- package/content/agents/refactoring-specialist.md +78 -0
- package/content/agents/retrieval-engineer.md +41 -0
- package/content/agents/rust-pro.md +89 -0
- package/content/agents/security-auditor.md +78 -0
- package/content/agents/sql-pro.md +53 -0
- package/content/agents/sre-engineer.md +66 -0
- package/content/agents/system-architect.md +77 -0
- package/content/agents/terraform-specialist.md +73 -0
- package/content/agents/test-engineer.md +79 -0
- package/content/agents/typescript-pro.md +82 -0
- package/content/agents/vector-search-engineer.md +43 -0
- package/content/agents/voice-agent-engineer.md +38 -0
- package/content/agents/workflow-orchestrator.md +70 -0
- package/content/commands/add-docstrings.md +92 -0
- package/content/commands/add-human-approval.md +40 -0
- package/content/commands/add-mcp-server.md +50 -0
- package/content/commands/add-streaming-endpoint.md +34 -0
- package/content/commands/benchmark-rerankers.md +44 -0
- package/content/commands/breakdown-task.md +86 -0
- package/content/commands/commit.md +117 -0
- package/content/commands/create-pr.md +109 -0
- package/content/commands/db-migrate.md +47 -0
- package/content/commands/explain-code.md +71 -0
- package/content/commands/explain-error.md +98 -0
- package/content/commands/extract-function.md +107 -0
- package/content/commands/find-bug.md +93 -0
- package/content/commands/fix-failing-test.md +106 -0
- package/content/commands/new-component.md +119 -0
- package/content/commands/plan-feature.md +71 -0
- package/content/commands/profile-postgres-queries.md +41 -0
- package/content/commands/red-team-llm.md +45 -0
- package/content/commands/refactor.md +82 -0
- package/content/commands/review-pr.md +101 -0
- package/content/commands/run-evals.md +34 -0
- package/content/commands/scaffold-pgvector-schema.md +42 -0
- package/content/commands/scaffold-vllm-config.md +44 -0
- package/content/commands/security-scan.md +129 -0
- package/content/commands/set-perf-budget.md +47 -0
- package/content/commands/setup-claude-ci.md +60 -0
- package/content/commands/sync-branch.md +138 -0
- package/content/commands/update-readme.md +108 -0
- package/content/commands/write-tests.md +81 -0
- package/content/manifest.json +1709 -0
- package/content/skills/adr-writer.md +90 -0
- package/content/skills/branch-rebaser.md +86 -0
- package/content/skills/bundle-analyzer.md +77 -0
- package/content/skills/changelog-from-prs.md +81 -0
- package/content/skills/chunking-strategy-optimizer.md +34 -0
- package/content/skills/claude-settings-auditor.md +38 -0
- package/content/skills/conventional-commits.md +80 -0
- package/content/skills/coverage-gap-finder.md +72 -0
- package/content/skills/dead-code-finder.md +65 -0
- package/content/skills/dependency-audit.md +64 -0
- package/content/skills/embedding-index-tuner.md +34 -0
- package/content/skills/embedding-set-inspector.md +34 -0
- package/content/skills/finetune-dataset-builder.md +33 -0
- package/content/skills/graphrag-scaffolder.md +39 -0
- package/content/skills/hook-writer.md +39 -0
- package/content/skills/human-in-the-loop-gate.md +33 -0
- package/content/skills/llm-as-judge-scorer.md +33 -0
- package/content/skills/llm-eval-suite-scaffolder.md +30 -0
- package/content/skills/llm-guardrails-designer.md +33 -0
- package/content/skills/llm-output-schema-generator.md +32 -0
- package/content/skills/mcp-server-scaffolder.md +33 -0
- package/content/skills/mock-data-factory.md +75 -0
- package/content/skills/multimodal-document-extractor.md +39 -0
- package/content/skills/openapi-doc-writer.md +88 -0
- package/content/skills/plugin-scaffolder.md +38 -0
- package/content/skills/postgres-index-strategist.md +38 -0
- package/content/skills/pr-description.md +87 -0
- package/content/skills/prompt-cache-optimizer.md +34 -0
- package/content/skills/prompt-optimizer.md +40 -0
- package/content/skills/prompt-pii-redactor.md +33 -0
- package/content/skills/provider-fallback-wrapper.md +33 -0
- package/content/skills/qlora-finetune-runner.md +33 -0
- package/content/skills/readme-generator.md +84 -0
- package/content/skills/secret-scanner.md +65 -0
- package/content/skills/sql-optimizer.md +77 -0
- package/content/skills/test-scaffolder.md +74 -0
- package/content/skills/tool-definition-generator.md +33 -0
- package/content/skills/web-research-pipeline.md +39 -0
- package/dist/index.js +384 -0
- package/package.json +44 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Fetch and rebase the current branch onto its base, resolving conflicts and verifying the build."
|
|
3
|
+
argument-hint: "[base branch]"
|
|
4
|
+
allowed-tools: "Bash, Read, Edit"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Bring the current feature branch up to date by rebasing it onto its base. Follow the steps below in order. Stop and report rather than improvise if anything is ambiguous — a rebase rewrites history, so correctness matters more than speed.
|
|
8
|
+
|
|
9
|
+
## Scope
|
|
10
|
+
|
|
11
|
+
If `$ARGUMENTS` is provided, treat it as the name of the base branch to rebase onto — supply a bare branch name without a remote prefix (for example `main`, `develop`, or `release-2.0`). If `$ARGUMENTS` is empty, auto-detect the base: prefer the remote's default branch, falling back to `main`, then `master`. Never assume the base — confirm which one you resolved before rebasing.
|
|
12
|
+
|
|
13
|
+
## Step 1 — Confirm a clean working tree
|
|
14
|
+
|
|
15
|
+
A rebase must start from a clean tree. Check first.
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
git status --short
|
|
19
|
+
git rev-parse --abbrev-ref HEAD
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
- If `git status --short` prints nothing, the tree is clean — continue.
|
|
23
|
+
- If there are uncommitted changes, do **not** proceed silently. Either commit them first (use the `commit` workflow) or stash them, and tell the user which you did:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
git stash push -u -m "sync-branch: pre-rebase stash"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
> [!WARNING]
|
|
30
|
+
> If you stash, you must `git stash pop` after the rebase completes (Step 5). Leaving work stashed is a silent way to lose changes. If popping the stash itself conflicts, stop and hand it back to the user.
|
|
31
|
+
|
|
32
|
+
> [!NOTE]
|
|
33
|
+
> Confirm you are not on the base branch itself. Rebasing `main` onto `main` is a no-op at best; if `HEAD` equals the resolved base, stop and report — there is nothing to sync.
|
|
34
|
+
|
|
35
|
+
## Step 2 — Fetch the latest base
|
|
36
|
+
|
|
37
|
+
Update remote refs so you rebase onto current upstream, not a stale local copy.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git fetch --all --prune
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Now resolve the base branch and record where you started, so you can recover if anything goes wrong.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# The remote's default branch, used when $ARGUMENTS is empty
|
|
47
|
+
git remote show origin | sed -n 's/.*HEAD branch: //p'
|
|
48
|
+
|
|
49
|
+
# Where HEAD is right now — note this hash for recovery
|
|
50
|
+
git rev-parse HEAD
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Pick the base in this priority order: `$ARGUMENTS` → remote default branch → `main` → `master`. State the chosen base explicitly before continuing.
|
|
54
|
+
|
|
55
|
+
## Step 3 — Rebase onto the base
|
|
56
|
+
|
|
57
|
+
Rebase the current branch onto the **remote-tracking** ref so you incorporate the freshly fetched commits.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# Replace <base> with the branch resolved in Step 2
|
|
61
|
+
git rebase origin/<base>
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
> [!NOTE]
|
|
65
|
+
> Normalize the ref before substituting. If the resolved base already begins with a remote name such as `origin/`, use it verbatim; otherwise prefix `origin/`. This avoids producing an invalid ref like `origin/origin/<base>`.
|
|
66
|
+
|
|
67
|
+
If the rebase applies cleanly, skip to Step 4. If it stops on a conflict, move to conflict resolution below.
|
|
68
|
+
|
|
69
|
+
### Resolving conflicts
|
|
70
|
+
|
|
71
|
+
For each conflicted file, understand **both** sides before editing — do not blindly accept one.
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
# See which files are conflicted (covers all conflict types: UU, AA, DD, AU, etc.)
|
|
75
|
+
git diff --name-only --diff-filter=U
|
|
76
|
+
|
|
77
|
+
# Inspect a specific conflict, both sides at once
|
|
78
|
+
git diff <file>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
- `<<<<<<< HEAD` is the version from the base you are rebasing onto.
|
|
82
|
+
- `>>>>>>> <commit>` is the change from the commit currently being replayed.
|
|
83
|
+
|
|
84
|
+
Read the surrounding code to grasp intent on each side, then write a resolution that preserves *both* behaviors where they are independent, or the correct one where they genuinely conflict. After editing a file to a coherent state:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
git add <file>
|
|
88
|
+
git rebase --continue
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Repeat until the rebase finishes. If a conflict is genuinely undecidable without product context, abort cleanly and hand it back rather than guessing:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
git rebase --abort # restores the pre-rebase state from Step 2
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> [!WARNING]
|
|
98
|
+
> Never resolve a conflict by deleting code you do not understand. If a hunk looks load-bearing and you cannot determine which side is correct, stop and ask the user.
|
|
99
|
+
|
|
100
|
+
## Step 4 — Verify the build and tests
|
|
101
|
+
|
|
102
|
+
A rebase can produce code that merges textually but breaks logically. Prove the branch still works.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
# Adapt to the repo's actual scripts
|
|
106
|
+
npm run build
|
|
107
|
+
npm test
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
If the build or tests fail, the failure was introduced by the rebase — investigate and fix it now, then re-run until green. Do not report success on a red build.
|
|
111
|
+
|
|
112
|
+
## Step 5 — Restore and report
|
|
113
|
+
|
|
114
|
+
If you stashed in Step 1, restore that work now:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
git stash pop
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Then summarize the outcome:
|
|
121
|
+
|
|
122
|
+
- The base branch you rebased onto and how many commits it pulled in.
|
|
123
|
+
- How many of your commits were replayed.
|
|
124
|
+
- Every conflict you resolved and the reasoning for each resolution.
|
|
125
|
+
- The build/test status (must be green).
|
|
126
|
+
- Whether a stash was used and successfully popped.
|
|
127
|
+
|
|
128
|
+
> [!WARNING]
|
|
129
|
+
> Rebasing rewrites commit hashes, so the local branch and its remote now disagree. Do **not** force-push a shared branch without the user's explicit confirmation. When they confirm, prefer the safe form:
|
|
130
|
+
>
|
|
131
|
+
> ```bash
|
|
132
|
+
> git push --force-with-lease
|
|
133
|
+
> ```
|
|
134
|
+
>
|
|
135
|
+
> `--force-with-lease` refuses to overwrite work someone else pushed while you were rebasing; a bare `--force` does not. Never push at all unless the user asks.
|
|
136
|
+
|
|
137
|
+
> [!NOTE]
|
|
138
|
+
> If the completed rebase turns out wrong (it finished, but the result is semantically broken), recover with `git reset --hard <the HEAD hash recorded in Step 2>`. This is distinct from `git rebase --abort`, which only works while a rebase is still in progress.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Update the README to reflect the current scripts, structure, and features of the repo."
|
|
3
|
+
argument-hint: "[section or focus]"
|
|
4
|
+
allowed-tools: "Read, Grep, Glob, Bash, Edit, Write"
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Bring the README back in sync with the code. Your job is to find where the README has drifted from reality and correct only those parts — not to rewrite the document. Every claim you keep or add must be backed by something in the repository.
|
|
8
|
+
|
|
9
|
+
## Scope
|
|
10
|
+
|
|
11
|
+
`$ARGUMENTS` narrows what you audit.
|
|
12
|
+
|
|
13
|
+
- A section name (`Installation`, `Scripts`, `Configuration`) means review and fix that section only, leaving the rest untouched.
|
|
14
|
+
- A focus area (`scripts`, `env vars`, `project structure`, `badges`) means reconcile that aspect across the whole README.
|
|
15
|
+
- A path hint (`packages/api`) means update the README that governs that subtree.
|
|
16
|
+
|
|
17
|
+
If `$ARGUMENTS` is empty, audit the entire top-level README end to end.
|
|
18
|
+
|
|
19
|
+
> [!NOTE]
|
|
20
|
+
> Do not invent commands, scripts, env vars, or features that are not present in the repo. The README must describe what the code actually does today, not what it should do or once did.
|
|
21
|
+
|
|
22
|
+
## Step 1 — Read the current README
|
|
23
|
+
|
|
24
|
+
Find and read every README before changing anything.
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Top-level and nested READMEs
|
|
28
|
+
ls README* 2>/dev/null
|
|
29
|
+
find . -iname 'readme*' -not -path '*/node_modules/*' -not -path '*/.git/*'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Read the target README in full. Note its existing headings, ordering, tone, and formatting conventions — you will preserve all of them. Inventory every concrete claim it makes: commands, file paths, ports, env vars, requirements, badges, and links.
|
|
33
|
+
|
|
34
|
+
## Step 2 — Read the real repo
|
|
35
|
+
|
|
36
|
+
Ground-truth each claim against the actual project. Pull the facts from the source of truth, not from memory.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Scripts and metadata — the canonical list of commands
|
|
40
|
+
cat package.json # or pyproject.toml / Cargo.toml / go.mod / Makefile
|
|
41
|
+
|
|
42
|
+
# Top-level structure the README describes
|
|
43
|
+
ls -la
|
|
44
|
+
find . -maxdepth 2 -type d -not -path '*/node_modules/*' -not -path '*/.git/*'
|
|
45
|
+
|
|
46
|
+
# Entry points, config, and declared env vars
|
|
47
|
+
ls .env.example 2>/dev/null && cat .env.example
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Read the `scripts` block (or `Makefile` targets / task runner) line by line — those are the only commands the README may document. Identify the real entry points (`main`, `bin`, framework config) and any required tooling versions (`engines`, `.nvmrc`, `.python-version`, `rust-toolchain`).
|
|
51
|
+
|
|
52
|
+
> [!TIP]
|
|
53
|
+
> When a README example references a config file, port, or flag, open that file and confirm the value. A stale port or renamed flag is the most common drift, and the cheapest to verify.
|
|
54
|
+
|
|
55
|
+
## Step 3 — Diff claims against reality
|
|
56
|
+
|
|
57
|
+
Build a mental (or written) list of mismatches before editing. Sort each README claim into one of:
|
|
58
|
+
|
|
59
|
+
- **Stale** — documented but wrong now (renamed script, changed port, moved path, dead link).
|
|
60
|
+
- **Missing** — real and important but undocumented (a new script, a new env var, a new top-level dir).
|
|
61
|
+
- **Phantom** — documented but no longer exists in the code (removed feature, deleted command).
|
|
62
|
+
- **Correct** — matches the code; leave it exactly as is.
|
|
63
|
+
|
|
64
|
+
> [!WARNING]
|
|
65
|
+
> Resist scope creep. Do not reformat correct sections, reorder existing content, or restyle prose that is already accurate. Touch a line only because the code behind it changed.
|
|
66
|
+
|
|
67
|
+
## Step 4 — Update only what changed
|
|
68
|
+
|
|
69
|
+
Edit the README surgically, matching its existing voice and structure.
|
|
70
|
+
|
|
71
|
+
- Fix **stale** claims to the verified value (correct script name, current port, real path).
|
|
72
|
+
- Add **missing** items into the section where they belong, following the formatting of neighboring entries.
|
|
73
|
+
- Remove **phantom** claims, plus any examples, badges, or links that depended on them.
|
|
74
|
+
- Keep headings, ordering, code-fence languages, and tone identical to the original.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Sanity-check that documented commands actually resolve
|
|
78
|
+
npm run # lists the real scripts to compare against the README
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
If the README documents a quickstart, walk the steps in order and confirm each command exists in `package.json` (or the relevant manifest). Replace any command that does not resolve with the real one — never with a guess.
|
|
82
|
+
|
|
83
|
+
> [!NOTE]
|
|
84
|
+
> If a section is so far out of date that fixing it would mean rewriting it wholesale, flag that section in your report and ask before doing a full rewrite. This command corrects drift; it does not regenerate the README from scratch.
|
|
85
|
+
|
|
86
|
+
## Report
|
|
87
|
+
|
|
88
|
+
Summarize the edits as a tight changelog the author can scan:
|
|
89
|
+
|
|
90
|
+
```markdown
|
|
91
|
+
## README update — <section or "full audit">
|
|
92
|
+
|
|
93
|
+
### Changed
|
|
94
|
+
- `Scripts`: `npm run serve` → `npm run start` (renamed in package.json)
|
|
95
|
+
- `Quickstart`: dev port 3000 → 3001 (from package.json)
|
|
96
|
+
|
|
97
|
+
### Added
|
|
98
|
+
- `Scripts`: documented `npm run validate` (was missing)
|
|
99
|
+
- `Configuration`: `DATABASE_URL` from .env.example
|
|
100
|
+
|
|
101
|
+
### Removed
|
|
102
|
+
- `Features`: dropped "GraphQL playground" — no longer in the codebase
|
|
103
|
+
|
|
104
|
+
### Left as-is
|
|
105
|
+
- Installation, License (verified accurate)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
For every line, name the file that justified the change so the author can verify it. Do not commit or push — leave the working tree for the author to review.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Generate tests covering the happy path and edge cases for the given target."
|
|
3
|
+
argument-hint: "[file or function]"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Write a focused, high-value test suite for the target supplied in `$ARGUMENTS`. The target may be a file path (e.g. `src/lib/parse.ts`), a specific function or method (e.g. `parseConfig`), or a class. If `$ARGUMENTS` is empty, ask which file or function to cover before continuing.
|
|
7
|
+
|
|
8
|
+
## Understand the Target
|
|
9
|
+
|
|
10
|
+
Before writing any tests, build an accurate mental model of what you are testing.
|
|
11
|
+
|
|
12
|
+
1. Read the target identified by `$ARGUMENTS` and its direct dependencies.
|
|
13
|
+
2. Identify every public entry point: exported functions, methods, and class constructors.
|
|
14
|
+
3. For each entry point, note inputs, outputs, side effects (I/O, mutations, network, time), and thrown errors.
|
|
15
|
+
4. Detect the existing test framework and conventions instead of inventing your own. Check for `jest`, `vitest`, `mocha`, `pytest`, `go test`, etc. in the manifest and look at a neighboring `*.test.*` / `*_test.*` file for style.
|
|
16
|
+
|
|
17
|
+
> [!NOTE]
|
|
18
|
+
> Match the project's existing patterns exactly: file naming, import style, assertion library, and mocking approach. A test suite that fits the codebase is worth more than one that follows your personal preference.
|
|
19
|
+
|
|
20
|
+
## Plan the Cases
|
|
21
|
+
|
|
22
|
+
Enumerate cases before coding so coverage is deliberate, not accidental. Aim for the following categories for each entry point.
|
|
23
|
+
|
|
24
|
+
### Happy path
|
|
25
|
+
|
|
26
|
+
The expected, well-formed inputs that represent normal usage. Assert on the concrete return value and any intended side effects.
|
|
27
|
+
|
|
28
|
+
### Edge cases
|
|
29
|
+
|
|
30
|
+
Boundary and unusual-but-valid inputs, for example:
|
|
31
|
+
|
|
32
|
+
- Empty inputs: `""`, `[]`, `{}`, `0`, `null`/`None`, `undefined`.
|
|
33
|
+
- Boundaries: min/max values, off-by-one limits, single-element vs. many-element collections.
|
|
34
|
+
- Unicode, whitespace, very long strings, and duplicate or out-of-order data.
|
|
35
|
+
|
|
36
|
+
### Error cases
|
|
37
|
+
|
|
38
|
+
Invalid inputs and failure modes. Assert that the right error type is raised or the documented error result is returned — do not just assert that "something" throws.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
// Assert the specific failure, not a generic one.
|
|
42
|
+
expect(() => parseConfig("{ bad json")).toThrow(SyntaxError);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Write the Tests
|
|
46
|
+
|
|
47
|
+
Produce the suite following these rules.
|
|
48
|
+
|
|
49
|
+
- Give each test a descriptive name that states the scenario and expected outcome (e.g. `returns 0 for an empty list`).
|
|
50
|
+
- Keep tests independent and deterministic. No shared mutable state and no reliance on execution order.
|
|
51
|
+
- Use the Arrange–Act–Assert shape; keep each test focused on one behavior.
|
|
52
|
+
- Mock only true external boundaries (network, filesystem, clock, randomness). Do not mock the unit under test.
|
|
53
|
+
- Pin nondeterminism: seed RNG and freeze time so runs are reproducible.
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { describe, it, expect } from "vitest";
|
|
57
|
+
import { slugify } from "./slugify";
|
|
58
|
+
|
|
59
|
+
describe("slugify", () => {
|
|
60
|
+
it("lowercases and hyphenates a normal title", () => {
|
|
61
|
+
expect(slugify("Hello World")).toBe("hello-world");
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it("collapses repeated separators", () => {
|
|
65
|
+
expect(slugify("a -- b")).toBe("a-b");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("returns an empty string for input with no word characters", () => {
|
|
69
|
+
expect(slugify("!!!")).toBe("");
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Verify and Report
|
|
75
|
+
|
|
76
|
+
1. Run the test suite using the project's test command and confirm every new test passes.
|
|
77
|
+
2. If a test fails, decide whether it revealed a real bug in the target or a flaw in the test, then fix the appropriate side — do not weaken an assertion just to make it pass.
|
|
78
|
+
3. Report a short summary: the entry points covered, the case categories included, and any behavior that looks like a genuine bug.
|
|
79
|
+
|
|
80
|
+
> [!WARNING]
|
|
81
|
+
> If a test exposes incorrect behavior in the target, surface it explicitly rather than writing the test to match the buggy output. Tests should encode intended behavior, not current behavior.
|