Agent skill

Aspire Service Defaults

by Aaronontheweb in Aaronontheweb/dotnet-skills

Sets up a shared ServiceDefaults project for .NET Aspire apps that centralizes OpenTelemetry, health checks, HTTP resilience and service discovery for every service.

MITAuto-check passedDevOps & Cloud

Install Aspire Service Defaults

skills CLI
$ npx skills add Aaronontheweb/dotnet-skills --skill aspire-service-defaults -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install Aaronontheweb/dotnet-skills aspire-service-defaults --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/Aaronontheweb/dotnet-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/aspire-service-defaults .claude/skills/aspire-service-defaults && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
aspire-service-defaults
GitHub stars
1.2k
Used in
1 other repo
Token cost
~2.6k tokens
SKILL.md length
197 words
Files
1
Skills in repo
35
Repo updated
First seen
Licence
MIT

At a glance

Sets up a shared ServiceDefaults project for .NET Aspire apps that centralizes OpenTelemetry, health checks, HTTP resilience and service discovery for every service.

  • Starting an Aspire distributed application that needs shared observability
  • SKILL.md covers When to Use This Skill, What is ServiceDefaults?, Project Structure and ServiceDefaults Project, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md
  • Adding consistent logging, tracing and metrics across services

What it does

The skill describes a shared project that each service references and activates by calling AddServiceDefaults(). It bundles OpenTelemetry for logs, traces and metrics, readiness and liveness health endpoints, automatic service discovery, and HTTP resilience with retry and circuit breaker policies. The core is an Extensions.cs file alongside a project file that targets net9.0.

Further sections show usage in an API service and in a worker service built on the generic host, adding custom health checks, adding custom trace sources such as Akka.NET or other ActivitySources, protecting or relocating health endpoints in production while keeping them reachable for Kubernetes probes, and how the AppHost configures OTLP endpoints automatically.

When your agent uses it

  • Starting an Aspire distributed application that needs shared observability
  • Adding consistent logging, tracing and metrics across services
  • Configuring shared health checks for readiness and liveness
  • Setting up HttpClient resilience and service discovery

Example prompts

  • “Create a ServiceDefaults project for our Aspire solution and reference it from the API and worker services.”
  • “Add a custom health check for the database to the shared defaults.”
  • “Register our Akka.NET ActivitySource in the OpenTelemetry setup.”
  • “Lock down the health endpoints in production but keep them available for Kubernetes probes.”

Requirements

  • A .NET Aspire solution

What it can do on your machine

Read from SKILL.md and the folder at commit 29878f2. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are csharp and xml).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • learn.microsoft.com
    • opentelemetry.io

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Aspire Service Defaults loads about 2.6k tokens when it runs. Until then it costs about 50 tokens; SKILL.md has 197 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~50
When it runs · the whole SKILL.md, loaded when a task matches
~2.6k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from Aaronontheweb/dotnet-skills at commit 29878f2, republished under its MIT licence (© Aaronontheweb). 197 words, ~2,610 tokens.

