The Complete Production SOP: How to Deploy and Run DocFX .NET API Documentation Engine in Autonomous AI Agents
Deploy the DocFX .NET API Documentation Engine skill in Codex, Claude Code, & Cursor. Master docfx.json setup, static site building, and sandbox rules.
Technical Overview & Architectural Context
Autonomous coding agents frequently stumble when generating .NET technical documentation portals. Left unguided, agents attempt ad-hoc Markdown exports, miss compiler-generated XML doc outputs, or corrupt DocFX file patterns—such as attempting to compile directly from source files without parsing Roslyn workspaces or failing to link conceptual documentation with auto-extracted API references. This leads to broken cross-reference links (`xref`), missing parameter tags, unindexed static files, and broken client-side search engines in the output portal. The DocFX .NET API Documentation Engine skill establishes deterministic boundaries around the compilation and extraction lifecycles. By defining rigid Standard Operating Procedures (SOPs) for configuring `docfx.json`, running `docfx metadata` to transform .NET symbols into structured YAML, and running `docfx build` against standard templates (such as `modern` or `default`), the agent operates within a predictable state machine. It prevents hallucinated flags, enforces XML comment schema compliance (`<summary>`, `<param>`, `<returns>`), and verifies that static outputs compile cleanly without leaking local file paths.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the DocFX .NET API documentation skill into your agent runtime's global or workspace skill registry.
Autonomous agents discover procedural capabilities via standardized `SKILL.md` manifests. For Claude Code and Codex, place the skill into the local or project `.agents/skills` registry. For Cursor and Windsurf, link it through project rules (`.cursorrules` or `.windsurfrules`) or workspace context folders so the LLM parses the YAML frontmatter and triggers before executing documentation tasks.
mkdir -p .agents/skills/docfx-dotnet-api-documentation && curl -fsSL https://askills.dev/api/skills/docfx-dotnet-api-documentation/raw -o .agents/skills/docfx-dotnet-api-documentation/SKILL.md---
name: "docfx-dotnet-api-documentation"
description: "Generate cross-platform technical documentation and .NET API references with DocFX."
metadata:
author: "Microsoft / .NET Foundation"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "generate dotnet api docs docfx"
- "configure docfx.json"
- "build static docfx website"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---
# DocFX .NET API Documentation Engine
Extracts XML documentation comments from C#, VB.NET, and F# source code, merging conceptual Markdown articles into a unified searchable static documentation portal.To save context tokens across multi-turn sessions, store reference YAML schemas outside the system prompt and allow the agent to read `docfx.json` only when the specific trigger fires.
Ensure that `fs_write` is constrained to the workspace root. Agents running without workspace sandboxing might attempt to emit generated static artifacts into system temporary folders that are deleted upon process teardown.
Toolchain Verification & docfx.json Blueprint Initialization
Verify the .NET DocFX toolchain and establish the baseline configuration file.
Ensure `docfx` is registered as a local or global .NET tool. Then instruct the agent to inspect project solution files (`.sln` or `.csproj`) and create a deterministic `docfx.json` configuration targeting metadata extraction and static HTML compilation.
dotnet new tool-manifest --force && dotnet tool install docfx && dotnet docfx init -q{
"$schema": "https://raw.githubusercontent.com/dotnet/docfx/main/schemas/docfx.schema.json",
"metadata": [
{
"src": [
{
"src": "../src",
"files": ["**/*.csproj"]
}
],
"dest": "api",
"includePrivateMembers": false
}
],
"build": {
"content": [
{
"files": ["api/**.yml", "api/index.md"]
},
{
"files": ["articles/**.md", "toc.yml", "*.md"]
}
],
"resource": [
{
"files": ["images/**"]
}
],
"output": "_site",
"template": ["default", "modern"]
}
}Always configure `"$schema"` in `docfx.json`. This provides instant schema validation inside Cursor and Claude Code workspace linters, preventing agent hallucinations of invalid keys.
Relative paths in `docfx.json` are evaluated relative to the configuration file location, not the terminal execution root. Misaligned `src` paths are the leading cause of empty API documentation runs.
Intent Matching & Trigger Invocation
Invoke the skill using explicit trigger phrases and verified agent parameters.
Provide a high-fidelity natural language instruction containing frontmatter triggers such as 'configure docfx.json' or 'generate dotnet api docs docfx'. The agent activates the procedural SOP, analyzes the C# code, verifies `<GenerateDocumentationFile>true</GenerateDocumentationFile>` in project files, and prepares the documentation pipeline.
Explicitly mention target projects or namespaces in the prompt so the agent does not attempt to extract internal unit test assemblies.
If `<GenerateDocumentationFile>` is omitted from `.csproj` files, Roslyn will not emit compiler XML comments, causing DocFX to generate empty API description blocks.
Verification, Linting & Output Quality Gate
Execute the two-stage DocFX compilation pipeline and audit the generated static site.
Run `docfx metadata` followed by `docfx build` with warnings treated as errors or strictly monitored. The agent reviews the generated `_site/` directory, checks that `xref` resolution succeeded, and tests local serving via `docfx --serve`.
dotnet docfx docs/docfx.json --warningsAsErrors#!/usr/bin/env bash
set -euo pipefail
echo "Validating DocFX build output..."
dotnet docfx docs/docfx.json --warningsAsErrors
if [ ! -f "docs/_site/index.html" ] || [ ! -d "docs/_site/api" ]; then
echo "Error: Expected static documentation files were not generated."
exit 1
fi
echo "DocFX documentation compiled successfully."Check `docs/_site/xrefmap.yml` to confirm that all public types have been assigned resolvable cross-reference UIDs for seamless API interlinking.
Enabling `--warningsAsErrors` will fail the build if any public API lacks XML tags or contains malformed Markdown in comments. Treat this as an automated code-quality safeguard.
Real-World Scenario: Automating API Documentation for an ASP.NET Core Clean Architecture Service
“Using the docfx-dotnet-api-documentation skill, configure docfx.json for our payment gateway solution in /src/PaymentGateway.Core.csproj and /src/PaymentGateway.Infrastructure.csproj. Build static docfx website into docs/_site using the modern template and ensure missing XML doc comments are flagged.”
Runtime Troubleshooting & Failure Modes
Root Cause: DocFX metadata extraction requires the underlying .NET dependencies to be restored before Roslyn can parse project symbols.
dotnet restore && dotnet build --no-incrementalRoot Cause: DocFX does not have Microsoft external reference packages or feeds configured, causing framework base types to fail UID resolution.
Add external references in `docfx.json` under build:
"xref": ["https://learn.microsoft.com/en-us/dotnet/api/xrefmap.yml"]Frequently Asked Questions (DocFX .NET API Documentation Engine SOP)
Q:Can I use DocFX .NET API Documentation Engine across Codex, Claude Code, and Cursor simultaneously?
Yes. The skill conforms to the universal SKILL.md specification. Once installed in `.agents/skills` or referenced in IDE workspace rules, any compatible runtime parses the trigger schema and executes the deterministic build pipeline.
Q:How does DocFX .NET API Documentation Engine prevent context window overflow during long agent sessions?
The skill instructs agents to run `docfx` via the CLI and inspect summarized exit codes and warnings rather than dumping megabytes of generated YAML metadata or HTML files into the LLM conversation context.
Q:Does this skill require escalated root or container permissions?
No. The skill operates with a verified security score of 98/100. It requires only standard workspace filesystem write permissions (`fs_write: workspace`) to emit artifacts into `docs/_site/` and requires no root privileges or elevated shell escape sequences.
Ready to equip your autonomous agent with DocFX .NET API Documentation Engine?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.