一键导入
planforge-new-config
Scaffold strongly-typed configuration with IOptions<T>, validation, and environment-specific overrides.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold strongly-typed configuration with IOptions<T>, validation, and environment-specific overrides.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Run a comprehensive code review across architecture, security, testing, naming, and patterns. Invokes relevant reviewer agents in sequence. Use before merging features or at the end of a phase. With --quorum, dispatches multi-model analysis for higher confidence.
Audit UI components for WCAG 2.2 compliance, semantic HTML, ARIA labels, keyboard navigation, color contrast, and responsive design.
Audit API endpoints for backward compatibility, versioning, OpenAPI compliance, pagination, rate limiting, and RFC 9457 error responses.
Review code for architecture violations: layer separation, sync-over-async, missing CancellationToken, improper DI. Use for PR reviews or code audits.
Fix a bug using TDD: reproduce with a failing test first, then implement the fix, then verify. Prevents regressions.
Review CI/CD pipelines for best practices: environment promotion, secrets management, rollback strategies, build caching, and deployment safety.
| name | planforge-new-config |
| description | Scaffold strongly-typed configuration with IOptions<T>, validation, and environment-specific overrides. |
| metadata | {"author":"plan-forge","source":".github/prompts/new-config.prompt.md"} |
Scaffold a strongly-typed configuration class bound from appsettings.json using the Options pattern.
public class {SectionName}Options
{
public const string SectionName = "{SectionName}";
[Required, Url]
public string BaseUrl { get; set; } = string.Empty;
[Required]
public string ApiKey { get; set; } = string.Empty;
[Range(1, 300)]
public int TimeoutSeconds { get; set; } = 30;
public int RetryCount { get; set; } = 3;
}
builder.Services
.AddOptions<{SectionName}Options>()
.BindConfiguration({SectionName}Options.SectionName)
.ValidateDataAnnotations()
.ValidateOnStart(); // Fail fast if config is invalid
{
"{SectionName}": {
"BaseUrl": "https://api.example.com",
"ApiKey": "",
"TimeoutSeconds": 30,
"RetryCount": 3
}
}
{
"{SectionName}": {
"ApiKey": "#{APIKEY_FROM_KEYVAULT}#"
}
}
// Prefer IOptions<T> for singleton config; IOptionsSnapshot<T> for scoped/reloadable
public class MyService
{
private readonly {SectionName}Options _options;
public MyService(IOptions<{SectionName}Options> options)
{
_options = options.Value;
}
}
public class {SectionName}OptionsValidator : IValidateOptions<{SectionName}Options>
{
public ValidateOptionsResult Validate(string? name, {SectionName}Options options)
{
if (string.IsNullOrWhiteSpace(options.ApiKey))
return ValidateOptionsResult.Fail("ApiKey is required.");
if (options.TimeoutSeconds < 1)
return ValidateOptionsResult.Fail("TimeoutSeconds must be at least 1.");
return ValidateOptionsResult.Success;
}
}
// Register:
builder.Services.AddSingleton<IValidateOptions<{SectionName}Options>,
{SectionName}OptionsValidator>();
ValidateOnStart() — fail fast on startup, not at first requestIConfiguration directly — always bind to typed Options classesappsettings.json — use User Secrets, Key Vault, or env varsIOptions<T> for singleton lifetime, IOptionsSnapshot<T> for scoped/reloadableConfiguration/ or Options/ folder