Skip to content
safran

Type to search. Enter opens the first result.

    Set-up commands

    Five commands take you from nothing to a profile you can trust: safran init writes a starter profile, safran profile check validates it, safran doctor checks the machine around it, safran plugins lists the connector types you can use, and safran discover drafts the parts of the profile that are tedious to write by hand. This page documents each one with its flags, real output and JSON shape. Global options, exit codes and the --json contract are on the CLI overview.

    $ safran init --yes --company acme --language tr --tracker jira --set tracker.url=https://acme.atlassian.net --set tracker.projects=PAY,MOB,WEB --host local --set host.path=repos
    ✔ Wrote safran.yaml
    
    Set these environment variables, in your shell or in a .env file next to the profile:
      JIRA_EMAIL  ! not set
      JIRA_TOKEN  ! not set
    
    Next
      safran profile check  validate the profile and every connector
      safran doctor         check git, the embedder and the index
      safran sync           clone or read the repositories and index them
      safran discover       draft groups, teams and glossary from merged pull requests

    safran init

    safran init [options]

    Writes a starter profile. Interactive by default: it asks for the company slug, the language tickets are written in, and one tracker, one code host and the embedder, with the fields each of them needs. With --yes (or --json) it asks nothing and takes everything from flags and defaults.

    It only writes the profile file (creating its directory if needed). It contacts no service and stores no secret: fields ending in _env hold the name of an environment variable. The file goes to the profile path of the run, so --profile <file> chooses where.

    FlagValueDefaultMeaning
    --company <slug>lowercase letters, digits, dashesthe current directory's name, slugifiedCompany slug (company: in the profile).
    --language <code>two-letter ISO 639-1 codeenLanguage tickets are written in (languages.tickets). languages.code is always written as en.
    --tracker <type>a tracker plugin type, or nonenoneThe tracker entry to write. Its id is the type name.
    --host <type>a code host plugin type, or nonenoneThe code host entry to write. Its id is the type name.
    --embedder <type>an embedder plugin typeollamaThe embeddings: entry.
    --set <section.field=value> …repeatableOne connector field. Sections are tracker, host and embeddings.
    --plugin <module> …repeatable; package name or path relative to the profileA third-party plugin module to list under plugins:. The module is imported, so its types can be chosen.
    --yes, -ynoneoffAsk nothing; use the flags and defaults.
    --forcenoneoffOverwrite an existing profile.

    The fields --set (and the wizard) knows for each built-in type:

    TypeFieldsDefaults used with --yes
    tracker jiraurl (required), deployment (cloud or datacenter), email_env, token_env, projectsdeployment=cloud, email_env=JIRA_EMAIL, token_env=JIRA_TOKEN
    tracker azure-boardsorganization (required), projects, token_envtoken_env=AZURE_DEVOPS_PAT
    tracker lineartoken_env, projectstoken_env=LINEAR_API_KEY
    tracker github-issuesowner (required), repos, token_env
    host azure-reposorganization (required), projects, token_envtoken_env=AZURE_DEVOPS_PAT
    host githubowner (required), token_env
    host gitlabgroup (required), url, token_envurl=https://gitlab.com
    host localpath, or repos (comma-separated directories); one of the two is required
    embedder ollamamodel, urlmodel=bge-m3, url=http://localhost:11434
    embedder openai-compatibleurl (required), model (required), token_env

    List fields (projects, repos) take comma-separated values. Paths of the local host are made absolute against the directory you ran the command in. A value that equals the schema default (deployment: cloud, the default GitLab and Ollama URLs) is left out of the file to keep it short. Anything init does not ask for, such as groups, teams, glossary, doc sources or a second tracker, you add by editing the file; see the profile reference.

    The command at the top of this page wrote this file (the local host's path was given as repos and resolved against /work/acme):

    # Safran profile for acme. Written by `safran init`; edit freely.
    # Secrets never go here: *_env fields name the environment variable that holds a token.
    # Validate with `safran profile check`. Groups, teams and glossary: `safran discover` drafts them.
    version: 1
    company: acme
    languages:
      tickets: tr
      code: en
    trackers:
      - id: jira
        type: jira
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL
        token_env: JIRA_TOKEN
        projects:
          - PAY
          - MOB
          - WEB
    code:
      hosts:
        - id: local
          type: local
          path: /work/acme/repos
    embeddings:
      type: ollama
      model: bge-m3

    Before writing, init runs the same two validations createSafran runs (the profile schema and each connector's own schema), so a file it writes is one safran profile check accepts. The exception is a type that comes from a --plugin module: init does not know its fields, writes a stub entry with a # TODO comment, and says so.

    JSON

    --json implies --yes. stubs lists the types written as stubs, env the variables the new profile refers to and whether each is set, next the commands to run next.

    {
      "profile_file": "/work/acme/safran.yaml",
      "company": "acme",
      "tracker": null,
      "host": "local",
      "embedder": "ollama",
      "stubs": [],
      "env": [],
      "next": [
        "safran profile check",
        "safran doctor",
        "safran sync",
        "safran discover"
      ]
    }

    Exit codes and mistakes

    init exits with 0 when the file was written and with 2 for a command line it refuses (1 when a --plugin module cannot be loaded). The file is written in one step at the end, after validation.

    $ safran init --yes
    ✘ safran.yaml already exists
    → Pass --force to overwrite it, or --profile <file> to write somewhere else.
    $ safran init --yes --force --tracker jira
    ✘ jira needs a value that --yes cannot guess: --set tracker.url=<url>
    $ safran init --yes --force --host gitlb
    ✘ No code-host plugin has the type "gitlb"
    → Did you mean gitlab? Available: azure-repos, github, gitlab, local.
    • Putting a secret in a _env field. --set tracker.token_env=… takes the name of a variable (JIRA_TOKEN). A value that is not a valid variable name is rejected.
    • --set without a type. --set tracker.url=… without --tracker <type> is an error under --yes, because the default tracker is none.
    • A field init does not know. --set only accepts the fields in the table above; edit the file for the rest.
    • Piping answers that run out. In interactive mode, input that ends before the last question stops the command with exit code 2 and nothing is written.

    safran profile check

    safran profile check [file] [options]

    Loads the profile, validates it against the profile schema and every connector's own schema, builds every connector, and prints a summary: connectors, groups, teams, glossary size, the environment variables the profile names and whether each is set, and the team mappings that still carry confidence: low.

    Offline by default: connectors are built but not called, so it needs no network and no tokens. A missing token shows up as not set here and becomes an error only when the connector is used. --online makes one cheap call per tracker (list projects) and per code host (list repositories). It writes nothing. The profile can be given as an argument instead of --profile.

    FlagValueDefaultMeaning
    --onlinenoneoffAlso make one call per tracker and per code host, and report each result.
    $ safran profile check --online
    ✔ safran.yaml is valid
    
      company      acme
      languages    tickets tr, code en
      trackers     jira
      code hosts   azure (azure-repos)
      doc sources  none
      groups       backend (2) — 2 repos
      teams        Payments, Mobile
      glossary     2 terms
      conventions  1
      embeddings   ollama (bge-m3)
      data         data
    
    ! Low-confidence team mappings to confirm by hand: Mobile
      → Check their `projects` and `repos`, then delete `confidence: low` from the entry.
    
    Environment variables
      name        status  used by
      JIRA_TOKEN  set     trackers.jira.token_env
    
    Online check
      ✔ tracker jira: 1 project visible
      ✔ code-host azure: 2 repos listed

    A connector is shown as id (type), or as the id alone when the two are the same. When a token is missing, the offline check still passes and tells you; the online check fails for the connector that needs it:

    $ safran profile check --online
    ✔ safran.yaml is valid
    
      company      acme
      languages    tickets tr, code en
      trackers     jira
      code hosts   local
      doc sources  none
      groups       none
      teams        none
      glossary     0 terms
      conventions  0
      embeddings   ollama (bge-m3)
      data         data
    
    Environment variables
      name        status   used by
      JIRA_EMAIL  not set  trackers.jira.email_env
      JIRA_TOKEN  not set  trackers.jira.token_env
    ! JIRA_EMAIL, JIRA_TOKEN are not set; the connectors that use them will fail when called.
      → Export them in your shell, or put them in a .env file next to the profile.
    
    Online check
      ✘ tracker jira: Environment variable JIRA_TOKEN is not set
        → Export JIRA_TOKEN in your shell, or put it in the .env file next to the profile.
      ✔ code-host local: 1 repo listed

    An invalid profile is not summarised at all: the command stops with every problem and its path. The messages are explained in validation errors.

    $ safran profile check
    ✘ The profile has 3 configuration problems:
      - trackers.0.url: Invalid input: expected string, received undefined
      - trackers.0.token_env: Invalid input: expected string, received undefined
      - trackers.0: Unrecognized key: "urll"
    → Fix these entries in the profile. `safran plugins` lists the available types and their fields.

    JSON

    The offline document of the profile safran init wrote above. With --online it also has an online array of { kind, id, type, ok, detail, hint? }, and ok is false when any of them failed.

    {
      "ok": true,
      "profile_file": "/work/acme/safran.yaml",
      "data_dir": "/work/acme/data",
      "company": "acme",
      "languages": {
        "tickets": "tr",
        "code": "en"
      },
      "trackers": [
        {
          "id": "jira",
          "type": "jira",
          "projects": [
            "PAY",
            "MOB",
            "WEB"
          ]
        }
      ],
      "hosts": [
        {
          "id": "local",
          "type": "local",
          "include": [],
          "exclude": []
        }
      ],
      "doc_sources": [],
      "groups": [],
      "teams": [],
      "glossary_terms": 0,
      "conventions": 0,
      "embeddings": {
        "type": "ollama"
      },
      "plugins": [],
      "to_confirm": [],
      "env": [
        {
          "name": "JIRA_EMAIL",
          "set": false,
          "used_by": [
            "trackers.jira.email_env"
          ]
        },
        {
          "name": "JIRA_TOKEN",
          "set": false,
          "used_by": [
            "trackers.jira.token_env"
          ]
        }
      ]
    }

    groups entries are { name, repos } with repos a count; teams entries are { name, projects, repos, confidence } with confidence null when the entry has none.

    Exit codes and mistakes

    CodeWhen
    0The profile is valid (and, with --online, every connector answered). Unset variables and low-confidence teams are reported but do not fail the check.
    1The profile is missing or invalid, or a connector failed its online call.
    • Reading "valid" as "working". The offline check proves the file is well formed. Only --online or safran doctor touch a service.
    • A profile with plugins: in the current directory. It is refused unless you name it or pass --allow-plugins; see plugin modules and trust.

    safran doctor

    safran doctor

    Checks the environment the profile needs, top to bottom, and tells you what to do about each problem. It has no options of its own.

    It does touch the outside world: it runs git --version, makes one tiny embedding request to the configured embedder (60 second timeout), and lists repositories from the code hosts. It writes nothing; a missing index is reported as missing, not created.

    CheckFails (✘) whenWarns (!) when
    bunBun is older than 1.3.0
    gitgit is not on PATH or does not run
    launchthe CLI was not started through bin/safran and the directory holds a .env or bunfig.toml that Bun may have auto-loaded
    profilethe profile is missing or invalid (the remaining checks are skipped)
    env <NAME>a variable the profile names is not set (one row per variable)
    embedderthe embedder cannot be built, does not answer, or returns no vector
    reposlisting repositories failsthe profile has no code host, or the hosts list no repositories
    indexthe index cannot be opened, or holds repos built with a different embedder than the profile configuresnot built yet; the last sync did not finish for some repos; listed repos are not indexed; a repo's index is older than 7 days
    linksthe link store cannot be readthe store is empty although a code host lists pull requests
    $ safran doctor
    ✔ bun             Bun 1.3.2
    ✔ git             git version 2.50.1 (Apple Git-155)
    ✔ launch          started through bin/safran: Bun loaded no .env or bunfig.toml from this directory
    ✔ profile         safran.yaml (acme): 1 tracker, 1 code host
    ✔ env JIRA_TOKEN  set (used by trackers.jira.token_env)
    ✔ embedder        ollama:bge-m3 answered in 26 ms (1024 dimensions)
    ✔ repos           2 repos listed
    ✔ index           2 repos, 5 chunks, embedder ollama:bge-m3, oldest index just now
    ✔ links           3 pull requests, 2 with a ticket, refreshed just now
    
    ✔ Everything is in place.

    The same command on the profile safran init just wrote, before any token is set and before the first sync:

    $ safran doctor
    ✔ bun             Bun 1.3.2
    ✔ git             git version 2.50.1 (Apple Git-155)
    ✔ launch          started through bin/safran: Bun loaded no .env or bunfig.toml from this directory
    ✔ profile         safran.yaml (acme): 1 tracker, 1 code host
    ✘ env JIRA_EMAIL  not set (used by trackers.jira.email_env)
                      → Export JIRA_EMAIL in your shell, or put it in the .env file next to the profile.
    ✘ env JIRA_TOKEN  not set (used by trackers.jira.token_env)
                      → Export JIRA_TOKEN in your shell, or put it in the .env file next to the profile.
    ✔ embedder        ollama:bge-m3 answered in 30 ms (1024 dimensions)
    ✔ repos           1 repo listed
    ! index           not built yet
                      → Run `safran sync`.
    ✔ links           not applicable: no code host in the profile lists pull requests
    
    ✘ 2 checks failed, 1 warning.

    JSON

    One entry per check, in the order above. status is ok, warn or fail; hint is null when there is nothing to do. The middle of the array is cut here.

    {
      "ok": true,
      "failed": 0,
      "warnings": 0,
      "checks": [
        {
          "name": "bun",
          "status": "ok",
          "detail": "Bun 1.3.2",
          "hint": null
        },
        {
          "name": "embedder",
          "status": "ok",
          "detail": "ollama:bge-m3 answered in 31 ms (1024 dimensions)",
          "hint": null
        },
        {
          "name": "links",
          "status": "ok",
          "detail": "3 pull requests, 2 with a ticket, refreshed just now",
          "hint": null
        }
      ]
    }

    Exit codes and mistakes

    CodeWhen
    0No check failed. Warnings do not change the exit code.
    1At least one check failed.
    • Using it as a liveness probe for trackers. doctor does not call the trackers; it only checks that their variables are set. Use safran profile check --online for that.
    • An "older than 7 days" warning. It means the code has probably moved on since the last sync. Run safran sync; see keeping data fresh.
    • "Built with another embedder". Vectors of different models cannot be compared, so search refuses those repos until they are re-indexed or embeddings: is switched back.

    safran plugins

    safran plugins

    Lists the connector plugins by kind, with the profile key where each type is used: the built-in ones, plus the ones a profile loads through its plugins: list. It has no options of its own, reads the profile if there is one (types the profile uses are marked in use, types from its modules from the profile's plugins), and works without a profile. It contacts no service. Loading a profile's plugin modules imports them, so it follows the trust rule.

    $ safran plugins
    Trackers  trackers[].type
      azure-boards   Azure Boards work items (Azure DevOps Services and Server), read-only
      github-issues  GitHub Issues (github.com and GitHub Enterprise Server), read-only
      jira           Jira Cloud (REST v3) and Jira Data Center / Server (REST v2), read-only
      linear         Linear issues through the GraphQL API, read-only
    
    Code hosts  code.hosts[].type
      azure-repos  Azure Repos (Azure DevOps Services and Server)
      github       GitHub and GitHub Enterprise Server
      gitlab       GitLab (gitlab.com and self-managed)
      local        Directories on this machine (read in place, no clone)
    
    Doc sources  docs[].type
      confluence  Confluence Cloud and Data Center pages that tickets link to, read-only
    
    Embedders  embeddings.type
      ollama             Local embeddings via Ollama (default model: bge-m3, multilingual)
      openai-compatible  Embeddings from any OpenAI-compatible /embeddings endpoint
    
    No profile at safran.yaml; showing the built-in plugins. Create one with `safran init`.

    Each type has its own page under connectors, with its configuration fields. The command lists types and descriptions, not fields.

    JSON

    One flat list sorted by type. source is built-in, profile (from a module under plugins:) or code; in_profile says whether the profile uses the type. The list is cut after two entries here.

    {
      "plugins": [
        {
          "kind": "tracker",
          "type": "azure-boards",
          "description": "Azure Boards work items (Azure DevOps Services and Server), read-only",
          "source": "built-in",
          "in_profile": false
        },
        {
          "kind": "code-host",
          "type": "azure-repos",
          "description": "Azure Repos (Azure DevOps Services and Server)",
          "source": "built-in",
          "in_profile": false
        }
      ]
    }

    Exit codes

    0 when the list was printed; 1 when the profile exists but cannot be read, its plugin modules are not trusted (FORBIDDEN) or a module cannot be loaded (PLUGIN_NOT_FOUND).

    safran discover

    safran discover [options]

    Drafts the knowledge part of the profile, which is groups of repositories, teams and what they own, tracker project keys, glossary candidates, conventions and the ticket language, from merged pull requests and ticket titles. It uses statistics and heuristics, no language model. The result is a draft: every finding carries a confidence, and low-confidence items must be confirmed by a person. The method, its limits and how to review a draft are in the discovery guide.

    What it touches: it lists repositories and tracker projects, refreshes the local link store from the code hosts (unless --no-refresh), and reads a sample of ticket titles from the trackers. It writes one file: the draft, by default safran.draft.yaml next to the profile. Your profile is not modified unless you pass --write --force.

    FlagValueDefaultMeaning
    --out <file>pathsafran.draft.yaml next to the profileWhere to write the draft. An existing draft is replaced.
    --writenoneoffWrite over the profile itself. Needs --force; cannot be combined with --out.
    --forcenoneoffAllow --write to replace the profile.
    --since <date>ISO date, such as 2026-01-0112 months backHow far back to read merged pull requests.
    --no-glossarynoneoffSkip glossary candidates.
    --no-refreshnoneoffUse the local link store as it is; fetch no pull requests.

    The output below comes from a deliberately tiny fixture (two repositories, three merged pull requests), which is why almost every finding says there is too little history. It shows the shape of the report: counts first, then findings by topic with their confidence, then what was added to the draft.

    $ safran discover --no-refresh
    Safran discovery — draft for review (statistics and heuristics, no language model)
    2 repos (2 cloned), 3 merged PRs read, 2 used, 2 with a ticket (0% without), 2 ticket titles
    sampled.
    Ignored PRs: 1 by bots.
    Legend: + added to the draft, · observation only; [high] [med ] [low ] = confidence.
    
    Coverage (2)
      · [high] pull requests ignored as noise
               1 of 3 merged PRs were ignored: 1 by bot accounts, 0 merge/revert PRs, 0 mass changes, 0
               naming many tickets at once, 0 repeats of the same change to another branch.
      · [low ] ticket references in merged PRs
               All 2 merged PRs read reference a ticket.
    
    Repo groups (1)
      · [high] repos already grouped
               2 repos already sit in a group in the profile and were left as written.
    
    Teams (1)
      · [low ] repos with too little history
               Not enough history for 1 repo: fewer than 3 ticket-linked PRs per project (payments-api).
               They were not assigned.
    
    Glossary candidates (1)
      · [low ] glossary candidates
               0 recurring terms in 2 sampled ticket titles: 0 already appear in code or changed paths,
               0 have too few focused PRs to compare, 0 have no path word that stands out, 0 point at a
               code word a commoner term already took; 0 proposed. Single words only; expect misses and
               some wrong pairs.
    
    Languages (1)
      · [low ] languages.tickets
               1 of 2 sampled ticket titles look Turkish, 1 English, 0 another language, 0 undecided.
               Too few to say (10 classified titles needed). Language detection is a heuristic
               (Turkish-only letters and small word lists for tr/en). `languages.tickets` was left as it
               is.
    
    Added to the draft: 0 project key(s), 0 grouped repo(s), 0 team(s), 0 repo(s) on existing teams, 0
    glossary candidate(s), 0 convention(s).
    Findings by confidence: 2 high, 0 medium, 4 low.
    
    ✔ Wrote the draft to safran.draft.yaml
    → It is a draft, not your profile. Review it (start with the items marked low),
      then rename it over safran.yaml and run `safran profile check --profile safran.yaml`.

    Progress (the step being worked on) goes to stderr while it runs.

    JSON

    The document has six keys. stats and one element of findings are shown in full; profile is the complete draft profile as an object (its keys are left exactly as they are in the profile), and a finding's detail is kept as produced.

    {
      "draft_file": "/work/acme/safran.draft.yaml",
      "replaced": true,
      "wrote_profile": false,
      "stats": {
        "repos": 2,
        "cloned_repos": 2,
        "pull_requests": 3,
        "pull_requests_used": 2,
        "dropped": {
          "bot": 1,
          "noise_title": 0,
          "mass_change": 0,
          "many_tickets": 0,
          "duplicate": 0
        },
        "linked_pull_requests": 2,
        "unlinked_share": 0,
        "tickets_sampled": 2,
        "tickets_failed": 0,
        "added": {
          "projects": 0,
          "grouped_repos": 0,
          "teams": 0,
          "team_repos": 0,
          "glossary": 0,
          "conventions": 0,
          "languages": false
        },
        "findings": {
          "low": 3,
          "medium": 0,
          "high": 2
        }
      },
      "findings": [
        {
          "kind": "coverage",
          "subject": "pull requests ignored as noise",
          "confidence": "high",
          "evidence": "1 of 3 merged PRs were ignored: 1 by bot accounts, 0 merge/revert PRs, 0 mass changes, 0 naming many tickets at once, 0 repeats of the same change to another branch.",
          "detail": {
            "applied": false,
            "bot": 1,
            "noiseTitle": 0,
            "massChange": 0,
            "manyTickets": 0,
            "duplicate": 0
          }
        }
      ],
      "profile": {}
    }

    In this listing findings is cut to its first element and profile is emptied; the stats come from a run with --no-glossary, which is why they count one finding fewer than the human output above. The types behind the document are in the @safran/discover reference.

    Exit codes and mistakes

    0 when the draft was written, 1 when discovery stopped with an error, 2 for a wrong command line, 130 when interrupted.

    $ safran discover --write
    ✘ --write replaces your profile with the draft
    → Pass --write --force if that is what you want; without --write the draft goes to safran.draft.yaml for review.
    • Treating the draft as the profile. Nothing reads safran.draft.yaml. Review it, rename it over the profile, then run safran profile check.
    • Running it against local hosts only. Teams and glossary come from merged pull requests; a local host lists none, so there is nothing to infer from.
    • --out pointing at the profile. Refused; replacing the profile is what --write --force is for.
    • Expecting comments to survive. The draft is generated from the parsed profile, with a header comment and # discovered marks on what was added; comments in your own file are not carried over. Keep the profile in version control before replacing it.