Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 131 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,155 @@
# SkillFlow

[![check](https://github.com/skovtunenko/skillflow/actions/workflows/check.yml/badge.svg)](https://github.com/skovtunenko/skillflow/actions/workflows/check.yml)
[![release](https://img.shields.io/github/v/release/skovtunenko/skillflow?sort=date)](https://github.com/skovtunenko/skillflow/releases/latest)
[![node](https://img.shields.io/badge/node-%E2%89%A522-339933?logo=nodedotjs&logoColor=white)](https://nodejs.org/)
[![license](https://img.shields.io/github/license/skovtunenko/skillflow)](https://github.com/skovtunenko/skillflow/blob/main/LICENSE)

SkillFlow is a language for the workflow of an agent skill. A flow file
describes the phases, steps, decisions, and who acts in each step, so a
person can review the skill in minutes.
lists the phases, steps, and decisions of a skill and names who acts in
each step: the model, a script, or a person. Nothing runs a flow file. It
is the specification, and the skill is its implementation.

SkillFlow has two parts. `skillflowctl` checks a flow, draws its graph, and
runs a browser editor in which the graph follows the text. It is plain code:
the same input gives the same result, and it spends no tokens. The
`skillflow` skill is for your agent: it writes a flow for an existing skill
(`reverse`), writes one with you (`author`), and finds and fixes the
differences between a flow and its skill (`check`, `sync`). Only these agent
modes spend tokens.

Website and playground: <https://skovtunenko.github.io/skillflow/>

## A flow file

```kdl
skillflow 1.0

context "Drafts release notes for a git tag and adds them to CHANGELOG.md." {
input tag "the git tag to describe"

output changelog "a new section in CHANGELOG.md"

invariant by=human "nothing is published without the user's approval"
}

phase gather {
step collect-changes by=code "Run collect.sh for the tag." {
output changes "the commits since the last tag"

catch {
end "the tag does not exist"
}
}

decide size "Is this a major release?" by=llm {
when major {
step ask-highlights by=llm "Ask which changes come first." {
input highlights "the changes that the user wants at the top"
}
}

when regular "The notes have no highlights."
}
}

phase write {
step draft by=llm "Group the changes by type. Revise until the user approves." {
output draft "the release notes before approval"
}

gate approved "Did the user approve the draft?"

step publish by=code "Add the notes to CHANGELOG.md." {
output changelog
}

Website: <https://skovtunenko.github.io/skillflow/>
step announce by=human "Post the notes to the team channel."
}
```

The syntax is [KDL 2.0](https://kdl.dev/). Node names (`phase`, `step`,
`decide`, `gate`, `catch`, `end`) are the structure, and a script checks
them. Quoted strings are the intent of each node; the agent compares them
with the text of the skill. `by=` names the executor: `llm`, `code`, or
`human`.

The flow of SkillFlow itself is
[`skills/skillflow/flow.kdl`](https://github.com/skovtunenko/skillflow/blob/main/skills/skillflow/flow.kdl).

## Install

Copy the folder `skills/skillflow` into the skills folder of your agent.
The scripts of the skill need Node.js 22 or later and no packages.
Pick one: the [skills CLI](https://skills.sh/) or
[kasetto](https://kasetto.dev/). The skill needs Node.js 22 or later; its
scripts use no packages and no network.

```bash
# skills CLI (skills.sh): installs into the current project
npx skills add skovtunenko/skillflow

# kasetto: --project, because its default scope is global
kst add https://github.com/skovtunenko/skillflow --skill skillflow --project
```

By hand: copy `skills/skillflow` into the skills folder of your agent.

## Modes
## Use it through your agent

Ask the agent for a mode, for example `skillflow check`.
Type the mode in the chat, for example `skillflow reverse` for a skill that
has no flow yet. Each mode is a model run and spends tokens.

| Mode | What it does |
| Mode | Reads | Gives |
| --- | --- | --- |
| `reverse` | the skill as it works now | a flow file for a skill that has none |
| `author` | your documents and answers | a new flow, or edits to a flow |
| `check` | the flow and the skill | a report of the differences; no file changes |
| `sync` | each difference, and the side you choose | edits to the flow or to the skill |
| `explain` | the flow file | an explanation, an HTML page, or a diff of two versions |
| `help` | — | answers about SkillFlow |

## Use it without an agent

`skillflowctl` (`skillflowctl.cmd` on Windows) in the skill folder runs
without a model and spends no tokens.

| Command | Result |
| --- | --- |
| `help` | Explains SkillFlow and how to write a flow. |
| `reverse` | Writes a flow file for a skill that has none. |
| `author` | Writes or edits a flow with you, step by step. |
| `check` | Tells you whether the skill still matches its flow. |
| `sync` | Brings the flow and the skill back in line. |
| `explain` | Explains a flow, shows it as a page, or compares two versions. |
| `skillflowctl lint <skill>` | checks the format and validates the flow; writes nothing |
| `skillflowctl page <skill>` | formats and validates the flow, then writes its HTML page |
| `skillflowctl edit <skill>` | opens a local editor in the browser; the graph follows the text |
| `skillflowctl edit <skill> --offline <page>` | writes the editor as one offline page |
| `skillflowctl` | in a terminal: a menu of flows and actions |

`<skill>` is a flow file, a folder with one flow file, or a skill name.
Exit codes: `0` OK, `1` the flow has errors, `2` a wrong command line or an
unreadable input. `skillflowctl --help` lists all commands and options.

## Repository layout

```text
skills/skillflow/ the skill: SKILL.md, flow.kdl, skillflowctl, scripts, references, assets
build/skillflow/ tests, the eval kit, and the tool that vendors the KDL parser
site/ website sources and the examples it shows
```

The file `skills/skillflow/flow.kdl` is the flow of SkillFlow itself.
This repository receives releases from a private source repository.
A release has a calendar version, `vYYYY.MM.DD.N`, equal to the version of
the skill.

## Development

The tasks need [mise](https://mise.jdx.dev/).
The tasks need [mise](https://mise.jdx.dev/); it installs Node.js 24.

```bash
mise run check # run the tests
mise run site # build the website into _site/
```

The browser tests need Chrome. Without it they are skipped, except in CI.
The browser tests need Chrome. Without Chrome they are skipped, except in
CI or with `SKILLFLOW_BROWSER=required`.

## License

MIT, see the file `LICENSE`. Third-party code in the skill ships with its
own license.
MIT, see [`LICENSE`](https://github.com/skovtunenko/skillflow/blob/main/LICENSE).
Third-party code in the skill ships with its own license; the website
lists each part.
8 changes: 4 additions & 4 deletions build/skillflow/tests/editor-pure.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ test("differingLines gives the whole lines that differ, and the rest rebuilds th
});

test("the layout choices survive their own cookie; with none, the page starts as an editor", () => {
const start = {view: "source", split: "cols", ratio: 55, srcMode: "edit", panelShut: true, dir: "cols"};
const start = {view: "source", split: "cols", ratio: 55, srcMode: "edit", panelShut: true, dir: "cols", order: "gs"};
assert.deepEqual(readPrefs(""), start);
assert.deepEqual(readPrefs(null, true), {...start, split: ""}, "a narrow window starts with the text alone");
const prefs = {view: "graph", split: "rows", ratio: 61, srcMode: "read", panelShut: false, dir: "rows"};
assert.equal(prefsPair(prefs), "skillflow-editor=graph.rows.61.read.open.rows");
const prefs = {view: "graph", split: "rows", ratio: 61, srcMode: "read", panelShut: false, dir: "rows", order: "sg"};
assert.equal(prefsPair(prefs), "skillflow-editor=graph.rows.61.read.open.rows.sg");
assert.deepEqual(readPrefs(`other=1; ${prefsPair(prefs)}; more=2`), prefs);
assert.deepEqual(readPrefs(prefsPair({...prefs, split: ""})), {...prefs, split: ""}, "one view at a time; the way the split was turned is kept");
assert.deepEqual(readPrefs("skillflow-editor=graph.one.61.read.open"), {...prefs, split: "", dir: "cols"}, "a pair of the version before has no turn");
assert.deepEqual(readPrefs("skillflow-editor=graph.one.61.read.open"), {...prefs, split: "", dir: "cols", order: "gs"}, "a pair of the version before has no turn and no order");
// a pair of the first editor, or a pair with a part this version does not know, counts as nothing saved
for (const old of ["skillflow-editor=%7B%22mode%22%3A%22both%22%7D", "skillflow-editor=help.cols.55.edit.shut", "skillflow-editor=graph.wide.55.edit.shut", "skillflow-editor=graph.cols.55.write.shut"]) assert.deepEqual(readPrefs(old), start, old);
assert.deepEqual(readPrefs("skillflow-editor=source.cols.999.edit.x"), {...start, ratio: 80});
Expand Down
Loading