Download SKILL.mdSave it as .claude/skills/aspire-service-defaults/SKILL.md (or your agent's skills folder).
name
aspire-service-defaults
description
Create a shared ServiceDefaults project for Aspire applications. Centralizes OpenTelemetry, health checks, resilience, and service discovery configuration across all services.
user-invocable
false

Aspire Service Defaults

When to Use This Skill

Use this skill when:

  • Building Aspire-based distributed applications
  • Need consistent observability (logging, tracing, metrics) across services
  • Want shared health check configuration
  • Configuring HttpClient resilience and service discovery

What is ServiceDefaults?

ServiceDefaults is a shared project that provides common configuration for all services in an Aspire application:

  • OpenTelemetry - Logging, tracing, and metrics
  • Health Checks - Readiness and liveness endpoints
  • Service Discovery - Automatic service resolution
  • HTTP Resilience - Retry and circuit breaker policies

Every service references this project and calls AddServiceDefaults().


Project Structure

src/
  MyApp.ServiceDefaults/
    Extensions.cs
    MyApp.ServiceDefaults.csproj
  MyApp.Api/
    Program.cs  # Calls AddServiceDefaults()
  MyApp.Worker/
    Program.cs  # Calls AddServiceDefaults()
  MyApp.AppHost/
    Program.cs

ServiceDefaults Project

Project File
xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <IsAspireSharedProject>true</IsAspireSharedProject>
  </PropertyGroup>

  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Extensions.Http.Resilience" />
    <PackageReference Include="Microsoft.Extensions.ServiceDiscovery" />
    <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" />
    <PackageReference Include="OpenTelemetry.Extensions.Hosting" />
    <PackageReference Include="OpenTelemetry.Instrumentation.AspNetCore" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Http" />
    <PackageReference Include="OpenTelemetry.Instrumentation.Runtime" />
  </ItemGroup>
</Project>
Extensions.cs
csharp
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Logging;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;

namespace Microsoft.Extensions.Hosting;

public static class Extensions
{
    private const string HealthEndpointPath = "/health";
    private const string AlivenessEndpointPath = "/alive";

    /// <summary>
    /// Adds common Aspire services: OpenTelemetry, health checks,
    /// service discovery, and HTTP resilience.
    /// </summary>
    public static TBuilder AddServiceDefaults<TBuilder>(this TBuilder builder)
        where TBuilder : IHostApplicationBuilder
    {
        builder.ConfigureOpenTelemetry();
        builder.AddDefaultHealthChecks();

        builder.Services.AddServiceDiscovery();

        builder.Services.ConfigureHttpClientDefaults(http =>
        {
            // Resilience: retries, circuit breaker, timeouts
            http.AddStandardResilienceHandler();

            // Service discovery: resolve service names to addresses
            http.AddServiceDiscovery();
        });

        return builder;
    }

    public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
        where TBuilder : IHostApplicationBuilder
    {
        // Logging
        builder.Logging.AddOpenTelemetry(logging =>
        {
            logging.IncludeFormattedMessage = true;
            logging.IncludeScopes = true;
        });

        builder.Services.AddOpenTelemetry()
            // Metrics
            .WithMetrics(metrics =>
            {
                metrics
                    .AddAspNetCoreInstrumentation()
                    .AddHttpClientInstrumentation()
                    .AddRuntimeInstrumentation();
            })
            // Tracing
            .WithTracing(tracing =>
            {
                tracing
                    .AddSource(builder.Environment.ApplicationName)
                    .AddAspNetCoreInstrumentation(options =>
                        // Exclude health checks from traces
                        options.Filter = context =>
                            !context.Request.Path.StartsWithSegments(HealthEndpointPath) &&
                            !context.Request.Path.StartsWithSegments(AlivenessEndpointPath))
                    .AddHttpClientInstrumentation();
            });

        builder.AddOpenTelemetryExporters();

        return builder;
    }

    private static TBuilder AddOpenTelemetryExporters<TBuilder>(this TBuilder builder)
        where TBuilder : IHostApplicationBuilder
    {
        // Use OTLP exporter if endpoint is configured (Aspire Dashboard, Jaeger, etc.)
        var useOtlp = !string.IsNullOrWhiteSpace(
            builder.Configuration["OTEL_EXPORTER_OTLP_ENDPOINT"]);

        if (useOtlp)
        {
            builder.Services.AddOpenTelemetry().UseOtlpExporter();
        }

        return builder;
    }

    public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder)
        where TBuilder : IHostApplicationBuilder
    {
        builder.Services.AddHealthChecks()
            .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"]);

        return builder;
    }

    /// <summary>
    /// Maps health check endpoints. Call after UseRouting().
    /// </summary>
    public static WebApplication MapDefaultEndpoints(this WebApplication app)
    {
        // Only expose in development - see security note below
        if (app.Environment.IsDevelopment())
        {
            // Readiness: all health checks must pass
            app.MapHealthChecks(HealthEndpointPath);

            // Liveness: only "live" tagged checks
            app.MapHealthChecks(AlivenessEndpointPath, new HealthCheckOptions
            {
                Predicate = r => r.Tags.Contains("live")
            });
        }

        return app;
    }
}

