Skip to content

Commit 66283c9

Browse files
mcj-coderclaude
andcommitted
docs: consolidate skills with decision matrices and hierarchy
Phase 2 of Skills Repository Improvement Plan: - Logging: Demote dotnet-logging-serilog to deprecated, add serilog-implementation.md to observability-logging-baseline references - Security: Add decision matrices to security-processes, static-analysis-security, and quality-gate-enforcement showing when to use each - Bootstrapping: Add hierarchy documentation to greenfield-baseline, automated-standards-enforcement, and repo-best-practices-bootstrap - Testing: Add decision tree to testing-strategy-agnostic for skill selection All skills now have clear "Do NOT use when" guidance and cross-references. Refs: #381 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 7f0561a commit 66283c9

File tree

10 files changed

+525
-2
lines changed

10 files changed

+525
-2
lines changed

skills/automated-standards-enforcement/SKILL.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: automated-standards-enforcement
33
description: Use when creating or modifying any repository to establish automated quality enforcement (linting, spelling, tests, SAST, security). Applies by default unless user explicitly refuses. Ensures clean build policy with minimal developer friction.
4+
metadata:
5+
type: Platform
6+
priority: P0
47
---
58

69
# Automated Standards Enforcement
@@ -11,6 +14,37 @@ description: Use when creating or modifying any repository to establish automate
1114

1215
**REQUIRED:** superpowers:verification-before-completion, superpowers:test-driven-development
1316

17+
## Bootstrapping Skills Decision Matrix
18+
19+
Use this matrix to select the appropriate bootstrapping skill:
20+
21+
| If You Need To... | Use This Skill |
22+
| ------------------------------------------------------------ | ------------------------------------------ |
23+
| Start a new project from scratch | greenfield-baseline |
24+
| Add/audit quality tooling (linting, tests, SAST) | **automated-standards-enforcement** (this) |
25+
| Add/audit repo security (branch protection, secret scanning) | repo-best-practices-bootstrap |
26+
27+
### Skill Scope Comparison
28+
29+
| Aspect | greenfield-baseline | automated-standards-enforcement | repo-best-practices-bootstrap |
30+
| ----------------- | ---------------------------- | ------------------------------- | ----------------------------- |
31+
| **Primary Focus** | Project foundation | Quality tooling | Repo security/compliance |
32+
| **Project State** | New (no existing code) | New or existing | New or existing |
33+
| **Outputs** | Repo structure, CI/CD, docs | Linting, tests, SAST config | Branch rules, secrets config |
34+
| **Triggers** | Entry point for new projects | Auto-triggered or standalone | Use after structure exists |
35+
36+
### Invocation Context
37+
38+
- **Greenfield projects**: Auto-triggered by greenfield-baseline
39+
- **Brownfield projects**: Invoke directly with brownfield approach
40+
- **Existing repos**: Invoke directly for quality tooling audit/addition
41+
42+
### Do NOT Use This Skill When
43+
44+
- Starting a brand new project (use greenfield-baseline, which triggers this skill)
45+
- Only need repo security/compliance (use repo-best-practices-bootstrap)
46+
- Quality tooling already exists and passes (no changes needed)
47+
1448
## When to Use
1549

1650
- Creating/modifying repository

skills/dotnet-logging-serilog/SKILL.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
---
22
name: dotnet-logging-serilog
33
description: Standardise logging on ILogger with Serilog as the provider; ensure startup exceptions are logged as Critical.
4+
metadata:
5+
status: deprecated
6+
superseded-by: observability-logging-baseline
47
---
58

9+
> **DEPRECATED**: This skill has been consolidated into `observability-logging-baseline`.
10+
>
11+
> - For comprehensive observability guidance (logs, metrics, traces), use
12+
> **`observability-logging-baseline`**
13+
> - For .NET-specific Serilog patterns, see
14+
> **`observability-logging-baseline/references/serilog-implementation.md`**
15+
>
16+
> This skill remains for backwards compatibility but will not receive updates.
17+
618
## Core
719

820
### When to use

skills/greenfield-baseline/SKILL.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
---
22
name: greenfield-baseline
33
description: Use when starting a new project from scratch to establish proper foundation with quality gates, repository structure, CI/CD, and development standards before any feature work begins.
4+
metadata:
5+
type: Platform
6+
priority: P2
47
---
58

69
# Greenfield Baseline
@@ -14,6 +17,41 @@ standards that prevent technical debt from day one.
1417

1518
**REQUIRED:** superpowers:verification-before-completion, superpowers:test-driven-development
1619

