nginx-c-module-design
Original:🇺🇸 English
Translated
nginx C module directive design guidelines for creating admin-friendly configuration interfaces. This skill should be used when designing nginx module directives — deciding what to expose vs hardcode, naming conventions, scope placement, default values, variable design, and validation patterns. Triggers on tasks involving ngx_command_t design, directive naming, configuration API design, nginx module public interface, or directive deprecation.
1installs
Sourcepproenca/dot-skills
Added on
NPX Install
npx skill4agent add pproenca/dot-skills nginx-c-module-designTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →nginx.org C Module Directive Design Best Practices
Comprehensive directive design guide for nginx C module authors, focused on creating clear, consistent, and admin-friendly configuration interfaces. Contains 46 rules across 8 categories, prioritized by impact to guide decisions about what to expose, how to name it, and how to evolve it safely.
When to Apply
Reference these guidelines when:
- Deciding which values to expose as directives vs hardcode
- Naming new directives and choosing argument types
- Selecting scope placement (http, server, location)
- Setting default values and validation behavior
- Designing nginx variables for runtime data
- Deprecating or renaming existing directives
Companion Skills
This skill focuses on design decisions (the "what" and "why"). For implementation mechanics, see:
- nginx-c-modules — C implementation: memory pools, request lifecycle, config parsing, handlers, filters
- nginx-c-perf — Performance: buffers, connections, locks, caching, timeouts
- nginx-c-debug — Debugging: crash diagnosis, GDB, tracing, sanitizers
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Exposure Decisions | CRITICAL | |
| 2 | Naming Conventions | CRITICAL | |
| 3 | Directive Types | HIGH | |
| 4 | Scope Design | HIGH | |
| 5 | Default Values | MEDIUM-HIGH | |
| 6 | Validation & Error Messages | MEDIUM | |
| 7 | Variable Design | MEDIUM | |
| 8 | Evolution & Compatibility | LOW-MEDIUM | |
Quick Reference
1. Exposure Decisions (CRITICAL)
- - Framework for Configurable vs Hardcoded Values
expose-configurable-vs-hardcode - - Provide Escape Hatches for Hardcoded Defaults
expose-escape-hatch - - Use Feature Gates for Optional Behavior
expose-feature-gate - - Avoid Over-Configuration
expose-too-many-directives - - Always Expose External Resource Paths
expose-path-resource - - Audit Security Implications of Every Exposed Directive
expose-security-surface - - Expose Values That Vary by Deployment Environment
expose-environment-dependent
2. Naming Conventions (CRITICAL)
- - Use a Consistent Module Prefix for All Directives
naming-module-prefix - - Group Related Directives with Sub-Prefixes
naming-sub-prefix-groups - - Prefer Noun Phrases for Directive Names
naming-noun-over-verb - - Avoid Custom Abbreviations in Directive Names
naming-no-abbreviations - - Mirror Nginx Core Suffix Patterns for Analogous Directives
naming-cross-module-consistency - - Use Lowercase with Underscores Only
naming-lowercase-underscore
3. Directive Types (HIGH)
- - Use NGX_CONF_FLAG for Binary Toggles
type-flag-for-toggles - - Use Enum Slot for Known Value Sets
type-enum-over-string - - Use Time and Size Slot Functions for Time and Size Values
type-time-size-units - - Use TAKE1/TAKE2/TAKE12 for Fixed Argument Counts
type-take-n-fixed-args - - Use 1MORE for Variable-Length Value Lists
type-one-more-lists - - Avoid Block Directives for Features
type-avoid-block - - Use Custom Handlers for Complex Directive Parsing
type-custom-handler-complex
4. Scope Design (HIGH)
- - Default to http + server + location Scope
scope-default-three-levels - - Restrict Shared Resource Directives to http Level Only
scope-http-only-shared-resources - - Use http + server Scope for Connection-Level Settings
scope-server-connection-level - - Do Not Support the if Context Unless Fully Tested
scope-avoid-if-context - - Restrict Path-Routing Directives to Location Context
scope-location-path-operations
5. Default Values (MEDIUM-HIGH)
- - Ensure Zero-Config Produces Safe Behavior
default-zero-config-safe - - Make Performance Features Opt-In
default-performance-optin - - Default Security Settings to Restrictive Values
default-safety-on - - Default Timeouts to Generous Values
default-generous-timeouts - - Use Zero to Mean Unlimited or Disabled for Numeric Limits
default-zero-unlimited - - Use Platform-Aware Buffer Size Defaults
default-platform-aware-buffers
6. Validation & Error Messages (MEDIUM)
- - Validate All Directive Values at Config Parse Time
valid-parse-time-check - - Include the Invalid Value in Error Messages
valid-show-invalid-value - - Include Valid Range or Format in Error Messages
valid-suggest-range - - Detect Conflicting Directives at Merge Time
valid-conflict-detection - - Provide Actionable Guidance in Error Messages
valid-actionable-guidance
7. Variable Design (MEDIUM)
- - Expose Variables for Per-Request Runtime Data Only
var-runtime-data-only - - Name Variables with Module Prefix and Descriptive Suffix
var-naming-convention - - Use Dynamic Prefix Variables for Key-Value Data
var-dynamic-prefix - - Leverage Lazy Evaluation for Expensive Variables
var-lazy-evaluation - - Support Variables in Directive Values Only When Per-Request Variation Is Needed
var-in-directive-values - - Expose Read-Only Diagnostic Variables for Observability
var-read-only-diagnostics
8. Evolution & Compatibility (LOW-MEDIUM)
- - Log Warnings for Deprecated Directives Before Removal
compat-deprecation-warning - - Keep Old Directive Name as an Alias
compat-alias-old-directive - - Maintain a Multi-Version Deprecation Window
compat-multi-version-window - - Document Migration Path in Both Old and New Directive Documentation
compat-document-migration
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions - Category structure and impact levels
- Rule template - Template for adding new rules
Reference Files
| File | Description |
|---|---|
| references/_sections.md | Category definitions and ordering |
| assets/templates/_template.md | Template for new rules |
| metadata.json | Version and reference information |