Skip to content
safran

Type to search. Enter opens the first result.

    Maintenance commands

    The commands on this page keep Safran's local data current and hand it to agents and people: safran sync brings the repositories and the code index up to date, safran links refresh pulls merged pull requests into the ticket ↔ code store, safran links status tells you how big and how old that store is, safran mcp serves everything to a coding agent, and safran dashboard serves it to you as a local web page. The first two are the ones that write under the data directory (the dashboard can start a sync for you, which is the same operation); run them on a schedule (see keeping data fresh). Global options, exit codes and the --json contract are on the CLI overview.

    $ safran sync
       repo          status  changed  unchanged  chunks    time  detail
    ✔  payments-api  ok            4          0       4  170 ms  4 embedded, 0 from cache
    ✔  ledger        ok            1          0       1   45 ms  1 embedded, 0 from cache
    
    2 repos: 2 ok in 221 ms
    $ safran links refresh
       repo          pull requests  with a ticket  detail
    ✔  payments-api              3              2
    ✔  ledger                    0              0
    
    3 pull requests read, 2 with a ticket, in 10 ms

    The examples run against a small fixture of the acme story: two repositories read from disk, indexed with bge-m3, and a code host that lists three merged pull requests.

    What lives where under the data directory (data/ next to the profile unless --data-dir says otherwise):

    PathWritten byHolds
    repos/<host>/<repo>/safran syncClones of remote repositories. Repositories of a local host are read in place and never copied.
    index/index.dbsafran syncThe code index: files, chunks, the lexical index, vectors and the embedding cache.
    safran.dbsafran links refreshThe link store: merged pull requests, their ticket keys and changed files.

    Everything there can be deleted and rebuilt with these two commands.

    safran sync

    safran sync [repo…] [options]

    Clones or fetches the repositories and indexes what changed. For every repository the code hosts list (after include / exclude), or only the ones you name:

    1. Fetch. A remote repository is cloned on the first run and fetched afterwards, with the host's credentials. A local repository is read where it is.
    2. Index. Files are scanned; a file is re-chunked only when its content changed, and an embedding is computed only when it is not in the cache. This is the step that calls the embedder.

    It touches the network (code hosts for the listing and git, the embedder) and writes clones and the index under the data directory. It never writes to a repository's remote. One lock per repository keeps two syncs from sharing a working tree: a repository another sync is working on is reported as skipped with the reason.

    One repository failing never stops the others. After a sync of everything in which every host answered, repositories that no code host lists any more are dropped from the index and named in the output.

    FlagValueDefaultMeaning
    --offlinenoneoffSkip the git fetch; index what is on disk. A remote repository that was never cloned is skipped.
    --fetch-onlynoneoffUpdate the working trees; do not index. Needs neither the index nor the embedder. Repositories of a local host are reported as skipped, since there is nothing to fetch.

    Positional arguments are repository names. --offline and --fetch-only together are refused: nothing would be left to do.

    The first run embeds every chunk. A second run finds nothing to do:

    $ safran sync
       repo          status  changed  unchanged  chunks   time  detail
    ✔  payments-api  ok            0          4       0  16 ms  no changes
    ✔  ledger        ok            0          1       0   9 ms  no changes
    
    2 repos: 2 ok in 29 ms
    ColumnMeaning
    statusok, failed or skipped.
    changedFiles chunked in this run because they are new or their content changed.
    unchangedFiles whose content hash matched the index.
    chunksChunks written to the index in this run.
    timeIndexing time for the repository.
    detailEmbeddings computed and taken from the cache, files left out, no changes, or the first line of the failure.

    Progress goes to stderr: one line per repository rewritten in place on a terminal (fetching, scanning, then a file counter such as indexing 4/4 files 100%), a few lines per repository elsewhere. With --verbose, the library's debug and info lines are added.

    Ctrl-C stops cleanly: the repositories that finished are indexed, the one that was interrupted and the ones not reached are listed as skipped, and the exit code is 130. Run the command again to continue; finished work is not repeated.

    JSON

    results has one entry per repository with status, and when it was indexed an index object of counters. files_skipped maps a skip reason to a count (its keys are data and are not converted). removed lists repositories dropped from the index. A failed repository has an error of { code, message, hint }; a cancelled run has aborted: true.

    {
      "ok": true,
      "results": [
        {
          "repo": "payments-api",
          "status": "ok",
          "index": {
            "repo": "payments-api",
            "files_indexed": 0,
            "files_unchanged": 4,
            "files_removed": 0,
            "chunks_written": 0,
            "embeddings_computed": 0,
            "embeddings_cached": 0,
            "duration_ms": 15,
            "files_skipped": {}
          }
        },
        {
          "repo": "ledger",
          "status": "ok",
          "index": {
            "repo": "ledger",
            "files_indexed": 0,
            "files_unchanged": 1,
            "files_removed": 0,
            "chunks_written": 0,
            "embeddings_computed": 0,
            "embeddings_cached": 0,
            "duration_ms": 9,
            "files_skipped": {}
          }
        }
      ],
      "duration_ms": 28,
      "removed": [],
      "warnings": []
    }

    warnings carries { source, code, message } for problems found while listing, such as a code host that could not list its repositories.

    Exit codes and mistakes

    CodeWhen
    0Every repository is ok or skipped.
    1At least one repository failed (the others are still indexed), or the run could not start: unknown repository name, every code host failing, the index cannot be opened.
    2Wrong command line.
    130Interrupted; the report of what finished is still printed.
    $ safran sync payment-api
    ✘ No repo named "payment-api"
    → Did you mean: payments-api?
    • Changing the embedding model and searching straight away. Vectors of different models cannot be compared; repositories built with the previous model are refused by search until safran sync has re-indexed them. safran doctor and safran status name them.
    • Expecting --offline to index repositories that were never cloned. They are skipped; run once without the flag.
    • Running two syncs at once. It is safe, but the second one skips the repositories the first is working on.
    • An embedder that is not running. The index is opened before any clone, so the command fails within a second instead of after the fetches. safran sync --fetch-only updates the working trees without it.
    safran links refresh [repo…] [options]

    Pulls merged pull requests from the code hosts into the local ticket ↔ code store: for each one its title, author, branch, merge date, the ticket keys it refers to and the files it changed. This store is what safran links show, ownership inference, safran discover and the evaluation commands read.

    It needs a code host that lists pull requests (azure-repos, github, gitlab); a local host has none. It calls those hosts and writes safran.db under the data directory. It does not call the trackers: ticket keys are recognised in pull request titles, branch names and descriptions (plus the links the host itself reports), using the project keys declared under trackers[].projects in the profile.

    The first run of a repository reads 12 months back. Later runs resume from the newest stored pull request, so a routine refresh is cheap.

    FlagValueDefaultMeaning
    --since <date>ISO date, such as 2026-01-01resume; 12 months back on the first runHow far back the stored history must reach. An explicit date re-reads that whole window.
    --max-per-repo <n>whole number, at least 1500Cap on pull requests newly stored per repository in one run. A repository with more than that is reported as not fully fetched, and the next run continues where this one stopped.

    Positional arguments are repository names.

    $ safran links refresh payments-api --since 2026-01-01 --max-per-repo 50
       repo          pull requests  with a ticket  detail
    ✔  payments-api              3              2
    
    3 pull requests read, 2 with a ticket, in 9 ms

    with a ticket counts the pull requests in which at least one ticket key was recognised. The detail column says history not fully fetched yet; run again to continue for a repository cut by the cap, and shows the error code and message for one that failed. As with sync, one repository failing does not stop the others, and Ctrl-C keeps what was stored (exit code 130).

    JSON

    {
      "ok": true,
      "repos": [
        {
          "repo": "payments-api",
          "status": "ok",
          "fetched": 3,
          "linked": 2
        },
        {
          "repo": "ledger",
          "status": "ok",
          "fetched": 0,
          "linked": 0
        }
      ],
      "duration_ms": 10,
      "warnings": []
    }

    A repository entry also has truncated: true when the cap cut it and error ({ code, message, hint }) when it failed; the document has aborted: true after a cancelled run. With no host that lists pull requests, repos is empty and ok is true.

    Exit codes and mistakes

    CodeWhen
    0Every repository is ok, or there was nothing to refresh.
    1At least one repository failed (the others are stored), or the run could not start, for example for an unknown repository name.
    2Wrong command line (--since is not a date, --max-per-repo is not a whole number of at least 1).
    130Interrupted; what is listed as ok is stored.
    $ safran links refresh nope
    ✘ No repo named "nope"
    → 2 repos are known; `safran repos` lists them.

    With local hosts only, the command says so and exits with 0:

    No repo to refresh: none of the code hosts lists pull requests.
    → Ticket ↔ code links come from merged pull requests on azure-repos, github or gitlab hosts.
    • Zero pull requests "with a ticket". Ticket keys are recognised by the project keys under trackers[].projects. A profile that does not declare its projects yet has none to look for; add them (or let safran discover propose them) and refresh again with --since.
    • Expecting older history after the first run. Without --since, later runs only add what is new. Pass an earlier date to extend the window.
    • Reading "not fully fetched" as a failure. It is the cap at work. Run the command again until the note disappears, or raise --max-per-repo.
    safran links status

    Prints the size and age of the ticket ↔ code store: how many merged pull requests it holds, how many of them refer to a ticket, when it was last refreshed, and which repositories' history is not fully fetched yet. It has no options of its own, reads the local store only and never creates it.

    $ safran links status
    records        3 merged pull requests
    with a ticket  2 (67%)
    refreshed      just now

    Before the first refresh:

    $ safran links status
    The ticket ↔ code store is empty.
    → Fill it with `safran links refresh --profile safran.yaml` (needs a code host that lists pull requests).

    JSON

    {
      "exists": true,
      "records": 3,
      "linked": 2,
      "refreshed_at": "2026-11-23T11:26:52.380Z",
      "incomplete_repos": [],
      "error": null
    }

    exists is false when there is no store file yet. error is { code, message, hint } when the file exists but cannot be read.

    Exit codes and mistakes

    0 when the store was read or does not exist yet; 1 when it exists but cannot be read (for example it was written by a newer version of Safran).

    • A low share "with a ticket". It measures how consistently pull requests name their ticket, and whether the profile declares the project keys. Evaluation and discovery only use the linked ones.

    safran mcp

    safran mcp [options]

    Serves the profile to coding agents over the Model Context Protocol: the same reads as the daily commands, as tools. By default it speaks stdio, which is what a coding agent starts as a child process; with --http it serves Streamable HTTP. The tools are documented in the MCP reference, and wiring the server into Claude Code in the MCP server page.

    The server runs until its client goes away. It reads what the tools ask for: trackers, the index, the link store, doc sources. It never syncs or refreshes by itself.

    FlagValueDefaultMeaning
    --httpnoneoffServe Streamable HTTP instead of stdio. The other five flags only apply with it.
    --port <n>0 to 655353939HTTP port. 0 picks a free one.
    --host <address>address to bind127.0.0.1Any address that is not loopback requires --token-env.
    --token-env <NAME>name of an environment variablenoneThe variable holds a bearer token every client must send.
    --path </mcp>URL path/mcpEndpoint path.
    --allow-host <hostname> …repeatableloopback names onlyExtra hostname accepted in the Host header, for a server not bound to loopback (a DNS name, a proxy's name).

    stdio

    In stdio mode stdout carries protocol frames and nothing else; logs and warnings go to stderr. The session ends when the client closes stdin (or on Ctrl-C). You normally do not run it by hand; you register it with the agent, through the launcher and with an absolute profile path:

    claude mcp add --transport stdio safran -- /work/safran/bin/safran mcp --profile /work/acme/safran.yaml

    Register the launcher, never a bare bun run started inside a project: Bun would auto-load that project's .env and bunfig.toml before Safran starts. When that happened anyway, the server says so on stderr at start. Naming the profile with --profile also settles the plugin trust question, which matters because nobody is there to answer a prompt.

    HTTP

    $ safran mcp --http --port 0
    ✔ Safran MCP server for acme listening on http://127.0.0.1:52876/mcp
      health: http://127.0.0.1:52876/healthz   auth: none (loopback only)
    
    Register it in Claude Code:
      claude mcp add --transport http safran http://127.0.0.1:52876/mcp
    
    Ctrl-C stops the server.
    Stopped.

    All of this is written to stderr; stdout stays empty. The port in the example was picked by --port 0. Stopped. is printed after Ctrl-C.

    The server gives read access to your tickets and source code and has no authentication other than the optional bearer token. It therefore binds to loopback by default and refuses any other address without a token:

    $ safran mcp --http --host 0.0.0.0
    ✘ Refusing to bind 0.0.0.0 without a token
    → The server gives read access to your tickets and source code and has no other authentication. Keep the default 127.0.0.1, or name a variable holding a bearer token: --token-env SAFRAN_MCP_TOKEN

    With --token-env SAFRAN_MCP_TOKEN, the variable must be set (in the shell or in the .env next to the profile) and every request except the health check must carry Authorization: Bearer <token>. The start-up text then prints the matching claude mcp add … --header line. The Host header of a request must name an accepted hostname: the loopback names always, the address you bound (unless it is a wildcard such as 0.0.0.0), and whatever you add with --allow-host. Requests, authentication and deployment are covered in MCP over HTTP.

    JSON

    safran mcp has no JSON result: in stdio mode stdout belongs to the protocol, in HTTP mode it stays empty. --json only changes how a start-up error is reported.

    Exit codes and mistakes

    CodeWhen
    0The client closed stdin, or the server was stopped with Ctrl-C.
    1The profile cannot be loaded, the variable named by --token-env is not set (AUTH_MISSING), or the port cannot be bound (INVALID_INPUT).
    2Wrong command line: an HTTP flag without --http, a port above 65535, a non-loopback --host without --token-env.
    $ safran mcp --port 3939
    ✘ --port only applies with --http
    $ safran mcp --http --host 0.0.0.0 --token-env SAFRAN_MCP_TOKEN
    ✘ Environment variable SAFRAN_MCP_TOKEN is not set
    → Export SAFRAN_MCP_TOKEN with a long random value, or put it in the .env file next to the profile.
    • A relative profile path in the registration. The agent starts the server from its own working directory; give --profile an absolute path.
    • Printing to stdout from a plugin. In stdio mode anything on stdout that is not a protocol frame breaks the session. Log through the logger a plugin is given.
    • Serving a stale index. The server answers from the local index and link store; it does not sync. Keep them current with safran sync and safran links refresh.
    • Passing the token itself. --token-env takes the name of the variable, like every _env field in the profile.

    safran dashboard

    safran dashboard [options]

    Serves the local dashboard for the profile: a web page with the instance's status, code search, tickets, history and evaluation reports, backed by an HTTP API on the same port. The CLI lists it under daily use; it is documented here because, like safran mcp, it is a server that runs until you stop it.

    It binds to 127.0.0.1 only; the command has no option to bind another address. At start it generates a random session token, prints a link that carries it, and opens that link in your browser (open on macOS, xdg-open on Linux; elsewhere, or when that fails, you open the link yourself). The API behind the page reads tickets and source code and can start a sync, so treat the link like a password: anyone who has it can use the server while it runs. The token is gone when the server stops.

    FlagValueDefaultMeaning
    --port <n>0 to 655350, any free portPort to listen on.
    --no-opennoneoffPrint the URL without opening a browser.
    --assets <dir>directoryweb/out-dashboard of the Safran checkoutDirectory of the built web UI. A relative path resolves against the directory you ran the command in.
    $ safran dashboard --no-open
    ✔ Safran dashboard for acme
      http://127.0.0.1:53832/dashboard?token=dde0cc84c887340296e1b3bd4d91f1878038033a3009b9a2665e1bfa70033971
      The link carries this session's token. Ctrl-C stops the server.
    Stopped.

    Everything is written to stderr and stdout stays empty, as with safran mcp --http. Stopped. is printed after Ctrl-C. There is no JSON result; --json only changes how a start-up error is reported.

    The page is the built web UI, which is not part of the Bun workspace: build it once with npm run build:dashboard in the checkout's web/ directory, which writes web/out-dashboard. The command does not check that the assets directory exists; with a missing directory the server still starts and prints its link.

    Exit codes and mistakes

    0 when the server was stopped with Ctrl-C; 1 when the profile cannot be loaded or the port cannot be bound; 2 for a wrong command line.

    $ safran dashboard --port 70000
    ✘ --port must be at most 65535, got 70000
    • Sharing the link. It carries the session token. Do not paste it into a ticket or a chat.
    • Expecting it on the network. It serves loopback only. To give an agent access, use safran mcp.
    • A blank page. The UI has not been built, or --assets points somewhere else.