Add a BookingSystem.Api endpoint

VerifiedSafe

Step-by-step checklist for adding an API endpoint that follows repo conventions: DTOs, service layer, thin controller, authorization, tests, and concurrency handling.

Sby Skills Guide Bot
DevelopmentIntermediate
10/21/2026
Claude Code
#dotnet#api-endpoints#code-conventions#concurrency#xunit

Recommended for

Automated summary

Step-by-step convention guide for adding a new API endpoint to the BookingSystem.Api project (DTO, service, controller, authorization, tests).

Strengths

  • Explicit ordered sequence (DTOs → service → controller → authorization → tests) that makes the work repeatable
  • Includes a concrete rule for concurrent read-then-write flows, returning a distinguishable conflict outcome instead of throwing
  • States the expected status codes (Ok/Created/Conflict/NotFound) and forbids a bare 500 for a predictable outcome
  • Requires xUnit tests for happy and error paths, plus a concurrency test modeled on ConcurrencyTests.cs

Limitations

  • Tightly coupled to one project's architecture and file names (BookingSystem.Api), so it is not directly reusable elsewhere
  • Does not spell out the exact shape of DTOs, services or the conditional-update pattern; you must read the existing code
  • The optional frontend step is vague and assumes the api() helper already exists in frontend/app.js
When to use it

Use it when adding or changing an endpoint in BookingSystem.Api and you want the change to follow the repository's existing conventions.

When not to use it

Avoid it for a different project or stack, or for tasks unrelated to endpoint creation such as schema redesign, CI setup or documentation.

Security analysis

Safe
Quality score88/100

This is a pure procedural/editorial guideline document describing how to add an endpoint in a .NET codebase. It declares no tools, contains no executable commands beyond standard `dotnet build && dotnet test` verification, and performs no network, filesystem-destructive, obfuscated, or exfiltration actions. No prompt-injection or instruction-override attempts were present in the content.

No concerns found

How this analysis is made

Examples

New cancel endpoint
Add a POST /api/bookings/{id}/cancel endpoint to BookingSystem.Api, following the project conventions.
Admin-only endpoint
Add an admin-only GET endpoint that lists all bookings for a given slot, with authorization and tests.
Concurrency-safe endpoint
Add an endpoint that reassigns a booking to another slot, make it safe against concurrent writes, and cover it with a concurrency test.

name: add-booking-endpoint description: Use when adding a new API endpoint to BookingSystem.Api, to keep controller/service/DTO/test structure consistent with the rest of the codebase.

Adding a new endpoint to BookingSystem.Api

Follow this sequence so new endpoints match the codebase's conventions (see CLAUDE.md):

  1. DTOs first. Add request/response record types to the relevant file in DTOs/ (e.g. BookingDtos.cs). Never expose an EF entity directly from a controller.
  2. Service method. If the endpoint does anything beyond a simple CRUD read, add the logic to the matching interface + implementation in Services/ (e.g. IBookingService / BookingService), not directly in the controller.
    • If the new logic reads then writes state that another request could also be writing concurrently, do NOT use a plain read-then-write. Use an atomic conditional UPDATE ... WHERE (see BookingService.CreateBookingAsync) or an EF Core concurrency token, and return a distinguishable "conflict" outcome rather than throwing.
  3. Controller action. Thin method: model-bind the request DTO, call the service, map the result to the response DTO / appropriate status code (Ok / Created / Conflict / NotFound — never a bare 500 for an expected outcome like "lost the race").
  4. Authorization. Add [Authorize] (already on the controller by default) and [Authorize(Roles = Roles.Admin)] on the action if it's an admin-only operation.
  5. Test. Add an xUnit test in BookingSystem.Tests for the happy path and for the conflict/error path. If the endpoint touches shared mutable state (like a booking or slot), add or extend a concurrency test modeled on ConcurrencyTests.cs: fire several requests with Task.WhenAll and assert exactly one wins.
  6. Frontend (optional). If the endpoint needs a UI, add a small function to frontend/app.js following the existing api() helper pattern — no new frontend framework or build step.

Run dotnet build && dotnet test before considering the change done.

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-a-bookingsystem-api-endpoint-mvda873q/download' --output '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md.part' && mv '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md.part' '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md' && test -s '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/add-booking-endpoint' && cp -R '.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q' '.claude/skills/add-booking-endpoint'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q'

openskills read 'add-a-bookingsystem-api-endpoint-mvda873q'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/add-a-bookingsystem-api-endpoint-mvda873q/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills