Skip to main content
skill CX Codex

scalar — Claude Code skill: .NET 10 API docs UI

A skill that walks the agent through wiring Scalar into a .NET 10 app as a Swagger UI replacement, with themes, auth prefill and multiple documents.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add codewithmukesh/dotnet-claude-kit --skill scalar -a claude-code
Open on GitHub

What scalar does

The skill hands the agent working code for Scalar, the API documentation UI for .NET 10. It covers the basic MapScalarApiReference() setup, themes like ScalarTheme.Mars and Moon, auth prefill, multiple OpenAPI documents, a custom route prefix and the Swagger-like classic layout.

One rule comes up again and again: wrap MapScalarApiReference() in an IsDevelopment() check. API docs expose internal structure, so in production you add .RequireAuthorization(). The "Try It" feature routes through proxy.scalar.com by default — for APIs with sensitive data, disable it with .WithProxy(null) so auth headers stay local.

Scalar reads security schemes from the OpenAPI document. Setting WithPreferredScheme("Bearer") alone does nothing until a document transformer such as BearerSecuritySchemeTransformer is registered. The skill also lists anti-patterns: real tokens in prefill, Swagger UI in new .NET 10 projects.

What it helps with

  • swap Swagger UI for Scalar in a .NET 10 project
  • lock down the API docs page with authorization in production
  • disable the external proxy so tokens don't flow through proxy.scalar.com
  • serve several API versions from one documentation UI
  • set a theme, force dark mode or switch to the classic layout

Example prompts for the agent

  • Wire up Scalar in my ASP.NET Core .NET 10 project instead of Swagger UI
  • Configure Scalar with the Mars theme and Bearer token prefill for development
  • Add two Scalar documents, v1 and v2-beta, and require authorization in production

How to install scalar

1Skills CLI (Vercel)

npx skills add codewithmukesh/dotnet-claude-kit --skill scalar -a claude-code

2Manually: put the files in place

~/.claude/skills/scalar/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/scalar/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about scalar

How do I install scalar in Claude?

Run npx skills add codewithmukesh/dotnet-claude-kit --skill scalar -a claude-code. The skill file lands at ~/.claude/skills/scalar/SKILL.md.

What does the scalar skill do?

It gives the agent templates and rules for setting up Scalar, the API documentation UI for .NET 10: setup, themes, authentication, multiple documents and production hardening.

Why does WithPreferredScheme("Bearer") show no auth in Scalar?

Scalar reads security schemes from the OpenAPI document. Register a document transformer like BearerSecuritySchemeTransformer first, otherwise the scheme setting has nothing to work with.

Source text

SKILL.md · MIT
---
name: scalar
description: >
  Scalar API documentation UI for .NET 10 applications. Covers setup, themes,
  authentication prefill, multiple documents, layout options, and security.
  A modern replacement for Swagger UI.
  Load this skill when setting up API documentation UI, or when the user mentions
  "Scalar", "MapScalarApiReference", "API reference", "Swagger UI replacement",
  "API documentation UI", "Scalar theme", "interactive API docs", or "Try It".
---

# Scalar

## Core Principles

1. **Scalar replaces Swagger UI** — Scalar is the recommended API documentation UI for .NET 10. Faster rendering, built-in dark mode, code generation for dozens of languages, and full OpenAPI 3.1 support.
2. **Development only by default** — Wrap `MapScalarApiReference()` in an `IsDevelopment()` check. API documentation exposes internal structure. If needed in production, add authorization.
3. **Disable the proxy for sensitive APIs** — Scalar's "Try It" feature routes through `proxy.scalar.com` by default. Disable it with `.WithProxy(null)` to keep auth headers local.
4. **Security schemes come from OpenAPI** — Scalar reads security schemes from the OpenAPI document. Configure them via document transformers, not in Scalar directly.

## Patterns

### Basic Setup

```csharp
using Scalar.AspNetCore;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();

var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
    app.MapScalarApiReference();  // UI at /scalar/v1
}

app.Run();
```

### Customized Configuration

```csharp
app.MapScalarApiReference(options =>
{
    options
        .WithTitle("Checkout API")
        .WithTheme(ScalarTheme.Mars)
        .WithDefaultHttpClient(ScalarTarget.CSharp, ScalarClient.HttpClient)
        .WithPreferredScheme("Bearer")
        .WithProxy(null)  // Disable external proxy
        .WithSidebar(true);
});
```

### Authentication Prefill (Development Only)

Pre-fill credentials so developers don't have to paste tokens manually. The OpenAPI document must already include the security scheme via a document transformer.

```csharp
if (app.Environment.IsDevelopment())
{
    app.MapScalarApiReference(options =>
    {
        options
            .WithPreferredScheme("Bearer")
            .AddHttpAuthentication("Bearer", auth =>
            {
                auth.Token = "dev-only-test-token";
            });
    });
}
```

Other auth types:

```csharp
// API Key
options.WithApiKeyAuthentication(apiKey =>
{
    apiKey.Token = "dev-api-key";
});

// OAuth2
options.WithOAuth2Authentication(oauth =>
{
    oauth.ClientId = "your-client-id";
    oauth.Scopes = ["openid", "profile"];
});
```

### Available Themes

```csharp
// ScalarTheme options: Default, Moon, Purple, BluePlanet, Saturn, Mars, DeepSpace, Kepler, Solarized, Laserwave
options.WithTheme(ScalarTheme.Mars);
```

### Multiple API Documents

