Skip to content

How-To · Node CLI

Recommended · Estimated time: ~10 min · Karajan iterations: 1–2

This walkthrough takes you from an empty directory to a merged feature on a small Node CLI project. The recipe is deliberately minimal so you can re-run it on a real codebase by swapping the bootstrap step for cd <your-repo>.

You should already have done the common setup: npm install -g karajan-code, kj init inside the project, and a green kj doctor. If kj doctor is red, fix that first — kj run will refuse to start otherwise.

  1. Bootstrap the project.

    Terminal window
    mkdir hello-cli && cd hello-cli
    npm init -y
    npm install --save-dev vitest
    git init -b main && git add -A && git commit -m "chore: scaffold"

    Edit package.json so the test runner is wired up:

    {
    "type": "module",
    "scripts": {
    "test": "vitest run"
    }
    }
  2. Initialize Karajan in the repo.

    Terminal window
    kj init
    kj doctor

    kj init creates .karajan/ and writes the orchestrator config; kj doctor confirms the agent CLIs, Docker, Ollama, and ports are all healthy.

  3. Describe the feature in natural language.

    No spec file. No JSON. Just the task as you’d describe it to a colleague:

    Terminal window
    kj run "Add a 'greet <name>' command to bin/cli.js that prints \
    'Hello, <name>!'. Add a Vitest test that runs the CLI via execa \
    and asserts the stdout for the name 'world'." \
    --methodology tdd \
    --coder claude \
    --reviewer codex \
    --reviewer-fallback claude \
    --max-iterations 5
  4. Watch the run on the HU Board.

    Open http://localhost:4000 in another tab while the pipeline runs. You’ll see, in real time:

    • Each role activating (planner → coder → tester → reviewer).
    • The exact prompt + response of every agent call.
    • The diff after each iteration.
    • The reviewer verdict.

    You can also tail the same trace in the terminal:

    Terminal window
    kj tail
  5. Inspect the result.

    Terminal window
    git status
    git diff --stat
    npm test

    Expected output of npm test:

    ✓ tests/cli.test.js (1)
    ✓ greets the given name (42ms)
    Test Files 1 passed (1)
    Tests 1 passed (1)
  6. Merge.

    Karajan does not push or merge for you by default — that’s your call. When you’re happy with the diff:

    Terminal window
    git checkout -b feat/greet-command
    git add -A && git commit -m "feat(cli): add greet <name> command"
    git push -u origin feat/greet-command
    gh pr create --fill

    Or, if you want Karajan to also open the PR for you, add --auto-commit --auto-pr to the kj run invocation.

The same run launched via the MCP from any MCP-capable client (Cursor, Claude Desktop, Codex):

{
"tool": "kj_run",
"params": {
"task": "Add a 'greet <name>' command to bin/cli.js that prints 'Hello, <name>!'. Add a Vitest test.",
"methodology": "tdd",
"coder": "claude",
"reviewer": "codex",
"reviewerFallback": "claude",
"maxIterations": 5
}
}