Quick start

From an empty project to a story on the map.

You need PHP 8.5 or later and Composer. Every command on this page was run in a new folder, with a hotel as the example, and the output shown is what it printed. It takes about ten minutes.

Install #

Barnspek is three Composer packages. barnspek is the library, barnspek-cli provides the vendor/bin/barnspek command, and barnspek-gui adds the browser app. From your project’s root:

$ composer require --dev rmb32/barnspek rmb32/barnspek-cli rmb32/barnspek-gui

Make a barn #

Barnspek keeps what you capture in a folder called .barn/ at the root of the project. init makes it.

$ vendor/bin/barnspek init
Made a barn: …/hotel
Barnspek keeps its spec in: …/hotel/.barn/barnspek

Commit .barn/ with your code: it is the specification. Barnspek finds it from any folder inside the project.

Capture a story #

A story says who wants something and why, in one sentence: the role wants to goal, so they reward. Roles belong to an area of business, a distinct part of what the business does. The first story creates the area of business, its role and its first Phase (a slice of work).

$ vendor/bin/barnspek create-story --area-of-business=reservations \
    --area-of-business-meaning="booking and keeping rooms" \
    --phase="first bookings" --phase-meaning="guests can book a room" \
    --role=guest --role-meaning="choosing and securing somewhere to stay" \
    --goal="book a room for a run of nights" --reward="have somewhere to stay" \
    --stage=transact
Barn: …/hotel
Story created:
  area of business: reservations (created)
  role: guest (created)
  story: book-a-room-for-a-run-of-nights (created)
  stage: transact
  story id: 01a1cb3e-…

The stage says where in a guest’s dealings with the hotel the story sits. It is optional. A second story reuses the same area of business and role, so it only needs the new words:

$ vendor/bin/barnspek create-story --area-of-business=reservations --role=guest \
    --goal="cancel their booking" --reward="are not held to a stay they will not take" \
    --stage=resolve
Barn: …/hotel
Story created:
  area of business: reservations (existing)
  role: guest (existing)
  story: cancel-their-booking (created)
  stage: resolve
  story id: 01a1cb3e-…

IDs are shortened here with “…”; yours will be longer.

Add a Scenario #

A Scenario pins a story down with one concrete case: given how things stand, when the role does something, then what holds afterwards. Save this as scenario.json:

{
    "area-of-business": "reservations",
    "role": "guest",
    "story": "book-a-room-for-a-run-of-nights",
    "actionSentence": "book a room for three nights",
    "actionParameters": {
        "nights": {"meaning": "how many nights to stay", "type": "integer", "value": 3}
    },
    "given": [
        {
            "subject": "room",
            "subjectMeaning": "a room the hotel lets to guests",
            "fact": "is-available",
            "factMeaning": "no booking holds the room on those nights"
        }
    ],
    "outcome": "accepted",
    "then": [
        {
            "subject": "booking",
            "subjectMeaning": "a guest's hold on a room for a run of nights",
            "fact": "is-confirmed",
            "factMeaning": "holds the room for the guest on these nights"
        }
    ]
}
$ vendor/bin/barnspek create-scenario --file=scenario.json
Barn: …/hotel
Scenario saved: 01a1cb3e-…

Each new word, such as room or is-available, is given its meaning the first time it appears and is reused from then on.

See what you have #

$ vendor/bin/barnspek show reservations
Barn: …/hotel
reservations — booking and keeping rooms

  role: guest — choosing and securing somewhere to stay
    story: wants to book a room for a run of nights, so that they have somewhere to stay [transact]
      phase: first-bookings
      scenario: book-a-room-for-three-nights
    story: wants to cancel their booking, so that they are not held to a stay they will not take [resolve]
      phase: first-bookings

  subject: room — a room the hotel lets to guests
    fact: is-available — no booking holds the room on those nights

  subject: booking — a guest's hold on a room for a run of nights
    fact: is-confirmed — holds the room for the guest on these nights

  action: book a room for three nights
      parameter: nights (integer) — how many nights to stay
$ vendor/bin/barnspek map --area-of-business=reservations
Barn: …/hotel
Story map — reservations

Establish
  (no stories)

Adjust
  (no stories)

Act
  The guest
    - wants to book a room for a run of nights, so they have somewhere to stay (planned)

Follow Up
  The guest
    - wants to cancel their booking, so they are not held to a stay they will not take (planned)

Terminate
  (no stories)

The map lists every story once, under the stage it sits at. Both stories read “planned” because their Phase has not been released. To turn each story into a readable document:

$ vendor/bin/barnspek write reservations --output-dir=docs/stories
Barn: …/hotel
Wrote: docs/stories/book-a-room-for-a-run-of-nights.md
Wrote: docs/stories/book-a-room-for-a-run-of-nights.html
Wrote: docs/stories/cancel-their-booking.md
Wrote: docs/stories/cancel-their-booking.html
$ cat docs/stories/book-a-room-for-a-run-of-nights.md
# book a room for a run of nights

**The** guest
**Wants to** book a room for a run of nights
**So they** have somewhere to stay

**Stage** transact — The role completes the exchange the area of business exists for: pays, places the order, submits, publishes.

## Scenarios

### book a room for three nights

**Given**
- no booking holds the room on those nights

**When**
- they book a room for three nights (nights=3) — expected to be accepted

**Then**
- holds the room for the guest on these nights

Open the browser app #

$ vendor/bin/barnspek gui

This serves the barn on your own machine and opens it in your browser; stop it with Ctrl-C. It lists the areas of business, and opening reservations shows the same story map with a card for each story. The browser app page covers the rest.

Let your AI agent help #

If you work with an AI agent, copy Barnspek’s agent skills into the project:

$ vendor/bin/barnspek skills:install
barnspek-getting-started: 2 written, 0 up to date, 0 left as you changed them
barnspek-phases: 1 written, 0 up to date, 0 left as you changed them
barnspek-shaping-a-phase: 2 written, 0 up to date, 0 left as you changed them
barnspek-writing-scenarios: 1 written, 0 up to date, 0 left as you changed them
barnspek-writing-stories: 1 written, 0 up to date, 0 left as you changed them
Skills are in …/hotel/.claude/skills

These are five skills in .claude/skills/, the folder Claude Code reads (--dir=<folder> for another agent’s). They teach your agent what Barnspek keeps, the commands that read and the ones that write, and how to write Stories, Scenarios and Phases the Barnspek way. Ask it to turn a description of what you want next into a Phase, review your Stories, or check whether a Phase is ready to release: it reads what you have captured first, drafts, asks you grouped questions, and writes through the commands only once you agree.

Run the command again after updating Barnspek: files you have changed are kept unless you pass --force.

Where next #

Used in Barn: in a barn, Barnspek is the Spek tab. barnspek init makes any project a barn so Barnspek can work on its own.