| name | tasks-documentation |
| description | Use for WRITING documentation with ready-to-use code templates (C# XML docs, TypeScript JSDoc, API docs, README patterns). Best for implementing actual documentation, adding code comments, and creating docs from scratch. NOT for documentation planning (use documentation instead). |
Documentation Workflow
When to Use This Skill
- Creating API documentation
- Writing code comments
- Updating README files
- Generating architecture documentation
Documentation Types
1. Code Comments
- XML docs for public APIs
- Inline comments for complex logic
- TODO/FIXME for technical debt
2. API Documentation
- Endpoint descriptions
- Request/response schemas
- Error codes and handling
3. Architecture Documentation
- Component diagrams
- Data flow documentation
- Integration guides
Pattern 1: C# XML Documentation
public sealed class SaveEmployeeCommand : PlatformCqrsCommand<SaveEmployeeCommandResult>
{
public string? Id { get; set; }
public string Name { get; set; } = string.Empty;
}
public static Expression<Func<Employee, bool>> UniqueExpr(string companyId, string userId)
=> e => e.CompanyId == companyId && e.UserId == userId;
Pattern 2: TypeScript JSDoc
@Injectable()
export class FeatureListStore extends PlatformVmStore<FeatureListState> {
public loadItems = this.effectSimple(() => );
public setFilters(filters: Partial<FeatureFilters>): void {
}
}
export interface FeatureDto {
id: string;
name: string;
status: FeatureStatus;
}
Pattern 3: API Endpoint Documentation
[ApiController]
[Route("api/[controller]")]
[PlatformAuthorize]
public class EmployeeController : PlatformBaseController
{
[HttpGet]
[ProducesResponseType(typeof(GetEmployeeListQueryResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status400BadRequest)]
public async Task<IActionResult> GetList([FromQuery] GetEmployeeListQuery query)
=> Ok(await Cqrs.SendAsync(query));
[HttpPost]
[ProducesResponseType(typeof(SaveEmployeeCommandResult), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)]
public async Task<IActionResult> Save([FromBody] SaveEmployeeCommand command)
=> Ok(await Cqrs.SendAsync(command));
}
Pattern 4: README Documentation
# Feature Name
Brief description of what this feature does.
## Overview
More detailed explanation of the feature's purpose and functionality.
## Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Frontend │────▶│ API Layer │────▶│ Domain Layer │
│ Component │ │ Controller │ │ Entity │
└─────────────────┘ └──────────────────┘ └─────────────────┘
## Usage
### Backend
```csharp
// Example usage
var command = new SaveFeatureCommand { Name = "Example" };
var result = await handler.HandleAsync(command, cancellationToken);
Frontend
this.store.loadItems();
Configuration
| Setting | Description | Default |
|---|
MaxItems | Maximum items per page | 50 |
CacheTimeout | Cache duration in seconds | 300 |
API Endpoints
| Method | Endpoint | Description |
|---|
| GET | /api/feature | List features |
| POST | /api/feature | Create/update feature |
| DELETE | /api/feature/{id} | Delete feature |
Error Handling
| Code | Description |
|---|
| 400 | Invalid request data |
| 404 | Feature not found |
| 409 | Conflict (duplicate) |
Related
- Entity documentation examples in this section
- API reference examples in this section
## Pattern 5: Inline Code Comments
```csharp
protected override async Task<SaveEmployeeCommandResult> HandleAsync(
SaveEmployeeCommand request, CancellationToken cancellationToken)
{
// Step 1: Determine if this is a create or update operation
var isCreate = request.Id.IsNullOrEmpty();
// Step 2: Get or create the entity
var employee = isCreate
? request.MapToNewEntity()
.With(e => e.CreatedBy = RequestContext.UserId())
: await repository.GetByIdAsync(request.Id, cancellationToken)
.EnsureFound($"Employee not found: {request.Id}")
.Then(existing => request.UpdateEntity(existing));
// Step 3: Validate business rules
// NOTE: This checks for duplicate codes within the same company
await employee.ValidateAsync(repository, cancellationToken).EnsureValidAsync();
// Step 4: Persist changes
// The repository automatically raises entity events for cross-service sync
var saved = await repository.CreateOrUpdateAsync(employee, cancellationToken);
// Step 5: Return result
return new SaveEmployeeCommandResult
{
Employee = new EmployeeDto(saved)
};
}
Documentation Guidelines
DO
- Document public APIs with XML/JSDoc
- Explain "why" not "what"
- Include usage examples
- Keep documentation close to code
- Update docs when code changes
DON'T
- State the obvious
- Leave TODO comments indefinitely
- Write documentation that duplicates code
- Create separate docs that become stale
Comment Types
| Type | When to Use |
|---|
/// <summary> | Public API documentation |
// Explanation | Complex logic explanation |
// TODO: | Planned improvements |
// FIXME: | Known issues |
// HACK: | Temporary workarounds |
// NOTE: | Important information |
Verification Checklist