20+
## Bootstrapping Skills Decision Matrix
21+
22+
Use this matrix to select the appropriate bootstrapping skill:
23+
24+
| If You Need To... | Use This Skill |
25+
| ------------------------------------------------------------ | ------------------------------- |
26+
| Start a new project from scratch | **greenfield-baseline** (this) |
27+
| Add/audit quality tooling (linting, tests, SAST) | automated-standards-enforcement |
28+
| Add/audit repo security (branch protection, secret scanning) | repo-best-practices-bootstrap |
29+
30+
### Skill Scope Comparison
31+
32+
| Aspect | greenfield-baseline | automated-standards-enforcement | repo-best-practices-bootstrap |
33+
| ----------------- | ---------------------------- | -------------------------------- | ----------------------------- |
34+
| **Primary Focus** | Project foundation | Quality tooling | Repo security/compliance |
35+
| **Project State** | New (no existing code) | New or existing | New or existing |
36+
| **Outputs** | Repo structure, CI/CD, docs | Linting, tests, SAST config | Branch rules, secrets config |
37+
| **Triggers** | Entry point for new projects | Triggered by greenfield-baseline | Use after structure exists |
38+
39+
### Invocation Order for New Projects
40+
41+
```text
42+
1. greenfield-baseline (establish project structure)
43+
├── automated-standards-enforcement (quality tooling - auto-triggered)
44+
└── repo-best-practices-bootstrap (security config - invoke after)
45+
2. walking-skeleton-delivery (E2E validation - invoke after baseline)
46+
```
47+
48+
### Do NOT Use This Skill When
49+
50+
- Project has existing code or structure (this is brownfield - use automated-standards-enforcement
51+
with brownfield strategy)
52+
- Only need to add quality tooling (use automated-standards-enforcement directly)
53+
- Only need security/compliance audit (use repo-best-practices-bootstrap directly)
54+
1755
## When to Use
1856

