| applyTo | src/**/*.ps1,tests/**/*.ps1,scripts/**/*.ps1,run.ps1,reload.ps1 |
|---|
Use this file when changing src/public/, src/private/, or PowerShell build/release helpers.
- Keep public command files small and delegating.
- Keep exactly one top-level public function per file in
src/public/. - Match the file name to that top-level public function name.
- Public mutating commands should support PowerShell
ShouldProcesssemantics. - Preserve existing naming and command model conventions for public commands/functions such as
Invoke-Nova*,Get-Nova*,Update-Nova*, and thenovaCLI routing model. - Do not create or maintain hand-written module
.psm1or module.psd1files in source. Nova generates the built module root and manifest underdist/NovaModuleTools/fromproject.jsonandsrc/**/*.ps1.
- Put internal helpers in the correct domain folder under
src/private/. - In
src/private/, keep at most one externally called function per file and match the file name to that entry function. - Additional functions in a private file are allowed only as related top-level support helpers called from that same file.
- If two private functions are both called from outside their file, split them into separate same-named files.
- Do not declare functions inside other functions. Keep private support helpers as sibling top-level functions in the file instead of nested function declarations.
- Private helper names should not use the public
Invoke-Nova*,Get-Nova*,Update-Nova*, ornovaCLI route naming conventions. Give private helpers clear implementation-focused names that describe what the helper does. - Reuse existing adapters and shared helpers before adding new infrastructure calls.
- Keep direct environment access, Git execution, upload requests, and self-update execution in their approved helper locations.
tests/ArchitectureGuardrails.Tests.ps1is authoritative. - Prefer explicit workflow-context objects (
[pscustomobject]/ ordered hashtables) for multi-step flows.
- Prefer clear, structured Nova errors over silent fallback behavior.
- Preserve existing warning semantics; do not rename warning opt-ins to a generic
-Forcepattern. - Keep CLI spellings and PowerShell spellings distinct in messages and docs.
- Read
project.jsonManifest.PowerShellHostVersionbefore changing PowerShell source, scripts, or tests, and keep new usage compatible with that target. A5.1project must not receive PowerShell 7.x-only syntax, cmdlets, parameters, or APIs unless compatibility is explicitly guarded and within scope. - Follow
.github/instructions/psscriptanalyzer.instructions.mdas the ScriptAnalyzer workflow source of truth. Use the repository analyzer wrapper for normal runs and reuse repository-approved settings when invokingInvoke-ScriptAnalyzerdirectly on a focused path. - When public command help changes, follow
.github/instructions/platyps-help.instructions.mdand useNew-MarkdownCommandHelp,Update-MarkdownCommandHelp, andTest-MarkdownCommandHelpinstead of hand-authoring the help structure. - Do not add PSScriptAnalyzer
ExcludeRule,ExcludeRules, suppression attributes, or generated settings that hide analyzer findings. Fix the rule violation instead. - Keep local quality wrappers ordered as ScriptAnalyzer first, then
Invoke-NovaBuild, thenInvoke-NovaTest, thenTest-NovaBuild. - If
run.ps1orInvoke-ScriptAnalyzerCI.ps1reports ScriptAnalyzer findings, fix them before treating the change as complete.
- Use spaces, not hard tabs.
- Use 4 spaces per indentation level.
- Indent block contents one level inside
function,if,switch,foreach,for,while,try,catch,finally,class, and method bodies. - When an expression wraps onto the next line, indent the continuation line one extra level instead of trying to align it visually to a previous token column.
- Use one space between language keywords and
(in control statements such asif (...),foreach (...),switch (...),while (...), andfor (...). - Use one space before an opening
{. - Use one space around binary, comparison, and logical operators.
- Use one space after commas in parameter and argument lists.
- Prefer
-notover!for logical negation. - Prefer full cmdlet names in standard PowerShell casing; do not introduce aliases.
- Prefer
[int]$Countstyle type literals without an extra space before the variable name.
- Use same-line opening braces for functions, control statements,
try/catch/finally,switchlabels, classes, and methods. - Keep
elseif,else,catch, andfinallyon the same line as the preceding closing brace. - Keep closing braces on their own line.
- Prefer multi-line
param(...), hashtables, and long argument sets over overly long single lines. - When wrapping an expression, keep the operator on the preceding line when it reads naturally.
- Use a single blank line between logical sections of a function when it improves readability.
- Do not stack multiple blank lines.
- Avoid decorative blank lines inside short blocks.
- Keep one blank line between top-level declarations when a file contains more than one declaration.
- Every changed or generated text file, including
.ps1files, must end with exactly one trailing newline and no extra blank lines at the bottom.
- Use
.github/instructions/code-quality-matrix.instructions.mdas the best-effort source-code maintainability guidance forsrc/**/*.ps1; keep new or heavily changed code short, single-purpose, low-duplication, and split by clear responsibility. - Favor short functions and extracted helpers over large nested logic.
- Replace long
switchorif/elseifchains with lookup tables, dispatch helpers, or focused strategy functions when behavior varies by mode, provider, or state. - Avoid copy/paste across source or test files.
- Remove dead code and commented-out code instead of leaving it behind.
- Prefer concise, specific names over identifiers that hide multiple responsibilities.
- Replace magic values with named constants, lookup tables, or variables that reveal intent.
- Add comments only when the code would otherwise be hard to follow.
- Avoid broad catch blocks that hide failures; catch specific exceptions only when the layer can add useful context.
- Update or add Pester coverage for behavior changes.
- Recheck
tests/ArchitectureGuardrails.Tests.ps1when changing layering or helper placement. - Run
./run.ps1before considering a code change complete. - Resolve any ScriptAnalyzer findings that
./run.ps1reports before handoff. - Before handoff, review the changed/generated text files and normalize any file endings that violate the single-trailing-newline rule.