Rayfin

Ai-files

rayfin init ai-files install and status manage AGENTS.md, .mcp.json, and the Rayfin skill — flags, conflict resolution, exit codes, and the drift nudge in rayfin up.

rayfin init ai-files installs and refreshes the three agent context files a Rayfin project ships:

  • AGENTS.md — project-level instructions for coding agents (scope, conventions, commands to build/test/lint). A one-time install: the CLI seeds a default on first scaffold and never overwrites it afterward, so your edits stick.
  • The mcpServers.rayfin key in .mcp.json — wires up the Rayfin MCP server so connected agents can query version-locked Rayfin documentation as structured tool calls instead of shelling out to rayfin docs. See Docs.
  • .agents/skills/rayfin/SKILL.md — the Rayfin skill: guidance an agent loads to know which docs tools to call, common Rayfin patterns, and project conventions.

This page is the command reference for keeping those three files installed and up to date.

Scaffolding with npm create @microsoft/rayfin@latest or rayfin init installs these automatically — you typically only run this by hand to refresh an existing project after upgrading the CLI, or to add agent files to a project that predates them.

ai-files install

npx rayfin init ai-files install

Idempotent: re-running reconciles the project to the bundled content for your current CLI version. Nothing is written when the project is already up to date.

FlagDescription
-f, --force [ids...]Overwrite items that were hand-edited (user-modified) or restore ones that were deleted (missing). With no arguments, applies to every managed item; pass one or more namespaced IDs (e.g. --force mcp:rayfin) to scope it. Never overwrites AGENTS.md.
-y, --yesSkip the interactive prompt and accept defaults (alias of --non-interactive).
--non-interactiveSkip the interactive prompt and accept defaults (all items enabled).
--enable <id>Install or keep a specific item by its namespaced ID (e.g. skill:rayfin). Repeatable.
--disable <id>Stop managing a specific item — records the choice without deleting the on-disk file. Repeatable. Also accepts orphaned IDs the lockfile remembers but the current CLI no longer ships.
--remove-filesModifier for --disable that also deletes the on-disk file. Cannot be passed alone.
--jsonEmit a {status, schemaVersion, dryRun, report} envelope instead of human-readable progress lines. Implies non-interactive.
-n, --dry-runClassify what install would do and emit the report, without writing to disk. Pairs with --json.

Exit codes

CodeMeaning
0Success, no warnings.
1Hard error — invalid arguments, unknown ID, malformed lockfile, or an unrecovered write failure.
3Success with warnings (for example, user-modified items were preserved rather than overwritten). Distinct from 1 so scripted consumers can tell "you should look at this" apart from "the command failed."

ai-files status

npx rayfin init ai-files status

Prints one line per managed item with its current state. Add --json for {status, schemaVersion, items: ItemStatus[]}.

FlagDescription
--jsonEmit a JSON object instead of formatted lines.

Item states

StateMeaning
up-to-dateOn disk; matches the lockfile and the bundled content. Nothing to do.
update-availableOn disk and matches the lockfile, but the CLI now ships different content. install refreshes it.
user-modifiedOn disk but its hash doesn't match what the CLI last wrote — treated as an intentional edit. install --force <id> overwrites it; install --disable <id> keeps your version.
missingPreviously installed, but the file is gone. install --force <id> reinstalls it.
not-installedKnown to the CLI but not yet installed. Plain install installs it.
disabledOpted out via --disable <id>, or (for the skill) by removing the rayfin-managed: true frontmatter sigil. install --enable <id> re-enables.
orphanedThe lockfile remembers an item the current CLI no longer ships. install cleans it up if untouched, or warns if you edited it.
unreadableOn disk but malformed (e.g. invalid JSON in .mcp.json). Repair by hand, or install --force <id> to rebuild it.

Conflict resolution

The CLI tracks what it last wrote in rayfin/.lockfile.json — commit it so your team shares the same baseline. Re-running install compares the on-disk content against that lockfile and against the bundled content for your current CLI version:

StateDefaultWith --force
not-installedinstallinstall
up-to-dateno-opno-op
update-availablerewriterewrite
user-modifiedwarn, preserve your contentoverwrite with bundled
missingwarnreinstall
disabled (via --disable)skipskip — --force alone won't re-enable; pass --enable <id>
disabled (skill sigil removed)skipskip — pass --enable <id> --force to re-stamp the sigil
unreadablewarnoverwrite (rebuild from scratch)
orphaned, untoucheddelete (lockfile + disk)delete
orphaned, editedwarn, preservedelete

AGENTS.md is the one exception to all of this: it's a one-time install. If it already exists — written by the CLI, your template, or you by hand — install never overwrites it, even with --force.

Drift nudge

rayfin up prints a one-line nudge at startup if any managed item is out of date, modified, missing, or newly shipped:

ℹ️  Your project's Rayfin agent files have changes available. Run `rayfin init ai-files install` to refresh.

It's content-based, not version-based — upgrading the CLI to a version that ships identical content produces no nudge.

Scripting and CI

# Check what would change without writing
npx rayfin init ai-files install -n --json

# Idempotent install in CI — warnings exit 3, hard errors exit 1
npx rayfin init ai-files install --yes --json

# Inspect current state without writes
npx rayfin init ai-files status --json
PromptRefresh agent files after a CLI upgrade
Check whether this project's Rayfin agent files have drifted with `npx rayfin init ai-files status --json`, then run `npx rayfin init ai-files install --yes --json` to refresh anything out of date. Tell me if any item came back user-modified and needs a manual decision.
Something wrong on this page?Report an issueEdit this page

On this page