Quickstart
By the end of this page you will have Safran installed, a profile, an index of a few repositories you can search from the terminal, and Claude Code connected to it. The first pass needs no tracker and no token: it reads repositories that are already on your disk. The second pass adds Jira and Azure Repos.
Every output block below was captured from the real CLI, run against a small fictional
company, acme. Paths are shown as /work/acme/…; yours will differ.
Before you start
You need Bun 1.3 or newer, git, and an embedder. The default
embedder is a local Ollama with the bge-m3 model:
ollama pull bge-m3Requirements has the details and the alternatives.
1. Get Safran
Safran is not on a package registry. Clone the repository and install its dependencies:
git clone https://github.com/fport/safran /work/safran
cd /work/safran
bun installThe command is bin/safran, a small shell launcher inside the checkout. Put it on your PATH
once, with a symbolic link:
mkdir -p ~/.local/bin
ln -s /work/safran/bin/safran ~/.local/bin/safran$ safran --version
safran 0.1.02. Write a profile
Pick a directory for the company. The profile, its .env and the data/ directory live
there. In this walk-through it is /work/acme, and the repositories are already checked out
under /work/acme/repos:
/work/acme/
repos/
payments-api/ src/refund/service.ts, src/refund/policy.ts, src/webhook/retry.ts
ledger/
web-app/safran init writes a starter profile. Run without flags it asks questions; with --yes it
takes everything from flags:
$ cd /work/acme
$ safran init --yes --company acme --language tr --host local --set host.path=./repos
✔ Wrote safran.yaml
No tracker yet: add one under `trackers:` when you want tickets.
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--language tr says tickets are written in Turkish. --host local picks the code host that
reads directories in place; host.path is a directory whose immediate subdirectories are
repositories. This is the file it wrote (init turns the relative path into an absolute one):
# 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
code:
hosts:
- id: local
type: local
path: /work/acme/repos
embeddings:
type: ollama
model: bge-m3init contacts nothing and asks for no secret. The profile explains
every key.
3. Check it
safran profile check validates the file and builds every connector, without calling any
service:
$ safran profile check
✔ safran.yaml is valid
company acme
languages tickets tr, code en
trackers none
code hosts local
doc sources none
groups none
teams none
glossary 0 terms
conventions 0
embeddings ollama (bge-m3)
data data
Connectors were built, not called. `safran profile check --online` makes one call to each.safran doctor checks the machine: Bun, git, how the CLI was started, the profile, the
environment variables the profile names, the embedder (one tiny call), the repositories and
the index.
$ 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): 0 trackers, 1 code host
✔ environment the profile references no environment variables
✔ embedder ollama:bge-m3 answered in 32 ms (1024 dimensions)
✔ repos 3 repos listed
! index not built yet
→ Run `safran sync`.
✔ links not applicable: no code host in the profile lists pull requests
! No failures, 1 warning.If the embedder line fails, Ollama is not running or the model is not pulled. The hint on the
line says which.
4. Index the code
safran sync clones or fetches the repositories of remote hosts, reads local ones in place,
and indexes what changed since the last run:
$ safran sync
ledger scanning files
ledger indexing 1/1 files 100%
payments-api scanning files
payments-api indexing 4/4 files 100%
web-app scanning files
web-app indexing 1/1 files 100%
repo status changed unchanged chunks time detail
✔ ledger ok 1 0 1 75 ms 1 embedded, 0 from cache
✔ payments-api ok 4 0 4 150 ms 4 embedded, 0 from cache
✔ web-app ok 1 0 1 50 ms 1 embedded, 0 from cache
3 repos: 3 ok in 291 msThe index is a SQLite file under /work/acme/data/index/. A second safran sync only touches
files whose content changed. The first run over a real company takes as long as embedding
every chunk takes on your machine; later runs are incremental.
5. Search
safran search searches every indexed repository at once, by meaning and by words:
$ safran search "where is the remaining refundable amount checked" --limit 2
1 payments-api src/refund/policy.ts:1-16
other · RefundRequest, RefundNotAllowedError, a… · typescript · score 0.600 (dense 0.604, lexical 0.572)
1 │ export interface RefundRequest {
2 │ paymentId: string;
3 │ amount: number;
4 │ capturedAmount: number;
5 │ alreadyRefunded: number;
6 │ branch: string;
7 │ }
8 │
… 8 more lines (--full, or: safran read payments-api src/refund/policy.ts --lines 1-16)
2 payments-api src/refund/service.ts:1-21
api-service · RefundResult, refundPayment, postLedger… · typescript · score 0.521 (dense 0.579, lexical 0.000)
1 │ import { assertRefundable, type RefundRequest } from "./policy";
2 │
3 │ export interface RefundResult {
4 │ refundId: string;
5 │ amount: number;
6 │ partial: boolean;
7 │ }
8 │
… 13 more lines (--full, or: safran read payments-api src/refund/service.ts --lines 1-21)
2 hits (limit 2; raise it with --limit)Each hit names the repository, the file and the line range, and reports the score of each
channel. Scores are comparable within one result list only. For an exact string, use
safran grep; to print lines, safran read:
$ safran grep assertRefundable
payments-api src/refund/policy.ts
12 ▸ export function assertRefundable(request: RefundRequest): void {
payments-api src/refund/service.ts
1 ▸ import { assertRefundable, type RefundRequest } from "./policy";
11 ▸ assertRefundable(request);
3 matches$ safran read payments-api src/refund/policy.ts --lines 11-16
payments-api src/refund/policy.ts:11-16 (16 lines)
/** A partial refund may never exceed what is left of the captured amount. */
export function assertRefundable(request: RefundRequest): void {
if (request.amount <= 0) throw new RefundNotAllowedError("refund amount must be positive");
const remaining = request.capturedAmount - request.alreadyRefunded;
if (request.amount > remaining) throw new RefundNotAllowedError("refund exceeds the remaining captured amount");
}Teach it one word
acme's tickets are in Turkish and its code is in English. Add a glossary to
/work/acme/safran.yaml, mapping the word people write to the words the code uses:
glossary:
- term: İade
code: [refund, chargeback]
- term: Sepet
code: [basket, cart]Now a query in the ticket language is expanded before it reaches the index, and the first line of the output says so:
$ safran search "kısmi iade" --limit 2
glossary: İade → refund, chargeback
1 payments-api README.md:1-3
doc · markdown · score 0.567 (dense 0.630, lexical 0.000)
1 │ # payments-api
2 │
3 │ Captures, refunds and chargebacks for acme. Refund rules live in `src/refund/policy.ts`.
2 payments-api src/refund/service.ts:1-21
api-service · RefundResult, refundPayment, postLedger… · typescript · score 0.516 (dense 0.574, lexical 0.000)
1 │ import { assertRefundable, type RefundRequest } from "./policy";
2 │
3 │ export interface RefundResult {
4 │ refundId: string;
5 │ amount: number;
6 │ partial: boolean;
7 │ }
8 │
… 13 more lines (--full, or: safran read payments-api src/refund/service.ts --lines 1-21)
2 hits (limit 2; raise it with --limit)No re-index was needed: the glossary changes the query, not the index. Glossary, teams and conventions has the exact matching rules.
6. Connect Claude Code
There are two ways. Use one, not both, or every tool appears twice.
The plugin starts the MCP server and adds four skills. Start Claude Code with the plugin directory of the checkout:
claude --plugin-dir /work/safran/pluginOn first use Claude Code asks for one option, profile: the absolute path of your profile,
here /work/acme/safran.yaml. Check that the server is up with /mcp, then ask something:
/safran:find-in-code where is the remaining refundable amount checked?Register the server on its own, for example in a project where you do not want the skills:
claude mcp add --transport stdio safran -- /work/safran/bin/safran mcp --profile /work/acme/safran.yamlBoth paths must be absolute. Always register bin/safran, never a bare bun run, for the
reason given in step 1.
The skills and what each one produces are described under Claude Code; the tools under MCP reference.
Add a tracker and a remote code host
The same steps with the connectors acme really uses: Jira Cloud for tickets, Azure Repos for code.
-
Write the profile. In a directory with no
safran.yamlyet (or with--forceto overwrite the one from the first pass):$ 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 requestsThe profile now names three environment variables. It never holds their values:
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: azure-repos type: azure-repos organization: acme projects: - Platform token_env: AZURE_DEVOPS_PAT embeddings: type: ollama model: bge-m3 -
Set the variables. Export them in your shell, or put them in a file named
.envin the same directory as the profile. A variable that is already set in the shell wins over the file. Never commit this file.# /work/acme/.env JIRA_EMAIL=dev@acme.test JIRA_TOKEN=paste-the-api-token-here AZURE_DEVOPS_PAT=paste-the-personal-access-token-hereWhich permissions each token needs is on the connector's page: Jira, Azure Repos. Secrets has the parsing rules of the file.
-
Check, this time with one call per connector. Offline,
safran profile checkreports each variable assetornot set. With--onlineit also lists projects from the tracker and repositories from the code host, which proves the tokens work.safran profile check --online -
Sync, then pull the history.
safran syncclones the repositories intodata/repos/and indexes them.safran links refreshreads merged pull requests and stores which ticket each one belonged to and which files it changed.safran sync safran links refresh -
Read a ticket, and let Safran draft the rest of the profile.
safran discoverproposes groups, teams, glossary terms and conventions from the merged pull requests. It writes a draft,safran.draft.yaml, next to the profile and leaves the profile itself alone; you review the draft and copy over what is right.safran ticket PAY-1423 --comments safran discover
If something fails
| What you see | What it means |
|---|---|
✘ Profile not found: …/safran.yaml | You are not in the directory of the profile. cd there, pass --profile <file>, or set SAFRAN_PROFILE. |
✘ … is not a valid profile: or ✘ The profile has N configuration problems: | The file was read but something in it is wrong. Each line names the path. See Validation errors. |
✘ Environment variable JIRA_TOKEN is not set | A connector was used without its token. Export the variable or add it to the .env next to the profile. |
✘ embedder in safran doctor | The embedding server did not answer. Start Ollama and pull the model, or point embeddings at another endpoint. |
| A command that worked in the checkout cannot find the profile elsewhere | You are running bun run safran outside the checkout. Use bin/safran. |
Troubleshooting covers more.
What to do next
- Concepts: how the profile, the connectors, the index, the server and the skills fit together.
- The profile: groups, teams, glossary and conventions make the answers specific to your company.
- A new company: the full setup, including discovery.
- Technical analysis: the skill most people came for.
- Evaluation: measure search on your own history before you trust it.
- SDK guide: the same things from TypeScript.