```csharp
// Register multiple OpenAPI documents
builder.Services.AddOpenApi("v1");
builder.Services.AddOpenApi("v2-beta");

// Scalar picks them up automatically
app.MapOpenApi();
app.MapScalarApiReference();
// Available at /scalar/v1 and /scalar/v2-beta
```

Or configure documents explicitly:

```csharp
app.MapScalarApiReference(options =>
{
    options
        .AddDocument("v1", "Production API")
        .AddDocument("v2-beta", "Beta API", isDefault: true);
});
```

### Custom Route Prefix

```csharp
// Default is /scalar/{documentName}
app.MapScalarApiReference("/api-docs");
// Now at /api-docs/v1
```

### Production with Authorization

```csharp
// When partners need access to docs in production
app.MapOpenApi().RequireAuthorization("ApiDocs");
app.MapScalarApiReference().RequireAuthorization("ApiDocs");
```

### Force Dark Mode

```csharp
options.ForceDarkMode();
```

### Classic Layout (Swagger-like)

```csharp
options.WithClassicLayout();
```

## Anti-patterns

### Don't Expose Scalar in Production Without Auth

```csharp
// BAD — anyone can see your API structure
app.MapOpenApi();
app.MapScalarApiReference();

// GOOD — development only
if (app.Environment.IsDevelopment())
{
    app.MapOpenApi();
    app.MapScalarApiReference();
}

// GOOD — production with auth
app.MapOpenApi().RequireAuthorization("ApiDocs");
app.MapScalarApiReference().RequireAuthorization("ApiDocs");
```

### Don't Pre-fill Real Credentials

```csharp
// BAD — real tokens visible in browser
options.AddHttpAuthentication("Bearer", auth =>
{
    auth.Token = "eyJhbG...real-production-token";
});

// GOOD — dev-only test tokens
if (app.Environment.IsDevelopment())
{
    options.AddHttpAuthentication("Bearer", auth =>
    {
        auth.Token = "dev-only-test-token";
    });
}
```

### Don't Forget the Security Scheme Transformer

```csharp
// BAD — no auth UI in Scalar because OpenAPI doc has no security schemes
builder.Services.AddOpenApi();
app.MapScalarApiReference(options =>
{
    options.WithPreferredScheme("Bearer"); // Does nothing!
});

// GOOD — register the document transformer first
builder.Services.AddOpenApi(options =>
{
    options.AddDocumentTransformer<BearerSecuritySchemeTransformer>();
});
app.MapScalarApiReference(options =>
{
    options.WithPreferredScheme("Bearer");
});
```

### Don't Leave the Proxy Enabled for Sensitive APIs

```csharp
// BAD — auth headers flow through proxy.scalar.com
app.MapScalarApiReference();

// GOOD — disable proxy for APIs with sensitive data
app.MapScalarApiReference(options =>
{
    options.WithProxy(null);
});
```

### Don't Use Swagger UI for New .NET 10 Projects

```csharp
// BAD — Swashbuckle removed from templates, maintenance concerns
builder.Services.AddSwaggerGen();
app.UseSwaggerUI();

// GOOD — built-in OpenAPI + Scalar
builder.Services.AddOpenApi();
app.MapOpenApi();
app.MapScalarApiReference();
```

## Decision Guide

| Scenario | Recommendation |
|----------|---------------|
| API documentation UI | `MapScalarApiReference()` with `MapOpenApi()` |
| Development environment | Default setup with `IsDevelopment()` guard |
| Production API docs | Add `.RequireAuthorization()` to both endpoints |
| Auth testing in dev | `AddHttpAuthentication()` with test tokens |
| Dark theme preference | `.ForceDarkMode()` or `.WithTheme(ScalarTheme.Moon)` |
| Multiple API versions | Multiple `AddOpenApi()` calls — Scalar detects automatically |
| Sensitive APIs | `.WithProxy(null)` to disable external proxy |
| Swagger-like layout | `.WithClassicLayout()` |
| Custom route | `app.MapScalarApiReference("/api-docs")` |

© codewithmukesh · MIT · codewithmukesh/dotnet-claude-kit

Similar skills

Everything for Backend and APIs →

From the same set46

caching Guides caching work in .NET 10 applications with HybridCache, response caching, and distributed cache patterns. Use it when reducing database reads or planning cache invalidation. CX Codex +1 2,800installs health-check Grades a .NET project across eight dimensions with letter marks A–F and a rolled-up GPA. Useful at onboarding, before a release, and after a cleanup sprint. CX Codex +1 2,800installs openapi Configures native OpenAPI generation in .NET 10 without Swashbuckle. Helps the agent handle transformers, TypedResults metadata, and security schemes. CX Codex +1 2,800installs configuration Guides .NET 10 configuration with typed options, validation, and secret handling. Use it when working with appsettings files or environment variables. CX Codex +1 2,800installs opentelemetry Configures OpenTelemetry traces, metrics, and logs in .NET 10 applications using OTLP export and IMeterFactory. CX Codex +1 2,800installs messaging A .NET skill that walks your agent through Wolverine or MassTransit setup, the outbox pattern, sagas, and RabbitMQ or Azure Service Bus brokers. CX Codex +1 2,800installs project-structure A skill that tells your agent how to lay out a .NET solution: central package versions, shared build properties, .slnx format and naming rules. CX Codex +1 2,800installs httpclient-factory Guides AI coding agents in configuring IHttpClientFactory and typed clients in .NET 10. Useful when building resilient HTTP pipelines and preventing socket exhaustion. CX Codex +1 2,800installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor