
C# Documentation Best Practices
OfficialFreeEnhance your C# code documentation with XML comments.
Free · Opens the source repo
What C# Documentation Best Practices does
The C# Documentation Best Practices skill provides a comprehensive guide for documenting C# types and members using XML comments. This skill emphasizes the importance of clear and concise documentation, ensuring that public members are well-documented while also encouraging documentation of internal members, especially those that are complex or not self-explanatory. By following these best practices, developers can improve code readability and maintainability, making it easier for others (and themselves) to understand the code in the future.
The skill outlines specific XML tags and their appropriate usage, such as <summary>, <remarks>, <param>, and <returns>. Each tag serves a distinct purpose, from providing a brief description of a member to detailing method parameters and return values. For example, the <summary> tag should start with a present-tense verb, while <param> descriptions should be noun phrases that do not specify data types. This structured approach helps maintain consistency across documentation, which is crucial for larger projects or teams.
Additionally, the skill covers how to document exceptions, constructors, properties, and methods in a way that is both informative and easy to follow. By adhering to these guidelines, developers can ensure that their documentation meets industry standards, which can be particularly beneficial when working in collaborative environments or when creating libraries intended for public use.
Overall, this skill is ideal for C# developers looking to enhance their documentation practices and ensure their code is accessible and understandable to others. By implementing these best practices, developers can foster better collaboration and reduce the learning curve for new team members or users of their code.
When to use it
Use this skill when you want to ensure that your C# code is documented according to best practices, especially for public APIs.
When not to use it
This skill may not be necessary for small, personal projects where documentation is not a priority or when working in languages other than C#.
What you can build with it
Documenting a Public API
When creating a public API, use this skill to ensure all public members are documented with clear XML comments.
Improving Team Collaboration
In a team environment, apply these documentation standards to enhance code readability and facilitate easier onboarding for new developers.
Documenting Complex Internal Logic
For complex internal methods, utilize this skill to provide detailed documentation that clarifies their purpose and usage.
How to install C# Documentation Best Practices
View source1. Install with the skills CLI
npx skills add github/awesome-copilot/csharp-docs --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by githubC# Documentation Best Practices
- Public members should be documented with XML comments.
- It is encouraged to document internal members as well, especially if they are complex or not self-explanatory.
Guidance for all APIs
- Use
<summary>to provide a brief, one sentence, description of what the type or member does. Start the summary with a present-tense, third-person verb. - Use
<remarks>for additional information, which can include implementation details, usage notes, or any other relevant context. - Use
<see langword>for language-specific keywords likenull,true,false,int,bool, etc. - Use
<c>for inline code snippets. - Use
<example>for usage examples on how to use the member.- Use
<code>for code blocks.<code>tags should be placed within an<example>tag. Add the language of the code example using thelanguageattribute, for example,<code language="csharp">.
- Use
- Use
<see cref>to reference other types or members inline (in a sentence). - Use
<seealso>for standalone (not in a sentence) references to other types or members in the "See also" section of the online docs. - Use
<inheritdoc/>to inherit documentation from base classes or interfaces.- Unless there is major behavior change, in which case you should document the differences.
Methods
- Use
<param>to describe method parameters.- The description should be a noun phrase that doesn't specify the data type.
- Begin with an introductory article.
- If the parameter is a flag enum, start the description with "A bitwise combination of the enumeration values that specifies...".
- If the parameter is a non-flag enum, start the description with "One of the enumeration values that specifies...".
- If the parameter is a Boolean, the wording should be of the form "
<see langword="true" />to ...; otherwise,<see langword="false" />.". - If the parameter is an "out" parameter, the wording should be of the form "When this method returns, contains .... This parameter is treated as uninitialized.".
- Use
<paramref>to reference parameter names in documentation. - Use
<typeparam>to describe type parameters in generic types or methods. - Use
<typeparamref>to reference type parameters in documentation. - Use
<returns>to describe what the method returns.- The description should be a noun phrase that doesn't specify the data type.
- Begin with an introductory article.
- If the return type is Boolean, the wording should be of the form "
<see langword="true" />if ...; otherwise,<see langword="false" />.".
Constructors
- The summary wording should be "Initializes a new instance of the <Class> class [or struct].".
Properties
- The
<summary>should start with:- "Gets or sets..." for a read-write property.
- "Gets..." for a read-only property.
- "Gets [or sets] a value that indicates whether..." for properties that return a Boolean value.
- Use
<value>to describe the value of the property.- The description should be a noun phrase that doesn't specify the data type.
- If the property has a default value, add it in a separate sentence, for example, "The default is
<see langword="false" />". - If the value type is Boolean, the wording should be of the form "
<see langword="true" />if ...; otherwise,<see langword="false" />. The default is ...".
Exceptions
- Use
<exception cref>to document exceptions thrown by constructors, properties, indexers, methods, operators, and events. - Document all exceptions thrown directly by the member.
- For exceptions thrown by nested members, document only the exceptions users are most likely to encounter.
- The description of the exception describes the condition under which it's thrown.
- Omit "Thrown if ..." or "If ..." at the beginning of the sentence. Just state the condition directly, for example "An error occurred when accessing a Message Queuing API."
Frequently asked questions about C# Documentation Best Practices
Similar skills
Markdown to HTML Conversion
Efficiently convert Markdown documents to HTML.
Code Tour
Create structured walkthroughs for codebases.
Acquire Codebase Knowledge
Streamline onboarding with comprehensive codebase documentation.
Documentation & Modernization
Streamline codebase documentation and modernization planning.
Azure Resource Visualizer
Generate architecture diagrams for Azure resources.
CLAUDE.md Improver
Optimize your CLAUDE.md files for better project context.
