agentleFS
fadwenfadwen/ai-powershell-standards/.github/skills/powershell-write-tests/SKILL.md

powershell-write-tests

Skill24 starsChanged 3 days agoMITView on GitHub

Write or extend Pester 6 tests for existing PowerShell code, following this repository's testing rules. Use when asked to add tests, raise coverage, or test a PowerShell function, script, or module.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read .github/instructions/powershell-pester.instructions.md first, unless it is already loaded.

    line 8
  2. Very specific:

    Read the code under test completely: its parameters and parameter sets, validation attributes, output type, every catch, and every call …

    line 13
  3. Very specific:

    Look at an existing test file in the repository.

    line 16
  4. Very specific:

    Write the file so that it runs on its own: a versioned #Requires for Pester, the code loaded in a top-level BeforeAll, and test data built …

    line 20
  5. Distinctive:

    Run the tests. A test that passes on its first run has not been shown to work: break the behaviour it covers, or the expected value, once …

    line 26

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Write Pester tests for PowerShell code

Read .github/instructions/powershell-pester.instructions.md first, unless it is already loaded. It holds the rules, a complete test file, and a table of assertion behaviour.

Steps

  1. Read the code under test completely: its parameters and parameter sets, validation attributes, output type, every catch, and every call that leaves the process (network, files, other modules, the clock).
  2. Look at an existing test file in the repository. Keep its assertion style and layout. In a new file use the Pester 6 Should-* assertions.
  3. List the behaviours to test before writing any: each parameter set, the documented output, each validation failure, each error path, pipeline input, and for a Test- function both outcomes.
  4. Write the file so that it runs on its own: a versioned #Requires for Pester, the code loaded in a top-level BeforeAll, and test data built in BeforeDiscovery.
  5. Mock only what crosses a boundary. For code inside a module, pass -ModuleName to Mock and Should-Invoke, and reach private functions with InModuleScope.
  6. Make every test able to fail: assert specific values, assert the count before reading by index, and assert expected errors with Should-Throw or by counting error records.
  7. Run the tests. A test that passes on its first run has not been shown to work: break the behaviour it covers, or the expected value, once to see it fail, then restore it.

Report

Say which behaviours are covered and which are not, the pass and fail counts, and the coverage figure if you measured it. If a test exposes a defect in the code, report the defect; do not weaken the test to make it pass, and do not change the code under test unless the user asked for that.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.