Skip to content

Install SWARQ

This guide is for a first-time setup of the SWARQ repository on a development machine. It takes about ten minutes. When you finish, the build, tests, and checks pass and the swarq CLI runs from the repository.

To create a board in a different project, see Set up a new workspace after this guide.

1. Prerequisites

Tool Version Why
Node.js 22 or later (.nvmrc pins 22) engines in the root package.json
pnpm 10.28.0 (pinned by packageManager) Lockfile and workspace
git any recent version Hooks and branch rules
Docker optional Only for pnpm gate, the release gate

Install pnpm through Corepack, which reads the pin in package.json:

Terminal window
nvm use # reads .nvmrc, if you use nvm
corepack enable
node --version # v22.x
pnpm --version # 10.28.0

Do not install pnpm globally with a different version.

2. Clone and install

Terminal window
git clone https://github.com/Fused-Gaming/swarq.git
cd swarq
git switch main # or the feature branch you were assigned
pnpm install --frozen-lockfile

Always use --frozen-lockfile. It installs exactly what pnpm-lock.yaml records. Do not edit the lockfile by hand. If a dependency change is needed, see CLAUDE.md.

3. Build, typecheck, and test

Terminal window
pnpm build
pnpm typecheck
pnpm test

Turbo runs each script in every package, and each run ends with a summary line such as Tasks: 12 successful, 12 total. If a task fails, read its output before you change anything. Do not skip a task to get past it.

4. Run the repository checks

Terminal window
pnpm check:publishable # public packages do not depend on private ones
pnpm check:plugins # plugin manifests match their package versions
pnpm test:session-hook # the Claude Code SessionStart hook
pnpm check:secrets # no credential-shaped strings are tracked
pnpm check:changelog # the root CHANGELOG.md matches the release contract

All five must pass before you open a pull request.

5. Run the CLI

The CLI is swarq, built from packages/cli. Until the package is installed on your PATH, run it from the build output:

Terminal window
node packages/cli/dist/bin.js help
node packages/cli/dist/bin.js board show

Inside the repository, the package.json scripts call the same build (for example pnpm check:secrets). When @h4shed/swarq is installed as a dependency of a project, npx --no-install swarq also works, and the pre-commit hook uses that form.

6. Enable the pre-commit gate

The hook in .githooks/pre-commit blocks a commit that stages a token or a private key. Git needs to be told to use it, once per clone:

Terminal window
git config core.hooksPath .githooks

Check it:

Terminal window
git config --get core.hooksPath # prints .githooks

7. Set up the GitHub token (optional, needed for sync)

Only swarq github sync, swarq github checkin, and swarq review pr-link --apply call GitHub. You do not need a token to build or test.

  1. Create a fine-grained personal access token scoped to Fused-Gaming/swarq.
  2. Store it as an environment variable named SWARQ_PAT. SWARQ also reads GITHUB_TOKEN or GH_TOKEN when SWARQ_PAT is unset, and uses the first one that is set. In a cloud session, GITHUB_TOKEN and GH_TOKEN can hold a placeholder that only works through the session’s proxy, so set SWARQ_PAT. In a cloud session, add it as an environment secret. Locally, export it in your shell session or a secrets manager.
  3. Never write the token into a file, a commit, or a chat message. The .gitignore rules and the pre-commit hook catch some mistakes, but they are not a substitute for care.

Check that the token is read, using a dry run. A dry run changes nothing on GitHub:

Terminal window
node packages/cli/dist/bin.js github sync --repo Fused-Gaming/swarq

Without --apply, the command only prints the plan. Read it before you add --apply.

8. Optional: the release gate

pnpm gate builds the Docker image and runs the checks in Release gate test plan. It needs a running Docker daemon. pnpm gate --skip-docker runs the host checks only, and it is not a release gate.

9. Work on a change

  • Work on a feature branch. Do not push to main.
  • Record a release-worthy change with pnpm changeset. The changeset check in CI fails without one. See Versioning and release policy.
  • Add an entry under [Unreleased] in CHANGELOG.md, then run pnpm check:changelog. See Changelog contract.
  • Commit messages describe the change in the imperative.
  • Before you open a pull request, run pnpm build && pnpm typecheck && pnpm test again.

Troubleshooting

Symptom Likely cause Fix
pnpm: command not found or a different pnpm version Corepack is not enabled, or an old global pnpm is first on PATH corepack enable, then open a new shell
ERR_PNPM_OUTDATED_LOCKFILE on install The lockfile does not match package.json Pull the latest branch. Do not regenerate the lockfile to get past it
Cannot find module '@h4shed/swarq-…' when running the CLI A package was not built Run pnpm build from the repository root
--apply needs SWARQ_PAT (or GITHUB_TOKEN or GH_TOKEN) in the environment The token is not set in this shell Set SWARQ_PAT (step 7), then rerun
GitHub API 401 The token variable holds an unusable value, for example a placeholder in GITHUB_TOKEN Set SWARQ_PAT, which is read first
swarq github: no board at .swarq/board.json You are running from the wrong directory Run from the repository root, or pass --board <dir>
Commit blocked by check-secrets A staged line looks like a token or key Remove the value, rotate it if it was real, and commit again. The output shows the file, line, and pattern, never the value