Design principles
These are the rules the code is written to. Each one explains a behaviour you will meet, so this page is also a guide to why Safran acts the way it does.
Profile over code
Nothing that differs per company is in the source or in a skill: no project key, no repository name, no team name, no URL. If it differs per company, it is a field of the profile schema.
What follows from it:
- A second company needs a second
safran.yaml, not a fork. - The skills contain no company names. They call
get_company_profileand work from the answer. - When you find yourself wanting to edit a skill to mention your team, the right place is
conventions,teamsorglossaryin the profile.
See The profile.
No secrets in the profile
The profile stores the names of environment variables, never tokens, and its schema rejects a pasted token and a URL with credentials. The values come from the environment. This makes the profile safe to show to an agent and to review like any other document.
See Secrets.
The evidence rule
Every claim about code cites a repository, a file and a line range that a tool returned in the current session. When nothing is found, the answer says so and says what was searched. Nothing is described from memory or from a ticket's wording.
The product is built so that this is possible: every search hit and every grep match carries
its repo, path and lines; read_file returns numbered lines; long output is cut with an
explicit marker, never silently, so the agent knows when it has not seen everything.
Its sibling is the untrusted-data rule: text written by third parties (tickets, comments, wiki pages, source files) reaches the agent inside a wrapper with a random tag, and is information, never instructions.
Measure before changing retrieval
Whether search got better is decided by a measurement on the company's own history, not by an impression from three queries. A golden set is built from merged pull requests; a change to chunking, ranking, the embedder or the glossary is run against it before and after, and a regression blocks the change.
The same rule applies to these docs: they state a number only when it was measured, and say where it came from.
See Evaluation.
Local by default
Safran is cloned and run on your machine. There is no Safran service and no account.
- Tickets and code are read directly from your trackers and code hosts with your tokens.
- The index and the work-history store are SQLite files under the data directory. There is no database server and no vector database.
- The default embedder is a local Ollama. A remote embedding endpoint is your explicit choice in the profile.
- The MCP server speaks stdio by default; in HTTP mode it binds to loopback, and binding another address requires a token.
- The built documentation site loads nothing from another origin.
Library-first
The packages export plain functions and one factory, createSafran. The CLI, the MCP server and
the dashboard are thin shells over it: they parse input, call the library and format output.
They hold no logic of their own.
What follows from it: anything the CLI or an MCP tool can do, your code can do with the same call, and gets the same errors.
import { createSafran } from "@safran/core";
await using safran = await createSafran({ profile: "/work/acme/safran.yaml" });
// What `safran search "kısmi iade" --group backend` runs.
const { hits } = await safran.code.search("kısmi iade", { groups: ["backend"] });
// What the `who_owns` tool runs.
const owners = await safran.company.whoOwns({ repo: "payments-api" });
console.log(hits.length, owners.basis);See Architecture.
Read-only trackers
No tracker connector has a method that creates or changes anything, and the MCP server has no write tool. Skills draft text for a person to paste. An analysis that is wrong on paper costs a correction; a wrong ticket written into a shared tracker costs other people's time.
undefined is the default, false is off
The options object is the API. There is no builder and no second configuration path.
- Leaving an option out means "the default".
falsemeans "off":index: falsedisables code search,builtinPlugins: falsestarts with an empty plugin registry,expandGlossary: falsesearches without the glossary.- A sub-part accepts a live instance in place of configuration: pass your own
embedderorindexand Safran uses it.
import { createSafran } from "@safran/core";
// Tickets only: no index is opened and no embedder is ever built.
await using ticketsOnly = await createSafran({ profile: "/work/acme/safran.yaml", index: false });
// Everything on; one search without glossary expansion.
await using safran = await createSafran({ profile: "/work/acme/safran.yaml" });
const { effectiveQuery } = await safran.code.search("kısmi iade", { expandGlossary: false });
console.log(ticketsOnly.profile.company, effectiveQuery);See createSafran.
Errors say what to do next
Every intentional failure is a SafranError with a stable code, a message and a hint. You
branch on the code, never on the message text. Vendor errors do not cross a connector raw: an
HTTP 401 from any tracker is AUTH_FAILED, a 404 is NOT_FOUND, a 429 is RATE_LIMITED.
Messages may be shown to an agent, so they contain no tokens.
See Errors.
Connectors are small interfaces with declared capabilities
A tracker implements one interface; so does a code host, a doc source and an embedder. Optional
abilities are paired with an entry in the connector's capabilities, and a caller checks the
capability instead of probing for a method. Asking a connector for something it does not have
is UNSUPPORTED, with a message naming the connector.
Building a connector touches no network and reads no secret, so a profile can be validated offline and without tokens.
See Connectors and Writing plugins.
Batches do not fail as a whole
Operations over many repositories (sync, links refresh) return a result per repository with
its own status and error. One repository that cannot be cloned does not stop the others, and a
cancelled run reports what it finished.
See Lifecycle.
Limits are stated
Read-only tracker access, one install per company, connectors that were written from vendor documentation and not yet run against a live service: these are written down as plainly as the features. Status and limitations is the list.