faf-python-sdk
Persistent Project Context for Python. Parse, validate, score.
FAF defines. MD instructs. AI codes.
The foundation other Python FAF tools build on. If you're building MCP servers, CI validators, or any Python tool that needs to understand project context, start here.
Media Type: application/vnd.faf+yaml (IANA registered)
What's New in v1.3.1 — The Interop Edition
The SDK can now author AI-context files, not just parse and score them.
v1.3.1 is a copy patch — "generate" removed from external text (module docstring, the blockquote written into every AGENTS.md, README, CHANGELOG). No API change; the
faf_sdk.interopfunctions below are unchanged.
faf_sdk.interop — generate_agents_md(faf) and generate_gemini_md(faf), Python ports of faf-cli's src/interop/agents.ts + gemini.ts, in parity with the canonical TypeScript. Deterministic BETTER-shaped projection: setup (install→build→dev ordered) · tests · layout · conventions · three-tier guardrails · definition of done · security · commit · stack. Human Context (who/why marketing) is intentionally omitted from AGENTS.md — it belongs in the README / .faf DNA, not agent ops.
from faf_sdk import parse_file, generate_agents_md
faf = parse_file("project.faf")
print(generate_agents_md(faf.data.raw)) # takes the raw dict — carries top-level commands / key_files / security
Any Python FAF tool that authors an AI-context file wraps this now — never hand-roll one. gemini-faf-mcp 2.7.0's faf_agents / faf_gemini are the reference wrappers.
What's New in v1.2.0 — The Dart Edition
Adds detect_dart_project(): content-aware Dart/Flutter detection from a pubspec.yaml (Flutter app vs package · Dart MCP / backend / CLI / library), reproducing faf-cli's engine byte-for-byte — 20 shared fixtures, parity-tested.
from faf_sdk import detect_dart_project
d = detect_dart_project(".")
print(d.app_type, d.framework) # e.g. "mobile" "Flutter"
What's New in v1.1.0
Mk4 Championship Scoring Engine — the same 33-slot scoring algorithm used by the Rust compiler and TypeScript CLI, now in Python. Same slots, same formula, same scores. Every FAF tool in every language now agrees on what 100% means.
score_faf()— Mk4 scoring with 21-slot Base or 33-slot Enterprise tiers- 100% parity with
faf-wasm-sdk(Rust) andfaf-cli(TypeScript) - 3 crash bugs fixed (malformed YAML, null project fields)
- 175 tests including 88 WJTTC championship-grade tests (concurrency, adversarial input, security)
Why this matters: If you're building on FAF in Python — MCP servers, Gemini extensions, CI pipelines — your scores now match every other FAF tool exactly. No more "it scored 85% in the CLI but 60% in Python." One engine, one truth.
v1.1.2 is a patch release — package description aligned with the canonical "Persistent project context for Python" framing. CHANGELOG.md added. No code changes.
Installation
pip install faf-python-sdk
Quick Start
from faf_sdk import parse_file, score_faf
# Parse a .faf file
faf = parse_file("project.faf")
print(f"Project: {faf.project_name}")
# Score it with the Mk4 engine
with open("project.faf") as f:
result = score_faf(f.read())
print(f"Score: {result.score}% {result.tier}")
print(f"Slots: {result.populated}/{result.total} populated")
FAF defines. MD instructs. AI codes.
Mk4 Scoring
The Mk4 engine scores .faf files by checking 21 universal slots (project metadata, human context, tech stack). Each slot is Populated, Empty, or Slotignored. The score is the percentage of active slots that are populated.
from faf_sdk import score_faf, LicenseTier
# Base scoring (21 slots)
result = score_faf(yaml_content)
print(result.score) # 0-100
print(result.tier) # Trophy/Gold/Silver/Bronze/Green/Yellow/Red
print(result.populated) # slots with real data
print(result.active) # total minus slotignored
print(result.slots) # per-slot breakdown
# Enterprise scoring (33 slots — adds monorepo/infra)
result = score_faf(yaml_content, LicenseTier.ENTERPRISE)
Placeholder rejection: Values like "null", "unknown", "n/a", "Describe your project goal" are detected and scored as Empty — not Populated.
Slotignored: Set any slot to slotignored to exclude it from scoring. A backend-only project can mark frontend: slotignored and still reach 100%.
Parsing
from faf_sdk import parse, parse_file, stringify
# Parse from string or file
faf = parse(yaml_content)
faf = parse_file("project.faf")
# Typed access
print(faf.data.project.name)
print(faf.data.project.goal)
print(faf.data.stack.backend)
print(faf.data.human_context.who)
# Raw dict access
print(faf.raw["project"]["goal"])
# Convert back to YAML
yaml_str = stringify(faf)
Validation
from faf_sdk import validate
result = validate(faf)
if result.valid:
print(f"Valid! Score: {result.score}%")
else:
print("Errors:", result.errors)
print("Warnings:", result.warnings)
File Discovery
from faf_sdk import find_faf_file, find_project_root
# Find project.faf (walks up directory tree)
path = find_faf_file("/path/to/src")
# Find project root by markers (package.json, pyproject.toml, .git, etc.)
root = find_project_root()
API Reference
| Function | Returns | Description |
|---|---|---|
score_faf(yaml, tier?) |
Mk4Result |
Mk4 score (21 or 33 slots) |
parse(content) |
FafFile |
Parse YAML string |
parse_file(path) |
FafFile |
Parse from file path |
validate(faf) |
ValidationResult |
Structure validation + warnings |
stringify(data) |
str |
Convert back to YAML |
find_faf_file(dir?) |
str | None |
Find project.faf in tree |
find_project_root(dir?) |
str | None |
Find project root |
FAF Ecosystem
| Package | Platform | Registry |
|---|---|---|
| faf-python-sdk | Python foundation | PyPI |
| gemini-faf-mcp | Google Gemini | PyPI |
| claude-faf-mcp | Anthropic | npm + MCP #2759 |
| grok-faf-mcp | xAI | npm |
| faf-cli | CLI | npm |
If faf-python-sdk has been useful, consider starring the repo — it helps others find it.
Links
- Site: faf.one
- IANA Registration: application/vnd.faf+yaml
- Gemini MCP: gemini-faf-mcp
License
MIT
Metadata
Release files for faf-python-sdk 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| faf_python_sdk-1.3.1.tar.gz | 55.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| faf_python_sdk-1.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 79.7 kB
Release files / faf_python_sdk-1.3.1.tar.gz
| Download URL | faf_python_sdk-1.3.1.tar.gz |
|---|---|
| Size | 55.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2bb5e70c317c4ef78698bedf9168fdac9c06f551c3f57a7855953cb36559d28a
|
|
BLAKE2b-256 checksum How to use checksums |
e98128da0977a581e617bc5a7d04553cffeb9d163f41d906f70b55514acf11d3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency logRelease files / faf_python_sdk-1.3.1-py3-none-any.whl
| Download URL | faf_python_sdk-1.3.1-py3-none-any.whl |
|---|---|
| Size | 24.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4bb8ae752ae58a34df558811d18afe0c815321500dd59b865904055614e43dc1
|
|
BLAKE2b-256 checksum How to use checksums |
d60b8635b49e7edeb646fbe73cf386d920e3b957756c3032ade2d911d0b8fc00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.
Transparency log