1957
- Creating a brand new project or repository
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# References
2+
3+
Reference materials for observability logging baseline, including platform-specific
4+
implementation guides.
5+
6+
## Contents
7+
8+
| File | Description |
9+
| ------------------------------------------------------ | -------------------------------------------------------------------- |
10+
| [serilog-implementation.md](serilog-implementation.md) | .NET-specific Serilog implementation patterns for structured logging |
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
# Serilog Implementation for .NET
2+
3+
This reference provides .NET-specific guidance for implementing structured logging with Serilog,
4+
complementing the platform-agnostic guidance in the main observability-logging-baseline skill.
5+
6+
## Overview
7+
8+
Serilog is the recommended logging provider for .NET applications. It provides:
9+
10+
- Structured logging with message templates
11+
- Rich sink ecosystem for log destinations
12+
- Enrichers for contextual data
13+
- Integration with Microsoft.Extensions.Logging
14+
15+
## Core Principles
16+
17+
### ILogger Abstraction
18+
19+
Application code must depend on `Microsoft.Extensions.Logging.ILogger` only:
20+
21+
```csharp
22+
public sealed class CustomerService
23+
{
24+
private readonly ILogger<CustomerService> _logger;
25+
26+
public CustomerService(ILogger<CustomerService> logger) => _logger = logger;
27+
28+
public void DoWork(CustomerId id)
29+
{
30+
_logger.LogInformation("Processing customer {CustomerId}", id);
31+
}
32+
}
33+
```
34+
35+
**Review rule**: Reject PRs that inject/use `Serilog.ILogger` directly in application code
36+
when `Microsoft.Extensions.Logging.ILogger` suffices.
37+
38+
### Startup Exception Logging
39+
40+
Exceptions during host startup must be logged at **Critical** severity:
41+
42+
```csharp
43+
using Microsoft.Extensions.Hosting;
44+
using Serilog;
45+
46+
Log.Logger = new LoggerConfiguration()
47+
.WriteTo.Console()
48+
.CreateBootstrapLogger();
49+
50+
try
51+
{
52+
var builder = Host.CreateApplicationBuilder(args);
53+
54+
builder.Services.AddSerilog((services, lc) => lc
55+
.ReadFrom.Configuration(builder.Configuration)
56+
.ReadFrom.Services(services)
57+
.Enrich.FromLogContext());
58+
59+
var app = builder.Build();
60+
61+
await app.RunAsync();
62+
}
63+
catch (Exception ex)
64+
{
65+
Log.Fatal(ex, "Host terminated unexpectedly");
66+
throw;
67+
}
68+
finally
69+
{
70+
Log.CloseAndFlush();
71+
}
72+
```
73+
74+
**Key points:**
75+
76+
- Use a bootstrap logger early to capture exceptions during host building
77+
- Log startup failures at Critical/Fatal severity
78+
- Ensure `Log.CloseAndFlush()` is called to flush buffered logs
79+
80+
## Azure Integration
81+
82+
### Application Insights
83+
84+
When running in Azure with Application Insights enabled:
85+
86+
```csharp
87+
var builder = Host.CreateDefaultBuilder()
88+
.ConfigureServices(services =>
89+
{
90+
services.AddApplicationInsightsTelemetry();
91+
})
92+
.UseSerilog((context, config) =>
93+
{
94+
var instrumentationKey = context.Configuration["ApplicationInsights:InstrumentationKey"];
95+
config
96+
.MinimumLevel.Debug()
97+
.WriteTo.ApplicationInsights(
98+
new TelemetryClient(new TelemetryConfiguration(instrumentationKey)),
99+
TelemetryConverter.Traces);
100+
});
101+
```
102+
103+
**Requirements:**
104+
105+
- Severity levels must map correctly to App Insights telemetry
106+
- Structured log properties must be preserved
107+
- Correlation/trace identifiers must be maintained
108+
109+
### OpenTelemetry Integration
110+
111+
When OpenTelemetry is present, configure Serilog to participate in the telemetry pipeline:
112+
113+
- Correlate logs with traces
114+
- Align operation and trace IDs
115+
- Support end-to-end diagnostics
116+
117+
## Unhandled Exception Handling
118+
119+
### Web Applications
120+
121+
Register global exception handling middleware early in the pipeline:
122+
123+
```csharp
124+
app.UseExceptionHandler(errorApp =>
125+
{
126+
errorApp.Run(async context =>
127+
{
128+
var logger = context.RequestServices.GetRequiredService<ILogger<Program>>();
129+
var exceptionHandler = context.Features.Get<IExceptionHandlerFeature>();
130+
131+
if (exceptionHandler?.Error != null)
132+
{
133+
logger.LogError(exceptionHandler.Error,
134+
"Unhandled exception for {Method} {Path}",
135+
context.Request.Method,
136+
context.Request.Path);
137+
}
138+
139+
context.Response.StatusCode = 500;
140+
await context.Response.WriteAsync("An error occurred");
141+
});
142+
});
143+
```
144+
145+
### Worker Services
146+
147+
Wrap top-level execution loops:
148+
149+
```csharp
150+
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
151+
{
152+
while (!stoppingToken.IsCancellationRequested)
153+
{
154+
try
155+
{
156+
await DoWorkAsync(stoppingToken);
157+
}
158+
catch (Exception ex) when (ex is not OperationCanceledException)
159+
{
160+
_logger.LogError(ex, "Error in worker execution");
161+
await Task.Delay(TimeSpan.FromSeconds(30), stoppingToken);
162+
}
163+
}
164+
}
165+
```
166+
167+
## Verification
168+
169+
### Fail-Fast Startup Test
170+
171+
```csharp
172+
[Fact]
173+
public async Task Host_StartupWithLoggingError_LogsExceptionAsCritical()
174+
{
175+
// Arrange: Create a host with intentionally broken configuration
176+
var logs = new List<LogEvent>();
177+
178+
var builder = Host.CreateDefaultBuilder()
179+
.ConfigureServices(services =>
180+
{
181+
services.AddSingleton(new BrokenDependency()); // Throws during startup
182+
})
183+
.UseSerilog((context, config) =>
184+
{
185+
config
186+
.MinimumLevel.Debug()
187+
.WriteTo.Sink(new CollectingSink(logs));
188+
});
189+
190+
// Act & Assert: Verify exception is logged as Critical before propagating
191+
var ex = await Assert.ThrowsAsync<InvalidOperationException>(
192+
() => builder.Build().RunAsync());
193+
194+
// Verify Critical-level log entry exists
195+
var criticalLog = logs.FirstOrDefault(le => le.Level == LogEventLevel.Fatal);
196+
Assert.NotNull(criticalLog);
197+
Assert.Contains(typeof(InvalidOperationException).Name, criticalLog.MessageTemplate.Text);
198+
}
199+
```
200+
201+
### Startup Logging Checklist
202+
203+
- [ ] Bootstrap logger captures exceptions before host configuration completes
204+
- [ ] Startup exceptions are logged at **Critical** (or **Fatal**) severity
205+
- [ ] Exception details (stack trace, message) are included in the log
206+
- [ ] Correlation/trace IDs are present if available
207+
- [ ] Logs flow to Application Insights (if configured)
208+
- [ ] No startup exceptions are silently swallowed
209+
210+
## Operational Hygiene
211+
212+
### Enrichment
213+
214+
```csharp
215+
.Enrich.FromLogContext()
216+
.Enrich.WithMachineName()
217+
.Enrich.WithEnvironmentName()
218+
.Enrich.WithProperty("Application", "MyApp")
219+
```
220+
221+
### PII Redaction
222+
223+
Enforce PII/secret redaction policies:
224+
225+
```csharp
226+
.Destructure.ByTransforming<CreditCard>(cc => new
227+
{
228+
Last4 = cc.Number.Substring(cc.Number.Length - 4),
229+
cc.ExpiryMonth,
230+
cc.ExpiryYear
231+
})
232+
```
233+
234+
### Sink Configuration
235+
236+
| Environment | Recommended Sinks |
237+
| ----------- | ------------------------------------------ |
238+
| Local/Dev | Console (coloured, structured) |
239+
| Staging | Console + File + Centralized (e.g., Seq) |
240+
| Production | Centralized sink (Seq, App Insights, etc.) |
241+
242+
## Review Rules
243+
244+
- Reject PRs that inject/use `Serilog.ILogger` directly when `ILogger` suffices
245+
- Reject PRs that swallow startup exceptions without Critical-level logging
246+
- Ensure logs are structured (properties) rather than string concatenation
247+
- Verify startup failures are captured by bootstrap logger

0 commit comments

Comments
 (0)