agentleFS
afittestideafittestide/asimi/.agents/skills/write-tests/SKILL.md

write-tests

Skill16 starsChanged 7 days agoMITView on GitHub

Patterns and conventions for writing tests

78 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use close-spec, design-with-images and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • dzhngSkill

    close-spec

    When a spec under specs/<feature>/ is done shipping (a write-spec build, or any planned task that produced a spec), archive it to specs/done/ and rewrite it from a build-plan into a durable rationale — the why, the principles, the invariants — pointing back to the real code for the how. Use when implementation has landed and the plan no longer matches what shipped, or the user says a feature/spec is finished. Pairs with [write-spec](../write-spec/SKILL.md) (the plan this closes) and [review](../review/SKILL.md) (run before closing).

    Also in 5 projects that use this

  • dzhngSkill

    design-with-images

    Explore UI and visual design with image generation, then iterate the real implementation against the user-selected concept. Use when brainstorming visual directions, offering mockup variants, or implementing an approved generated design; do not stop at the mockups or the first code approximation.

    Also in 5 projects that use this

  • transitive-bullshitSkill

    compare-screenshots

    Compare screenshots against the intended design, distinguishing approved references from historical baselines. Use for iterative implementation matching, before/after visual review, objective image telemetry, or checking a lone capture for flat, empty, or badly framed content.

    Also in 5 projects that use this

  • LucasMatuszewskiSkill

    audit-agents

    Audit and maintain agent configuration files (.claude/agents, AGENTS.md, CLAUDE.md, agent-memory). Checks for duplicates, outdated info, naming conflicts, wrong technical facts, and files over 200 lines. Fixes all issues and commits.

    Also in 5 projects that use this

  • wolverin0Skill

    audit-decisions

    Standardize remediation decisions, baseline-policy entries, and legal-review banners for accepted, deferred, or policy-blocked audit findings.

    Also in 4 projects that use this

  • rhnfzlSkill

    explore-unknowns

    Walk the user through mapping the unknowns of a task before, during, and after they build it, and hand them a four-quadrant map (settled ground, open decisions, taste, and landmines) they keep. Reach for this eagerly whenever a request is ambiguous or underspecified, the codebase or domain is unfamiliar, the user will "know it when they see it", a reference implementation must be understood before porting, a build-queue or architecture-changing task is about to start, a mid-build deviation needs capturing, or a finished change needs buy-in or verified understanding before merge. Trigger even when the skill is not named: "do a blindspot pass", "find my unknown unknowns", "interview me about this change", "brainstorm the approach for a task I am about to build", "help me scope this", "what am I missing here", "plan this before I build", "I know nothing about X in this codebase". When a territory profile is present it reads memory and the graph first and feeds the map into the build pipeline; without one it degrades to a plain general map. Not for trivial or mechanical tasks with clear acceptance criteria, single-fact lookups, pure debugging of a known symptom, or pure code review, those have their own tools. Do not use it to run the build itself; the map is the deliverable and implementation remains a separate task, whether it has not started or is already underway.

    Also in 5 projects that use this

  • +5 more from dzhng

The file

We split this skill into the rules it gives an agent

3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 73 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Every scenario follows this flow:

    line 57
  2. Very specific:

    Create your .feature file in intent/gherkin/

    line 77
  3. Very specific:

    Create a new intent_gherkin_<topic>_steps_test.go file

    line 78

“Common” is measured: kept by at least 6 in 10 of the 73 edited versions of this file we could read. “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

Gherkin Feature Files — Specification & Convention

The project uses Godog (v0.16.0) with Gherkin to write behavioral specifications that are also executable tests.

Feature File Location

Features live in intent/gherkin/:

intent/gherkin/
├── e729_chat_session_restore.feature
├── e739_peer_credential_verification.feature
└── rituals/
    ├── continue.feature
    ├── ctrl_c_between_steps.feature
    └── ctrl_c_simple.feature
  • Root level — Features covering a single edict: e<edict_id>_<short_name>.feature
  • rituals/ — Features about ritual behavior (multiple edicts)
  • One feature file per spec scope (not per test file)

Anatomy of a Feature