Usage in Services

API Service
csharp
var builder = WebApplication.CreateBuilder(args);

// Add all service defaults
builder.AddServiceDefaults();

// Add your services
builder.Services.AddControllers();

var app = builder.Build();

// Map health endpoints
app.MapDefaultEndpoints();

app.MapControllers();
app.Run();
Worker Service
csharp
var builder = Host.CreateApplicationBuilder(args);

// Works for non-web hosts too
builder.AddServiceDefaults();

builder.Services.AddHostedService<MyWorker>();

var host = builder.Build();
host.Run();

Adding Custom Health Checks

csharp
public static TBuilder AddDefaultHealthChecks<TBuilder>(this TBuilder builder)
    where TBuilder : IHostApplicationBuilder
{
    builder.Services.AddHealthChecks()
        // Basic liveness
        .AddCheck("self", () => HealthCheckResult.Healthy(), ["live"])

        // Database readiness
        .AddNpgSql(
            builder.Configuration.GetConnectionString("postgres")!,
            name: "postgres",
            tags: ["ready"])

        // Redis readiness
        .AddRedis(
            builder.Configuration.GetConnectionString("redis")!,
            name: "redis",
            tags: ["ready"])

        // Custom check
        .AddCheck<MyCustomHealthCheck>("custom", tags: ["ready"]);

    return builder;
}

Adding Custom Trace Sources

For Akka.NET or custom ActivitySources:

csharp
public static TBuilder ConfigureOpenTelemetry<TBuilder>(this TBuilder builder)
    where TBuilder : IHostApplicationBuilder
{
    builder.Services.AddOpenTelemetry()
        .WithTracing(tracing =>
        {
            tracing
                .AddSource(builder.Environment.ApplicationName)
                // Akka.NET tracing
                .AddSource("Akka.NET")
                // Custom sources
                .AddSource("MyApp.Orders")
                .AddSource("MyApp.Payments")
                .AddAspNetCoreInstrumentation()
                .AddHttpClientInstrumentation();
        });

    return builder;
}

Production Health Checks

For production, protect health endpoints or use different paths:

csharp
public static WebApplication MapDefaultEndpoints(this WebApplication app)
{
    // Always map for Kubernetes probes, but consider:
    // - Using internal-only ports
    // - Adding authorization
    // - Rate limiting

    app.MapHealthChecks("/health", new HealthCheckOptions
    {
        // Only return status, not details
        ResponseWriter = (context, report) =>
        {
            context.Response.ContentType = "text/plain";
            return context.Response.WriteAsync(report.Status.ToString());
        }
    });

    app.MapHealthChecks("/alive", new HealthCheckOptions
    {
        Predicate = r => r.Tags.Contains("live"),
        ResponseWriter = (context, report) =>
        {
            context.Response.ContentType = "text/plain";
            return context.Response.WriteAsync(report.Status.ToString());
        }
    });

    return app;
}

Integration with AppHost

The AppHost automatically configures OTLP endpoints:

csharp
// AppHost/Program.cs
var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres");
var redis = builder.AddRedis("redis");

var api = builder.AddProject<Projects.MyApp_Api>("api")
    .WithReference(postgres)
    .WithReference(redis);

builder.Build().Run();

Services receive OTEL_EXPORTER_OTLP_ENDPOINT automatically, sending telemetry to the Aspire Dashboard.


Best Practices

PracticeReason
One ServiceDefaults projectConsistent config across all services
Filter health checks from tracesReduces noise in observability data
Tag health checksSeparate liveness from readiness
Use StandardResilienceHandlerBuilt-in retry, circuit breaker, timeout
Add custom trace sourcesCapture domain-specific spans

Resources

© Aaronontheweb, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/aspire-service-defaults of Aaronontheweb/dotnet-skills.

Open the folder on GitHubat commit 29878f2

