install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/pproenca/dot-skills/nginx-c-module-design" ~/.claude/skills/comeonoliver-skillshub-nginx-c-module-design && rm -rf "$T"
manifest:
skills/pproenca/dot-skills/nginx-c-module-design/SKILL.mdsource content
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 Valuesexpose-configurable-vs-hardcode
- Provide Escape Hatches for Hardcoded Defaultsexpose-escape-hatch
- Use Feature Gates for Optional Behaviorexpose-feature-gate
- Avoid Over-Configurationexpose-too-many-directives
- Always Expose External Resource Pathsexpose-path-resource
- Audit Security Implications of Every Exposed Directiveexpose-security-surface
- Expose Values That Vary by Deployment Environmentexpose-environment-dependent
2. Naming Conventions (CRITICAL)
- Use a Consistent Module Prefix for All Directivesnaming-module-prefix
- Group Related Directives with Sub-Prefixesnaming-sub-prefix-groups
- Prefer Noun Phrases for Directive Namesnaming-noun-over-verb
- Avoid Custom Abbreviations in Directive Namesnaming-no-abbreviations
- Mirror Nginx Core Suffix Patterns for Analogous Directivesnaming-cross-module-consistency
- Use Lowercase with Underscores Onlynaming-lowercase-underscore
3. Directive Types (HIGH)
- Use NGX_CONF_FLAG for Binary Togglestype-flag-for-toggles
- Use Enum Slot for Known Value Setstype-enum-over-string
- Use Time and Size Slot Functions for Time and Size Valuestype-time-size-units
- Use TAKE1/TAKE2/TAKE12 for Fixed Argument Countstype-take-n-fixed-args
- Use 1MORE for Variable-Length Value Liststype-one-more-lists
- Avoid Block Directives for Featurestype-avoid-block
- Use Custom Handlers for Complex Directive Parsingtype-custom-handler-complex
4. Scope Design (HIGH)
- Default to http + server + location Scopescope-default-three-levels
- Restrict Shared Resource Directives to http Level Onlyscope-http-only-shared-resources
- Use http + server Scope for Connection-Level Settingsscope-server-connection-level
- Do Not Support the if Context Unless Fully Testedscope-avoid-if-context
- Restrict Path-Routing Directives to Location Contextscope-location-path-operations
5. Default Values (MEDIUM-HIGH)
- Ensure Zero-Config Produces Safe Behaviordefault-zero-config-safe
- Make Performance Features Opt-Indefault-performance-optin
- Default Security Settings to Restrictive Valuesdefault-safety-on
- Default Timeouts to Generous Valuesdefault-generous-timeouts
- Use Zero to Mean Unlimited or Disabled for Numeric Limitsdefault-zero-unlimited
- Use Platform-Aware Buffer Size Defaultsdefault-platform-aware-buffers
6. Validation & Error Messages (MEDIUM)
- Validate All Directive Values at Config Parse Timevalid-parse-time-check
- Include the Invalid Value in Error Messagesvalid-show-invalid-value
- Include Valid Range or Format in Error Messagesvalid-suggest-range
- Detect Conflicting Directives at Merge Timevalid-conflict-detection
- Provide Actionable Guidance in Error Messagesvalid-actionable-guidance
7. Variable Design (MEDIUM)
- Expose Variables for Per-Request Runtime Data Onlyvar-runtime-data-only
- Name Variables with Module Prefix and Descriptive Suffixvar-naming-convention
- Use Dynamic Prefix Variables for Key-Value Datavar-dynamic-prefix
- Leverage Lazy Evaluation for Expensive Variablesvar-lazy-evaluation
- Support Variables in Directive Values Only When Per-Request Variation Is Neededvar-in-directive-values
- Expose Read-Only Diagnostic Variables for Observabilityvar-read-only-diagnostics
8. Evolution & Compatibility (LOW-MEDIUM)
- Log Warnings for Deprecated Directives Before Removalcompat-deprecation-warning
- Keep Old Directive Name as an Aliascompat-alias-old-directive
- Maintain a Multi-Version Deprecation Windowcompat-multi-version-window
- Document Migration Path in Both Old and New Directive Documentationcompat-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 |