Feature: <Title> — <Subtitle>
  As a <role>
  I want <capability>
  So that <benefit>

  Background:                                    # optional; runs before each scenario
    Given some shared precondition
    And another precondition

  Scenario: <description of one behavior>
    Given a specific precondition
    When something happens
    Then verify the outcome
    And verify another outcome

Background

The Background block (if present) sets up the test state before every Scenario. Step definitions use ctx.Before(...) to reset state per-scenario.

Scenario Structure

Every scenario follows this flow:

  1. Given — Arrange: set up the test model, mocks, and preconditions
  2. When — Act: trigger the behavior under test
  3. Then — Assert: verify outputs, mock calls, state mutations

For the judge, feature files should be verifiable — each Then step should have a corresponding assertion in the step definition code.

Step Definitions

Step definitions live in intent_gherkin_*_test.go at the project root:

intent_gherkin_test.go               # Main test runner (TestIntentGherkin)
intent_gherkin_steps_test.go         # Step defs for edict chat sessions
intent_gherkin_continue_steps_test.go # Step defs for :continue command

Adding Step Definitions for a New Feature

  1. Create your .feature file in intent/gherkin/
  2. Create a new intent_gherkin_<topic>_steps_test.go file
  3. Define a state struct for the test:
type myTestState struct {
    model *TUIModel
    mock  *mockCourtClient
}
  1. Register step definitions in a register<Name>StepDefs function:
func registerMyFeatureStepDefs(ctx *godog.ScenarioContext, t *testing.T) {
    s := &myTestState{}

    ctx.Before(func(ctx context.Context, sc *godog.Scenario) (context.Context, error) {
        *s = *newMyFeatureState(t)  // Fresh state per scenario
        return ctx, nil
    })

    ctx.Step(`^a precondition exists$`, func() error {
        // Arrange
        return nil
    })

    ctx.Step(`^the user does something$`, func() error {
        // Act
        return nil
    })

    ctx.Step(`^the result should be "([^"]*)"$`, func(expected string) error {
        // Assert
        if actual != expected {
            return fmt.Errorf("expected %q, got %q", expected, actual)
        }
        return nil
    })
}
  1. Register it in intent_gherkin_test.go:
func TestIntentGherkin(t *testing.T) {
    suite := godog.TestSuite{
        Name: "intent-gherkin",
        ScenarioInitializer: func(ctx *godog.ScenarioContext) {
            registerEdictChatStepDefs(ctx, t)
            registerContinueStepDefs(ctx, t)
            registerMyFeatureStepDefs(ctx, t)     // <-- Add here
        },
        Options: &godog.Options{
            Format:   "pretty",
            Paths:    []string{"intent/gherkin"},
            TestingT: t,
        },
    }

    if suite.Run() != 0 {
        t.Fatal("non-zero status returned, failed to run feature tests")
    }
}

Key Infrastructure

The test infrastructure uses:

  • mockCourtClient — a mock for the CourtClient interface with configurable function fields (getEdictFn, pauseRitualFn, sealsFn, submitPromptFn, etc.) and tracking counters (submitPromptCalls, pausedChannels, resumedChannels, publishedEvents)
  • TUIModel — the main TUI model created via newTestModel(t) which includes tabs, chat, and mock court wiring
  • newTestModel(t) — returns a *TUIModel with DismissWelcome() already called
  • handleContinueCommand(model, args) — processes :continue commands and returns a command function func() runners.Msg

Writing Effective Feature Files

Good

Scenario: PauseRitual returns true when no step is running
  Given no step cancel is registered for the channel
  When PauseRitual is called for the channel
  Then PauseRitual returns true
  And a pause channel is created for the channel
  And the ritual goroutine is not cancelled

Avoid

  • Implementation details — focus on behavior, not line numbers or internal variable names visible to the test
  • Underspecified steps — "something happens" without defining what "something" is
  • Too many scenarios per file — split by feature area

Running Feature Tests

# Run all Gherkin feature tests
go test -v -run TestIntentGherkin ./...

# Run with coverage
go test -v -run TestIntentGherkin -coverprofile=coverage.out ./...

Feature files are executable specifications — they are run as Go tests via the Godog test suite runner. A failing scenario means either the code doesn't match the specification, or the specification is stale.

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.