agentleFS
andy-dendy-repoandy-dendy-repo/govern/.claude/skills/add-use-case/SKILL.md

add-use-case

Skill2 starsChanged 32 days agoMITView on GitHub

Adds one Govern use case end to end: Application contract (Request/Response/Validator/Handler), feature errors, Api endpoint, integration tests and docs. Use when the user asks for a new command, query or endpoint ("add an endpoint to…", "users should be able to…", "create/update/delete/list X").

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Run inside /develop-feature, which covers the plan, verification and review.

    line 11
  2. Very specific:

    Read first: architecture.md, api-endpoints.md, error-handling.md, mapping.md, and persistence.md if data changes.

    line 13
  3. Very specific:

    Helpers: add request helpers to tests/Govern.IntegrationTests/Support/[Feature]Api.cs (pattern: UsersApi).

    line 46
  4. Very specific:

    Update docs/features/[feature].md: the use case, endpoint row (method, route, auth, statuses), error codes and business rules.

    line 49
  5. Very specific:

    Add the file to docs/README.md if it is new.

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Add a use case

Run inside /develop-feature, which covers the plan, verification and review. This skill is the recipe for the code. Reference implementation: src/Govern.Application/Users/Contracts/SignUpContract.cs + src/Govern.Api/Features/Users/SignUpEndpoint.cs + tests/Govern.IntegrationTests/Features/Users/SignUpEndpointTests.cs.

Read first: architecture.md, api-endpoints.md, error-handling.md, mapping.md, and persistence.md if data changes.

1. Contract: src/Govern.Application/[Feature]/Contracts/[UseCase]Contract.cs

  • [UseCase]Request: sealed record implementing IRequest<[UseCase]Request, [UseCase]Response>. Document every positional parameter.
  • [UseCase]Response: sealed record implementing IResponse. If the projection is reused, add static Expression<Func<TEntity, [UseCase]Response>> Projection (mapping.md).
  • [UseCase]Validator: sealed class deriving AbstractValidator<[UseCase]Request>, with bounds on every string and collection.
  • [UseCase]Handler: internal sealed class implementing IRequestHandler<,>:
    • Primary constructor, at most 6 dependencies.
    • await using var db = await dbContextFactory.CreateDbContextAsync(ct);
    • Reads use AsNoTracking().Select(...).
    • Writes go through domain methods, then SaveChangesAsync.
    • Expected failures are return XxxErrors.Y;.
    • Ownership is enforced with ICurrentUserService.UserId.
  • Anything else in the file is a file-scoped type.

2. Errors: src/Govern.Application/[Feature]/Models/[Feature]Errors.cs

  • Add public static readonly Error X = Error.Conflict("feature.snake_code", "Client-safe message.");.
  • Reuse existing errors; never change existing codes.

3. Endpoint: src/Govern.Api/Features/[Feature]/[UseCase]Endpoint.cs

Copy the shape of SignUpEndpoint: static class, Map(IEndpointRouteBuilder), a named HandleAsync.

  • Access: explicit .RequireAuthorization() or .AllowAnonymous(). A new anonymous route must be added to the allow-list in tests/Govern.IntegrationTests/Security/EndpointAuthorizationTests.cs.
  • Metadata: .WithName(nameof(...)), .WithTags("[Feature]"), .Produces<...>(status), .ProducesValidationProblem(), .ProducesProblem(...) for each error status.
  • Docs: XML docs with <response code> for every status.

4. Integration tests: tests/Govern.IntegrationTests/Features/[Feature]/[UseCase]EndpointTests.cs

  • Base class: derive from ApiTestBase(fixture). The database is reset per test.
  • Required cases:
    • Happy path: status, body and persisted state via Fixture.OpenDbAsync().
    • 400 with the exact invalid fields (ShouldBeValidationProblemAsync).
    • 401 without a token when protected.
    • Each domain error with its code (ShouldBeProblemAsync(status, "feature.code")).
    • Ownership: another user's resource returns 404.
  • Helpers: add request helpers to tests/Govern.IntegrationTests/Support/[Feature]Api.cs (pattern: UsersApi).

5. Docs

  • Update docs/features/[feature].md: the use case, endpoint row (method, route, auth, statuses), error codes and business rules.
  • Add the file to docs/README.md if it is new.

6. Check

  • dotnet build Govern.slnx.
  • dotnet test --project tests/Govern.ArchitectureTests: contract shape, endpoint shape, folders, size limits.
  • dotnet test Govern.slnx.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.