Voice profile and behavioral policy infrastructure for production AI systems.
traits.dev helps teams define how assistants should communicate, validate policy safety before shipping, compile model-aware system prompt blocks, and evaluate adherence over time.
- Versioned YAML profiles instead of ad hoc prompt text
- Schema validation with safety checks (
S001toS008) - Deterministic profile composition (
extends) for reusable policy layers - Model-aware compilation for Claude and GPT prompt placement
- Multi-tier evaluation tooling for local and CI workflows
This repository is a monorepo containing core tooling and integration packages.
@traits-dev/core- Runtime SDK for load/resolve/validate/compile/inject/eval/import flows
- Public API plus internal monorepo entrypoint (
@traits-dev/core/internal)
@traits-dev/cli- Commands:
init,validate,compile,eval,import
- Commands:
@traits-dev/vercel- Vercel AI SDK middleware via
withPersonality() - One-line model wrapping with eager compile and automatic system injection
- Vercel AI SDK middleware via
@traits-dev/mcp- MCP server exposing traits tools/resources for Claude Desktop, Cursor, and other MCP clients
- Run with
npx @traits-dev/mcportraits-mcp
pnpm add @traits-dev/corepnpm add @traits-dev/vercel aipnpm add -D @traits-dev/cliRun without install:
npx -y @traits-dev/mcp# 1) Create a starter profile
pnpm exec traits init my-profile.yaml --template resolve
# 2) Validate with strict safety gating
pnpm exec traits validate my-profile.yaml --strict
# 3) Compile for your target model
pnpm exec traits compile my-profile.yaml --model gpt-4o
# 4) Optional: prompt budget awareness
pnpm exec traits compile my-profile.yaml --model gpt-4o --budget --budget-limit 2000
# 5) Evaluate against built-in suites or custom samples
pnpm exec traits eval my-profile.yaml --model gpt-4o --suite support --tier 1
pnpm exec traits eval my-profile.yaml --model gpt-4o --format json
pnpm exec traits eval my-profile.yaml --model gpt-4o --format junit --junit-threshold 0.7import { compileProfile, injectPersonality, validateProfile } from "@traits-dev/core";
const validation = validateProfile("profiles/resolve.yaml", { strict: true });
if (!validation.isValid) {
throw new Error("Profile is not valid for production use.");
}
const compiled = compileProfile("profiles/resolve.yaml", {
model: "gpt-4o",
explain: true
});
const finalSystem = injectPersonality({
compiledPersonality: compiled,
model: "gpt-4o",
system: "You are a helpful assistant."
});import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { withPersonality } from "@traits-dev/vercel";
const model = withPersonality(
openai("gpt-4o"),
"profiles/resolve.yaml",
{ strict: true, bundledProfilesDir: "profiles" }
);
const result = await generateText({
model,
prompt: "I was charged twice. Please fix this."
});
console.log(result.text);@traits-dev/mcp exposes starter profiles as MCP resources and traits operations as tools.
Claude Desktop config:
{
"mcpServers": {
"traits": {
"command": "npx",
"args": ["-y", "@traits-dev/mcp"]
}
}
}MCP surface:
- Tools:
traits_validate,traits_compile,traits_list_profiles - Resources:
traits://profilestraits://profiles/{name}traits://profiles/{name}/compiled/{model}
Supported profile schemas:
v1.4baseline voice-policy schemav1.5addscapabilitiesboundariesv1.6adds:- Array
extends(string | string[]) with left-to-right merge - Locked rule constraints via
{ rule, locked?: boolean }
- Array
schema: "v1.6"
extends:
- "brand-base"
- "domain-support"
- "channel-chat"
behavioral_rules:
- "Lead with implementation, not theory"
- rule: "Never claim actions without tool confirmation"
locked: true
capabilities:
tools: []
constraints:
- rule: "Never claim completed side effects without tool evidence."
locked: true
handoff:
trigger: "Request requires unavailable operations"
action: "Offer human handoff"Validation includes:
- Structural checks (
V001-V003) - Safety checks (
S001-S008) - Overspec thresholding (
S004) - Inheritance safety regression protection (
S006)
Important inheritance behavior in v1.6:
- Array
extendsmerges parent profiles left to right, then child on top - Locked inherited behavioral rules cannot be removed by
behavioral_rules_remove - Attempted locked removal emits
S006error
- Tier 1: deterministic vocabulary/structure/helpfulness scoring
- Tier 2: embedding-based adherence scoring
- Tier 3: LLM-judge dimension adherence scoring
CLI output formats:
- Human-readable text (default)
- JSON (
--format json) - JUnit (
--format junit) for CI dashboards/gates
Built-in suites:
supporthealthcaredevelopereducatoradvisor
packages/core/ SDK runtime + validators + compiler + evaluators
packages/cli/ CLI command surface
packages/vercel/ Vercel AI SDK middleware adapter
packages/mcp/ MCP server package
profiles/ Canonical profile artifacts + test fixtures
knowledge-base/ Pattern libraries + calibration metadata
experiment/ Calibration and evaluation scripts/artifacts
docs/site/ VitePress documentation content
pnpm install
pnpm build
pnpm typecheck
pnpm testUseful scripts:
pnpm docs:devrun docs locallypnpm showcase:buildrebuild static showcase datapnpm calibration:checkstrict calibration status check
This repo uses Changesets + GitHub Actions release automation.
pnpm changeset
pnpm version-packages
git push origin mainPublishing uses token-based auth via Changesets GitHub Action.
- Schema reference:
docs/site/schema-reference.md - Guides:
docs/site/guides/ - API references:
docs/site/api/core.mddocs/site/api/vercel.mddocs/site/api/mcp.md
- Contributing guide:
CONTRIBUTING.md - Security policy:
SECURITY.md
MIT, see LICENSE.