/dapr-skills:create-pubsub-dotnetfrom dapr-skills
Creates a Dapr pub/sub application in .NET with publisher, subscriber, or both, supporting declarative, programmatic, or streaming subscriptions. Runs with dapr run or Aspire.
Ships in dapr-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill creates a new Dapr pub/sub application in .NET: a publisher, a subscriber or both, sharing the message contract the user described and one Redis-backed pubsub component. The subscriber uses a declarative (default), programmatic or streaming subscription, and the app runs with dapr run -f . or with .NET Aspire.
The application is built from the user's own domain. There is no built-in sample scenario: the event, its fields, its topic and what the subscriber does with it all come from the Check specification interview, and every template is filled in from the placeholder vocabulary in ../dapr-shared/pubsub-placeholders.md.
You MUST follow these phases in strict order:
## Show final message section: the closing sentence followed by the Dev Dashboard recommendation. Do NOT add any other text, summary, or commentary.The following must be installed by the user before this skill can run. Do not run the check-prereq skills; assume the prerequisites are installed.
dapr init provides Redis)Packages (added during project setup):
Dapr.AspNetCore 1.19.1 for the publisher, declarative subscribers and programmatic subscribersDapr.Messaging 1.19.1 for streaming subscribers (no Dapr.AspNetCore in that project)CommunityToolkit.Aspire.Hosting.Dapr 13.0.0 and Aspire.Hosting.Valkey (same version as the Aspire.AppHost.Sdk that aspire new writes)Concepts (CloudEvents, dead-letter, routing, TTL, raw payload, subscription types): ../dapr-shared/pubsub-concepts.md.
Placeholder vocabulary used by every template: ../dapr-shared/pubsub-placeholders.md.
Never build a default scenario. The application is about the user's domain, and the templates are placeholders waiting for it. Infer everything the prompt already says, then ask only what is missing, one question at a time, waiting for each answer. If the prompt gives no domain at all, ask for it — do not invent one and do not fall back to an order-processing example.
Domain, first:
<IdProperty>: the handler deduplicates on it, so there must be exactly one
per event. Ask for the type of each field when the name does not make it obvious.Then the wiring:
[Topic]/WithTopic in code) or streaming (the app pulls messages; no inbound port)". Inference: "streaming", "no inbound port" or "pull" → streaming; "programmatic", [Topic] or WithTopic → programmatic; "declarative" or "subscription YAML" → declarative.dapr run, default) or with .NET Aspire?"subscriber.Feature rules:
<TopicName>-deadletter) is on unless the user declines it.REFERENCE.md → Routing, TTL and raw payload.Before creating any file, write out the resolved values and restate them to the user in two or three
lines, so a wrong reading is caught before it is scaffolded. Resolve them exactly as
../dapr-shared/pubsub-placeholders.md defines them:
| Placeholder | Resolved from |
|---|---|
<EventName>, <EventFields>, <IdProperty> | questions 2 and 3 |
<eventVar>, <EventDescription> | <EventName>, in camelCase and as a lowercase noun phrase |
<TopicName>, <DeadLetterTopicName> | question 2; the dead-letter topic is <TopicName>-deadletter |
<TopicConstant>, <DeadLetterTopicConstant>, <TopicResource> | PascalCase of <TopicName> |
<PublishRoute>, <PublishResource>, <SubscribeRoute>, <DeadLetterRoute> | <TopicName>; the subscribe route is /events/pubsub/<TopicName> |
<ValidationCondition>, <HandlerBody> | questions 3 and 4 |
Fixed, never derived from the domain: the component name pubsub, the class PubSubNames, the
idempotency store IProcessedEvents / InMemoryProcessedEvents, and PublishFeatures. <root-kebab> is
<ProjectRoot> in kebab-case (ShipTrack → shiptrack); app ids are <root-kebab>-publisher and
<root-kebab>-subscriber.
Check once whether the optional Dev Dashboard is installed by following the Check section of ../dapr-shared/dev-dashboard.md (diagrid-dev-dashboard --version). Remember the result (DevDashboardInstalled) for the final message. This check never stops the skill: do not ask the user about it, do not install anything, and continue whether or not the dashboard is installed.
Create the project root inside the current location where the terminal is open. Run all commands from inside <ProjectRoot> and do not cd elsewhere between commands.
dapr run)mkdir <ProjectRoot>
cd <ProjectRoot>
dotnet new sln --format slnx -n <ProjectRoot>
dotnet new web -n <ProjectRoot>.Publisher
dotnet new web -n <ProjectRoot>.Subscriber
dotnet new classlib -n <ProjectRoot>.Contracts
dotnet add <ProjectRoot>.Publisher package Dapr.AspNetCore --version 1.19.1
dotnet add <ProjectRoot>.Subscriber package Dapr.AspNetCore --version 1.19.1
dotnet add <ProjectRoot>.Publisher reference <ProjectRoot>.Contracts
dotnet add <ProjectRoot>.Subscriber reference <ProjectRoot>.Contracts
dotnet sln add <ProjectRoot>.Publisher <ProjectRoot>.Subscriber <ProjectRoot>.Contracts
publisher or subscriber: create only that web project; no classlib; the contract goes in the project's Models/ folder.Dapr.Messaging 1.19.1 to the subscriber instead of Dapr.AspNetCore.<TargetFramework>net10.0</TargetFramework> in every project.Class1.cs from the Contracts classlib.IMPORTANT: Always include --non-interactive, --test-framework none and --suppress-agent-init. Without --suppress-agent-init the Aspire CLI changes the user's global AI tool configuration.
aspire new aspire-starter -n <ProjectRoot> -o <ProjectRoot> --non-interactive --test-framework none --suppress-agent-init
Then, from inside <ProjectRoot>:
<ProjectRoot>.Web and <ProjectRoot>.ApiService projects and remove them from the solution file (<ProjectRoot>.sln) and remove their two <ProjectReference> lines from <ProjectRoot>.AppHost.csproj.<ProjectRoot>.Publisher and <ProjectRoot>.Subscriber (dotnet new web) and the Contracts classlib (role both), add them to the solution, reference ServiceDefaults from each web project, and call builder.AddServiceDefaults(); and app.MapDefaultEndpoints(); in their Program.cs.Aspire.AppHost.Sdk version from the AppHost .csproj; keep the versions aspire new wrote).<Content Include="Resources\**\*.*"> item group (with CopyToOutputDirectory and Link) to the AppHost .csproj as in the wiring file's AppHost .csproj section, then wire the AppHost, Resources/ folder and Dev Dashboard resource per ../dapr-shared/dotnet-aspire-dapr-wiring.md → Pub/sub apps. No dapr.yaml is created.See REFERENCE.md → Folder structures for the four trees (dapr run both / single role, Aspire both, streaming subscriber).
Each file below comes from a shared file. Copy it and replace every placeholder with the value resolved in
Resolving the placeholders. A file is never written with a placeholder left in it: after writing each
one, check it for a stray < ... > that is not valid C# generics or XML.
Namespaces. <ProjectNamespace> is <ProjectRoot>.<Role> for a web project (ShipTrack.Publisher, ShipTrack.Subscriber) and <ProjectRoot>.Contracts for the classlib. Single role: the contract files keep the project namespace (they live in Models/ but declare namespace <ProjectNamespace>;). Wire them up with global usings in each web project's .csproj, not per-file using lines (this works for minimal APIs, controllers and Aspire):
<ItemGroup>
<Using Include="<ProjectRoot>.Contracts" /> <!-- role both only -->
<Using Include="<ProjectRoot>.<Role>" />
</ItemGroup>
dapr.yaml (dapr run mode) — ../dapr-shared/pubsub-dapr-yaml.md (.NET values: publisher 5110/3510/50010, subscriber 5120/3520/50020). Omit appPort for a streaming-only subscriber.resources/pubsub.yaml — ../dapr-shared/dapr-pubsub-redis.md (Aspire: use the version in the wiring file, which has a different host and password).resources/resiliency.yaml — ../dapr-shared/dapr-pubsub-resiliency.md (dead-letter on).resources/subscription.yaml (declarative only) — ../dapr-shared/dapr-pubsub-subscription.md. The scopes value MUST be the subscriber app id (<root-kebab>-subscriber), identical to the appID in dapr.yaml or DaprSidecarOptions.AppId in the AppHost.<EventName>, PubSubNames) — ../dapr-shared/dotnet-pubsub-publisher.md → Message contract.<EventName>Publisher, POST /<PublishRoute>, minimal API or controller, registration) — ../dapr-shared/dotnet-pubsub-publisher.md.../dapr-shared/dotnet-pubsub-subscriber-declarative.md. app.UseCloudEvents() MUST come before the endpoint mappings; otherwise the typed body binds the CloudEvent envelope and every field is null.../dapr-shared/dotnet-pubsub-subscriber-programmatic.md (also UseCloudEvents() first).../dapr-shared/dotnet-pubsub-messaging.md → Streaming subscriber.<EventName>Handler, dead-letter handler) — ../dapr-shared/dotnet-pubsub-handler.md.pubsub.http — ../dapr-shared/pubsub-local-http.md, using the launchSettings.json ports..gitignore — ../dapr-shared/dotnet-gitignore.md.Properties/launchSettings.json — dotnet new web generates this file with random ports and an https profile; replace its profiles with a single http profile (omit launchUrl) with applicationUrl http://localhost:5110 (publisher) and http://localhost:5120 (subscriber). The port MUST equal appPort in dapr.yaml; a streaming-only subscriber has no appPort, so its port is only used by dotnet run.For the Program.cs of each type and style, see REFERENCE.md → Program.cs per type and style.
IMPORTANT: After Project Setup you MUST run these checks:
dotnet build "<ProjectRoot>.slnx" (dotnet new sln --format slnx writes .slnx). Aspire mode: dotnet build "<ProjectRoot>.sln", because aspire new writes a .sln. It must succeed; fix any errors and rebuild.dapr run -f . in <ProjectRoot> (Aspire: aspire run).IMPORTANT: After Verify you MUST run these instructions:
Create a README.md inside <ProjectRoot> with these sections:
dapr init provides it (Aspire: the Valkey container).Program.cs, and a link to pubsub.http.GET /v1.0/metadata on the sidecar and the Dev Dashboard's subscriptions view.subscription.yaml needs no restart.REFERENCE.md → README key points).../dapr-shared/dev-dashboard.md (Aspire form in Aspire mode).metadata.name: pubsub stays the same, so no code changes. A heading with no paragraph, or a paragraph without that link, is incomplete. See REFERENCE.md → README key points for the full wording.../dapr-shared/running-with-catalyst.md.review-pubsub-publishing, review-pubsub-subscriptions and review-pubsub-components skills.IMPORTANT: This is the LAST step. After Create README.md, your final output MUST be ONLY the message below followed by the Dev Dashboard recommendation — no preamble, no summary, no additional commentary, only replace the with the actual value:
The pub/sub application is created. Open the README.md file in the folder for a summary and instructions for running locally.
Then add, as a separate paragraph, the block from the Final recommendation section of ../dapr-shared/dev-dashboard.md that matches DevDashboardInstalled (use the Aspire form in Aspire mode). Use it as written. Nothing may follow it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub diagrid-labs/dapr-skills --plugin dapr-skills33 skills in this plugin
/add-pubsub-dotnetAdds Dapr pub/sub to an existing .NET (ASP.NET Core, plain or Aspire) project. Edits only after you approve a plan. Use for "add pub/sub to my .NET project" or "subscribe this ASP.NET app to a topic". For a new project use create-pubsub-dotnet./add-pubsub-pythonAdds Dapr pub/sub to an existing Python FastAPI app. Edits only after you approve a plan. Use for "add pub/sub to my FastAPI app" or "make this Python service subscribe to a Dapr topic". For a new app use create-pubsub-python./add-workflow-dotnetAdds Dapr Workflow, activities and management endpoints to an existing .NET (ASP.NET Core, plain or Aspire) project after you approve a plan. Use for "add a workflow to my .NET project" or "make this process a durable workflow". For a new project use create-workflow-dotnet. For Diagrid use the diagrid plugin./check-prereq-agent-dotnetChecks prerequisites for durable AI agents in .NET with Microsoft Agent Framework on Dapr Workflow. Use for "check prerequisites for .NET agents" or "verify .NET agent environment"./check-prereq-agent-pythonChecks prerequisites for durable AI agents in Python with the Dapr Agents SDK or diagrid package framework wrappers. Use for "check prerequisites for Python agents" or "verify Python agent environment"./check-prereq-aspireChecks prerequisites for Dapr Workflow apps with .NET Aspire. Use for "check prerequisites for Aspire" or "verify Aspire environment".Other plugins' skills for the same job