Used in 1 other repository

We found 1 copy of this SKILL.md (exact, near-identical or edited) in other folders, from 1 other GitHub owner. This page covers the copy in Aaronontheweb/dotnet-skills, which our catalogue first saw on October 7, 2026.

Compare with similar skills

Aspire Service Defaults next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Aspire Service Defaults compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Aspire Service Defaults this skillAaronontheweb/dotnet-skills1.2k1 repos~2.6kAutomated safety check: PassMIT
Otel Dotnetollygarden/opentelemetry-agent-skills106—~988Automated safety check: PassApache-2.0
Sentry Advanced Troubleshootingjeremylongshore/tons-of-skills-marketplace2.8k—~3.7kAutomated safety check: PassMIT
Domain Cloud Nativemoeru-ai/auv1001 repos~1kAutomated safety check: PassApache-2.0
Otel Instrumentationatherio-danp/cde-dotnetcc109—~1.3kAutomated safety check: NotesNone
Dotnet Devopsnovotnyllc/dotnet-artisan232—~1.1kAutomated safety check: PassMIT

Similar skills

  • Otel Dotnet

    ollygarden/opentelemetry-agent-skills

    OpenTelemetry in .NET — DI/builder SDK setup (OpenTelemetry.Extensions.Hosting, AddOpenTelemetry, UseOtlpExporter, OpenTelemetrySdk.Create), native .NET instrumentation APIs (ActivitySource…

    106 GitHub stars~988 tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • Sentry Advanced Troubleshooting

    jeremylongshore/tons-of-skills-marketplace

    Advanced Sentry troubleshooting for complex SDK issues, silent event drops, source map failures, distributed tracing gaps, and SDK conflicts.

    2.8k GitHub stars~3.7k tokensUpdated yesterday
    DevOps & CloudAuto-check passed
  • A skill your agent uses when building cloud-native apps. An agent skill from moeru-ai/auv.

    100 GitHub starsUsed in 1 repo~1k tokens
    DevOps & CloudAuto-check passed
  • Otel Instrumentation

    atherio-danp/cde-dotnetcc

    Add or change OpenTelemetry tracing, metrics, and structured logging in the .NET API (apps/api) — OTLP exporter setup, custom ActivitySource spans, IMeterFactory metrics, log/trace correlation.

    109 GitHub stars~1.3k tokensUpdated 2 mo ago
    DevOps & CloudAuto-check: notes
  • Dotnet Devops

    novotnyllc/dotnet-artisan

    Configures .NET CI/CD pipelines (GitHub Actions with setup-dotnet, NuGet cache, reusable workflows; Azure DevOps with DotNetCoreCLI, templates, multi-stage), containerization (multi-stage…

    232 GitHub stars~1.1k tokensUpdated 3 days ago
    DevOps & CloudAuto-check passed
  • Logging

    Resgrid/Core

    Observability for .NET 10 applications. An agent skill from Resgrid/Core.

    229 GitHub stars~1.4k tokensUpdated today
    DevOps & CloudAuto-check passed

More from Aaronontheweb/dotnet-skills

All 35 skills in this repo
  • .NET Trimming and Native AOT

    Aaronontheweb/dotnet-skills

    Guides making .NET libraries trimming-safe and Native-AOT compatible: the MSBuild properties, trimming attributes, warning codes and a playbook of safe patterns.

    1.2k GitHub stars~2.9k tokensUpdated today
    Auto-check passed
  • Cscheck

    Aaronontheweb/dotnet-skills

    Write and simplify C property-based, model-based, and executable specification tests with CsCheck.

    1.2k GitHub stars~1.2k tokensUpdated today
    Auto-check passed
  • Akka.Hosting Actor Patterns

    Aaronontheweb/dotnet-skills

    Shows how to build entity actors with Akka.Hosting so the same code runs in local unit tests and in a sharded cluster in production.

    1.2k GitHub starsUsed in 1 repo~5k tokens
    Auto-check passed
  • SDK Container Publishing

    Aaronontheweb/dotnet-skills

    Publish .NET services as container images with the built-in SDK tooling (dotnet publish /t:PublishContainer, Microsoft.NET.Build.Containers) - no Dockerfile required.

    1.2k GitHub stars~1.9k tokensUpdated today
    Auto-check passed
  • Akka.NET Best Practices

    Aaronontheweb/dotnet-skills

    Guidance for Akka.NET actor systems covering EventStream versus DistributedPubSub, supervision, Props versus DependencyResolver, work distribution and testable cluster code.

    1.2k GitHub starsUsed in 1 repo~3.3k tokens
    Auto-check passed
  • Akka.NET Management and Discovery

    Aaronontheweb/dotnet-skills

    Sets up Akka.Management and Cluster.Bootstrap so Akka.NET clusters form through service discovery on Kubernetes, Azure or config instead of static seed nodes.

    1.2k GitHub starsUsed in 1 repo~2.5k tokens
    Auto-check passed

Questions about Aspire Service Defaults

What does Aspire Service Defaults do?

Sets up a shared ServiceDefaults project for .NET Aspire apps that centralizes OpenTelemetry, health checks, HTTP resilience and service discovery for every service. The skill describes a shared project that each service references and activates by calling AddServiceDefaults(). It bundles OpenTelemetry for logs, traces and metrics, readiness and liveness health endpoints, automatic service discovery, and HTTP resilience with retry and circuit breaker policies.

When should I use Aspire Service Defaults?

Aspire Service Defaults fits situations like: starting an Aspire distributed application that needs shared observability; adding consistent logging, tracing and metrics across services; configuring shared health checks for readiness and liveness; setting up HttpClient resilience and service discovery.

How do I install Aspire Service Defaults in Claude Code?

Run `npx skills add Aaronontheweb/dotnet-skills --skill aspire-service-defaults -a claude-code`. Or copy the skill folder (skills/aspire-service-defaults in Aaronontheweb/dotnet-skills) into .claude/skills/aspire-service-defaults in your project. Claude Code loads it when a task matches its description.

How do I install Aspire Service Defaults in Codex?

Run `npx skills add Aaronontheweb/dotnet-skills --skill aspire-service-defaults -a codex`. Or copy the skill folder (skills/aspire-service-defaults in Aaronontheweb/dotnet-skills) into .agents/skills/aspire-service-defaults in your project. Codex loads it when a task matches its description.

Can I use Aspire Service Defaults in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add Aaronontheweb/dotnet-skills --skill aspire-service-defaults -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/aspire-service-defaults, .gemini/skills/aspire-service-defaults, .github/skills/aspire-service-defaults and .opencode/skills/aspire-service-defaults in your project.

What does Aspire Service Defaults need to run?

SKILL.md names no scripts, command-line tools or credentials: Aspire Service Defaults is instructions for the agent only. Our summary lists: A .NET Aspire solution.

Does Aspire Service Defaults access the network?

SKILL.md names 2 domains. As links in the text: learn.microsoft.com and opentelemetry.io. This is read from the text; nothing was executed.

Is Aspire Service Defaults safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Aspire Service Defaults use?

Aspire Service Defaults is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Aspire Service Defaults use?

About 2.6k tokens (SKILL.md is roughly 10k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Aspire Service Defaults?

Skills that share tags, products or a category with Aspire Service Defaults: Otel Dotnet (ollygarden/opentelemetry-agent-skills, 106 stars), Sentry Advanced Troubleshooting (jeremylongshore/tons-of-skills-marketplace, 2.8k stars), Domain Cloud Native (moeru-ai/auv, 100 stars) and Otel Instrumentation (atherio-danp/cde-dotnetcc, 109 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Aspire Service Defaults?

Aaronontheweb (a GitHub user) maintains it in Aaronontheweb/dotnet-skills, which has 1,209 GitHub stars. The repository holds 35 skills in this directory. The repository was last updated on October 10, 2026.

Source: Aaronontheweb/dotnet-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.