Skip to content
safran

Type to search. Enter opens the first result.

    The profile

    The profile is the one file that makes Safran about your company. This page shows a complete one, then explains how Safran finds it, where it puts data, and how it validates it.

    A complete profile

    This is acme's profile. It validates as written; copy it and change the values.

    safran.yaml
    version: 1
    company: acme
    
    languages:
      tickets: tr          # language people write tickets in
      code: en             # language of identifiers and comments
    
    trackers:
      - id: jira
        type: jira
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL        # the NAME of the variable, never the value
        token_env: JIRA_TOKEN
        projects: [PAY, MOB, WEB]    # ticket keys PAY-…, MOB-…, WEB-… belong to this tracker
    
    code:
      hosts:
        - id: azure
          type: azure-repos
          organization: acme
          project: Platform
          token_env: AZURE_DEVOPS_PAT
          exclude: ["*-archive"]     # globs on repo names; exclude wins over include
      groups:                        # named sets of repos, used to scope a search
        backend: [payments-api, ledger]
        mobile: [acme-ios, acme-android]
        frontend: [web-app, admin-panel]
    
    docs:
      - id: wiki
        type: confluence
        url: https://acme.atlassian.net
        email_env: JIRA_EMAIL
        token_env: CONFLUENCE_TOKEN
        spaces: [PAY]
    
    teams:
      - name: Payments
        projects: [PAY]
        repos: [payments-api, ledger]
      - name: Mobile
        projects: [MOB]
        repos: [acme-ios, acme-android]
        confidence: low              # guessed by discovery; confirm by hand, then delete this line
        source: 9 ticket-PR links
      - name: Web
        projects: [WEB]
        repos: [web-app, admin-panel]
    
    glossary:                        # ticket word -> the words the code uses
      - term: Sepet
        code: [basket, cart]
      - term: İade
        code: [refund, chargeback]
    
    conventions:                     # free-form rules the skills quote to the agent
      - Task titles are written in English.
      - Branch names follow feature/<TICKET-KEY>-short-description.
    
    embeddings:
      type: ollama
      model: bge-m3

    Only version and company are required. Everything else has a default, so a profile grows with what you connect:

    SectionWhat it tells SafranWithout it
    languagesThe language of tickets and of codeBoth are en
    trackersWhere tickets are, and which project keys belong to which trackerNo ticket commands or tools
    code.hostsWhere the repositories areNothing to sync or search
    code.groupsNamed sets of repositoriesSearches cannot be scoped by group
    docsWikis whose pages tickets link toLinked pages are not fetched
    teamsWho owns which project and repositoryOwnership is inferred from merged pull requests, or unknown
    glossaryTicket words and the code words they stand forQueries are sent to the index as written
    conventionsRules the skills quote to the agentThe skills have no house rules to apply
    embeddingsWhich embedder to useA local Ollama with bge-m3
    pluginsExtra plugin modules to loadOnly the built-in connector types

    Profile reference has the type, default and constraints of every key. Secrets explains the _env fields.

    Create one

    safran init writes a starter profile. Without flags it asks questions; with --yes it uses flags and defaults. It contacts no service and asks for no secret.

    $ safran init --yes --company acme --language tr --tracker jira --set tracker.url=https://acme.atlassian.net --set tracker.projects=PAY,MOB,WEB --host azure-repos --set host.organization=acme --set host.projects=Platform
    ✔ Wrote safran.yaml
    
    Set these environment variables, in your shell or in a .env file next to the profile:
      AZURE_DEVOPS_PAT  ! not set
      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

    What init does and does not do:

    • It writes one tracker, one code host and the embedder. Their id is set to their type (jira, azure-repos); rename it in the file if you like. Groups, teams, glossary and conventions are yours to add, by hand or from the draft safran discover produces.
    • --set <section>.<field>=<value> sets a connector field, where the section is tracker, host or embeddings. init knows the common fields of the built-in types; anything else is edited in the file.
    • It refuses to overwrite an existing profile without --force.
    • The file it writes has already passed both validation steps below.

    The other way is to copy safran.example.yaml from the repository root and edit it.

    How the profile is found

    The CLI looks in this order and uses the first that is given:

    1. --profile <file> on the command line. safran profile check also accepts the file as an argument.
    2. The SAFRAN_PROFILE environment variable.
    3. safran.yaml in the directory you run the command from.
    safran profile check --profile /work/acme/safran.yaml
    SAFRAN_PROFILE=/work/acme/safran.yaml safran status

    The difference between naming a profile and letting it be found matters for one thing: a profile that was merely found in the current directory may not load plugins: modules, because importing a module runs its code. See Validation errors.

    The Claude Code plugin takes the profile as an absolute path; see Plugin.

    In the SDK, profile is a path or the profile itself as an object. With no option it is safran.yaml in the working directory:

    open.ts
    import { createSafran } from "@safran/core";
    
    await using safran = await createSafran({ profile: "/work/acme/safran.yaml" });
    
    console.log(safran.profile.company); // "acme"
    console.log(safran.profileFile); // "/work/acme/safran.yaml"
    console.log(safran.dataDir); // "/work/acme/data"

    Where data goes

    Everything Safran stores goes under one data directory. By default that is data/ next to the profile file, so one directory holds the whole installation for a company:

    /work/acme/
      safran.yaml      the profile
      .env             values of the variables the profile names (optional, never committed)
      data/            clones, the index, the work-history store

    --data-dir <dir> (CLI) or dataDir (SDK) puts it somewhere else. When the profile is passed to the SDK as an object there is no profile file, and the default is data/ in the working directory. Everything in the data directory can be deleted and rebuilt. Architecture lists what is inside.

    Relative paths inside the profile (a local code host's path, a plugins: entry) are resolved against the directory of the profile file, not against where you run the command.

    Validation happens in two steps

    A profile is checked twice, by two different owners.

    1. The profile schema checks the shape every profile shares: the top-level keys, the fields every connector entry has (id, type, and the common ones), teams, glossary, and the rules that span entries (no duplicate ids, a project key under one tracker only). The top level and the teams and glossary entries are strict: an unknown key is an error. Connector entries are deliberately loose at this step, because their other fields belong to the connector. A failure here is PROFILE_INVALID.

    2. Each connector's own schema then validates its whole entry, strictly. This is where a typo in a field name, a missing required field or a token pasted into a token_env field is caught. Every entry is tried, so one run reports everything that is wrong. A failure here is PLUGIN_CONFIG_INVALID, or PLUGIN_NOT_FOUND when no plugin handles the type.

    Neither step touches the network, and neither needs a token to be set. createSafran runs both every time, so the CLI, the MCP server and your own code all refuse the same profiles.

    Check it

    safran profile check runs both steps and prints what it understood:

    $ safran profile check
    ✔ safran.yaml is valid
    
      company      acme
      languages    tickets tr, code en
      trackers     jira
      code hosts   azure (azure-repos)
      doc sources  wiki (confluence)
      groups       backend (2), mobile (2), frontend (2) — 6 repos
      teams        Payments, Mobile, Web
      glossary     2 terms
      conventions  2
      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
      AZURE_DEVOPS_PAT  not set  code.hosts.azure.token_env
      CONFLUENCE_TOKEN  not set  docs.wiki.token_env
      JIRA_EMAIL        not set  trackers.jira.email_env, docs.wiki.email_env
      JIRA_TOKEN        not set  trackers.jira.token_env
    ! AZURE_DEVOPS_PAT, CONFLUENCE_TOKEN, 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.
    
    Connectors were built, not called. `safran profile check --online` makes one call to each.

    Things to read off this output:

    • The profile is valid even though no token is set. Missing variables are reported, not failed: a connector fails only when it is used. The exit code is 0.
    • The Mobile team carries confidence: low, so the command asks a person to confirm it.
    • --online makes one cheap call per tracker (list projects) and per code host (list repositories), and exits with 1 if any of them fails. Use it to prove that tokens and URLs work.
    • --json prints the same facts as one JSON document.

    When the profile is not valid, the command prints one line per problem with its path. Those messages and their fixes are on Validation errors.

    A profile in TypeScript

    A profile does not have to be a file. defineProfile types an object as profile input, and createSafran accepts it directly. The same two validation steps run.

    inline-profile.ts
    import { createSafran } from "@safran/core";
    import { defineProfile } from "@safran/profile";
    
    const profile = defineProfile({
      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"],
        },
      ],
      teams: [{ name: "Payments", projects: ["PAY"], repos: ["payments-api", "ledger"] }],
      glossary: [{ term: "İade", code: ["refund", "chargeback"] }],
    });
    
    // `index: false` turns code search off: a tickets-only instance needs no embedder.
    await using safran = await createSafran({ profile, index: false });
    
    console.log(safran.profile.languages.tickets); // "tr"
    console.log(safran.company.expand("kısmi iade")); // ["refund", "chargeback"]

    Next