/dapr-skills:add-pubsub-dotnetfrom dapr-skills
Adds Dapr pub/sub (publisher, subscriber, or both) to an existing .NET ASP.NET Core, plain, or Aspire project. Edits only after user approves a plan, builds after each step, and runs tests at the end.
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 adds Dapr pub/sub (publisher, subscriber or both) to an ASP.NET Core project that already exists. It changes nothing before the user approves a written plan, edits existing files with the smallest possible change, follows the project's own conventions and the subscription type it already uses, builds the solution after every step and runs the existing tests at the end. It never changes git state.
You MUST follow these phases in strict order:
DAPR-PUBSUB.md at the solution root (the project folder when there is no solution file).## Show final message followed by the Dev Dashboard recommendation. No other text after it.The user must have installed:
dotnet --version: the SDK major version must be at least the target framework's major version (net8.0 → 8+, net9.0 → 9+, net10.0 → 10+). If a global.json pins an SDK, that SDK must be installed.aspire run (not needed to build)Read-only. Follow Detection in REFERENCE.md. Determine and remember:
*.sln or *.slnx) and the target project. If more than one ASP.NET Core project qualifies, ask which one (one question) and wait.net8.0, net9.0 and net10.0 are supported. For anything else (net6.0, net7.0, .NET Framework, or a multi-target list containing one), stop now: say that Dapr.AspNetCore 1.19 needs net8.0 or later, suggest upgrading the target framework or creating a separate service with create-pubsub-dotnet, and change nothing.Microsoft.NET.Sdk.Web) is supported. Worker Service, console, Azure Functions, Blazor WebAssembly and MAUI projects stop here with the same kind of explanation.Program.cs (top-level) or Startup.cs; minimal APIs or controllers; namespace style, nullable, folder layout.Dapr.AspNetCore, Dapr.Client and Dapr.Messaging packages and versions. Remember every Dapr.* package older than 1.19.1 as newer packages available.AddDaprClient(, .AddDapr(, UseCloudEvents( (and whether it comes after UseEndpoints(), MapSubscribeHandler(, AddDaprMessaging(, MapDaprMessaging(.REFERENCE.md ([Topic(/.WithTopic(, kind: Subscription YAML, [DaprTopic(), and every subscribed (pubsub, topic) pair.type: pubsub. (name, type, scopes) and kind: Resiliency files; dapr.yaml and its resources folder.POST /orders). Read-only endpoints never qualify. Remember the best match, and whether an existing test calls it over HTTP (WebApplicationFactory, HttpClient).dotnet build "<solution-path>", dotnet test "<solution-path>".git status (read-only). Remember whether the tree has uncommitted changes.Infer from the request first, then ask, one question at a time:
[Topic], WithTopic → programmatic; "declarative", "subscription YAML" → declarative); otherwise ask with declarative as the default. Mixed types: ask which type the new topic uses, default the type with the most subscriptions.../dapr-shared/pubsub-placeholders.md.## Clashes and mixed types in REFERENCE.md.Follow the Check section of ../dapr-shared/dev-dashboard.md (diagrid-dev-dashboard --version) and remember DevDashboardInstalled. Do not ask about it, install it or stop because of it.
Emit the Add Pub/Sub Plan using the template in REFERENCE.md. It lists the target, role and subscription type with the reason, the topics, every file to add, every file to edit with a one-line description, package versions and where they go, the Dapr wiring (ports, component reused or new, resiliency, Subscription file), what is left alone, the baseline test run (default yes), and an uncommitted-changes warning when Phase 1 found one.
The plan ends with a Questions section. Ask these before any file is created or changed, each with its default:
Dapr.Messaging is older than 1.18.8, the update to 1.19.1 is a required plan item; if the user declines it, switch the plan to declarative and say so.POST /orders) and ask whether it should also publish the event after its existing work succeeds. When the request explicitly asks to publish from a named action or endpoint ("when an order is created/placed", "from POST /orders"), the default is Yes even when an existing test calls that endpoint over HTTP; the plan then carries a Risk line naming the test file(s)/test(s), saying they will need a Dapr sidecar or a test double for the publisher (replace or override the registered <EventName>Publisher) and that this skill does not edit tests. When the request does not mention publishing from an existing action, the default is Yes, but No when an existing test calls that endpoint over HTTP, because the call would then need a running Dapr sidecar; say so in the question. When no endpoint qualifies, write "No existing endpoint publishes the event; use the new POST /pubsub/<PublishRoute> endpoint." instead of asking.Write the plan's file lists as if every default is accepted, and mark which items depend on a question.
Then ask the user to approve, change or stop. A plan is not consent: change nothing until the user says yes. A plain "yes" accepts the plan with the defaults; the user may answer a question differently in the same reply. When the request already says to go ahead without asking, still show the plan with its questions first, then continue with the defaults.
If the baseline test run was kept, run dotnet test "<solution-path>" once now and remember which tests failed before any change.
Apply the approved items in this fixed order, one step at a time:
Dapr.AspNetCore 1.19.1 (publisher, declarative, programmatic) or Dapr.Messaging 1.19.1 (streaming; a publisher in the same project then also uses Dapr.Messaging, so Dapr.AspNetCore is not added), plus the updates from question 1. See Package reference in REFERENCE.md.dapr.yaml entry per ../dapr-shared/pubsub-dapr-yaml.md → Appending to an existing dapr.yaml (keep the app's existing appPort for every subscription type), pubsub.yaml from ../dapr-shared/dapr-pubsub-redis.md or reuse of the existing component, resiliency.yaml per ../dapr-shared/dapr-pubsub-resiliency.md (Appending to an existing Resiliency when one exists), and subscription.yaml per ../dapr-shared/dapr-pubsub-subscription.md for declarative; Aspire mode: the AppHost edits from Pub/sub apps → Adding to an existing AppHost in ../dapr-shared/dotnet-aspire-dapr-wiring.md.PubSubNames and <EventName>Publisher per ../dapr-shared/dotnet-pubsub-publisher.md; for a subscriber, the handler per ../dapr-shared/dotnet-pubsub-handler.md (declarative, programmatic) or ../dapr-shared/dotnet-pubsub-messaging.md (streaming). Publisher stack: when the chosen type is streaming (Dapr.Messaging, no Dapr.AspNetCore reference), the publisher role is an <EventName>Publisher that injects IDaprPublishSubscribeClient and calls PublishEventAsync on it, per Publishing with IDaprPublishSubscribeClient (the <EventName>Publisher block) in the messaging file, NOT the DaprClient-based publisher file; it needs AddDaprMessaging() only and no AddDaprClient(). When the project already references Dapr.AspNetCore or Dapr.Client (mixed), follow the existing publisher's stack, say which one in the plan, and never register both for the same purpose.## Wiring per subscription type in REFERENCE.md: AddDaprClient() only when neither AddDaprClient( nor .AddDapr( exists; UseCloudEvents() before any Map* subscriber route (declarative, programmatic), only when missing, and moved when it follows UseEndpoints(; MapSubscribeHandler() for programmatic only, when missing; AddDaprMessaging() for streaming, with options.DaprGrpcEndpoint set from DAPR_GRPC_PORT as in the shared messaging file (a bare call never opens the stream)./events/pubsub/orders, /events/pubsub/orders-deadletter) per ../dapr-shared/dotnet-pubsub-subscriber-declarative.md or ../dapr-shared/dotnet-pubsub-subscriber-programmatic.md, in the Minimal API form or Controller form the project already uses (streaming maps no endpoints). For a publisher: the new POST /pubsub/orders endpoint, or, when question 2 was answered yes, the edit to the trigger endpoint per Adding to an existing Program.cs or Startup.cs in the publisher file..http file or add <ProjectName>.pubsub.http (../dapr-shared/pubsub-local-http.md).Rules for every step:
Edit with the smallest change, and never overwrite an existing file with Write. Never touch files the plan does not list.AddDaprClient(), MapSubscribeHandler() or AddDaprMessaging().dapr.yaml or an existing resiliency file.git status.DPS-* rules.dotnet build "<solution-path>". If it fails, fix that step or undo that step's edits, tell the user what happened, and stop. Never continue past a failing build.Run dotnet build "<solution-path>" and, when test projects exist, dotnet test "<solution-path>". Report failures that also failed in the baseline run as pre-existing. If the baseline passed and a test that calls the changed endpoint now fails because of the publish call (timeout or connection to the sidecar, e.g. DaprException), report it as an expected consequence of the approved Risk line and name the one-line fix (a test double: replace or override the registered <EventName>Publisher); failures unrelated to the publish call are regressions. Never edit tests to make them pass. Do not start dapr run or aspire run.
Create DAPR-PUBSUB.md at the solution root (or, when Phase 1 found no solution file, in the project folder next to the .csproj, which is also where dapr.yaml and resources/ go) from ../dapr-shared/pubsub-run-doc.md (follow its Filling it in section). Never edit an existing README.md.
IMPORTANT: This is the LAST step. Your output MUST end with the message below followed by the Dev Dashboard recommendation — keep anything before it to one short line (details belong in DAPR-PUBSUB.md). Replace <ProjectName> with the target project name, and <root> with solution when a solution file was found or project when there is none:
Dapr pub/sub is added to . Open DAPR-PUBSUB.md in the root for what changed and how to run it.
Then add, as a separate paragraph, the block from the Final recommendation section of ../dapr-shared/dev-dashboard.md that matches DevDashboardInstalled (in its Aspire form in Aspire mode). Nothing may follow it.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
33 skills in this plugin
/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".npx claudepluginhub diagrid-labs/dapr-skills --plugin dapr-skillsOther plugins' skills for the same job