create-use-case

A scaffold for a backend application use case: a small function containing one business operation, plus a matching automated test. It uses hexagonal design, which keeps business rules separate from web and framework code.

In plain words
What is it for?
It helps add or refactor backend operations, define their required repositories or gateways, handle expected failures, and test them with Bun's test runner.
Why use it?
It keeps application logic easier to test and prevents HTTP handlers from becoming responsible for business decisions.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/packmindhub/skillsight/create-use-case
Clone the repo
git clone --depth 1 https://github.com/PackmindHub/skillsight

Made for: Claude Code.

Per session 52 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 517 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00052 $0.00517
Opus 5 $0.00026 $0.00259
Sonnet 5 $0.00010 $0.00103
Haiku 4.5 $0.00005 $0.00052

Measured 3d ago against content hash c9ca11199d4a, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

create-use-case scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/create-use-case.md · 38 lines

What it actually says

Create a Use Case

Scaffold a new application use case following the repository's hexagonal convention: a pure function that takes deps (ports) and input, plus a matching bun:test test built with a local makeDeps. Use this whenever you add a business operation to the backend so it stays framework-agnostic and testable.

When to Use

  • Adding a new business operation to backend/src/application/.
  • Implementing the logic behind a new HTTP route before wiring the handler.
  • Refactoring logic out of an HTTP handler into the application layer.

Checkpoints

  • What is the feature folder (e.g. skills, plugins, integrations) the use case belongs to?
  • Which domain ports does it need (repositories, gateways)?
  • What are the expected failure cases that should be returned as { error: ... } instead of thrown?

Steps

1. Create the use-case file

Add backend/src/application/<feature>/<verb-noun>.ts. Export an async function taking deps (an object of domain/ports interfaces) and input (a typed params object). Return the domain entity on success and a discriminated { error: "..." } union for expected failures. Import only from domain/ — no Hono, no Drizzle.

2. Write the test alongside it

Add <verb-noun>.test.ts in the same folder. Define a local makeDeps(...) that returns fully-stubbed ports typed against their I*Repository interfaces, capturing call side-effects in closure variables. Use describe/it/expect from bun:test. Cover the success path and each { error } branch.

3. Wire it into the HTTP layer

In the relevant backend/src/http/ handler, instantiate dependencies from the DI container (bootstrap/compose.ts) and call the use case, mapping { error } results to the correct HTTP status. Keep the handler thin.

4. Verify

Run bun test backend/src/application/<feature>/<verb-noun>.test.ts, then bun run lint and bun run typecheck.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 38 lines · 52 tokens per session scan A c9ca11199d4a

Subscribe to this mod's changes

create-use-case is a command published in the GitHub repository PackmindHub/skillsight (9 stars, last pushed 2mo ago), licensed Apache-2.0. It adds 52 tokens to every session and 517 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.