Context for one file (context)
sprout context FILE [--budget N] [--json]sprout context is what to know before changing one file, in about --budget tokens (default 1500):
- Depends on: each dependency, and only the declarations this file uses from it. For Go that’s exact; elsewhere, declarations whose name appears in the file.
- Used by: the files that use it, and why.
- Tests that reach it: nearest first, with a
go testcommand for Go. - Declares: last, since whoever edits the file reads that anyway.
Each part gets a share of the budget and passes on what it doesn’t use. A part that doesn’t fit says how many items it has.
$ sprout context app/crud.py --budget 5002 dependencies · 3 direct users · 10 affected through them · 7 tests reach it
## depends on (and what it uses from each)app/core/security.py — imports app.core.security def verify_password(…) def get_password_hash(password: str) -> strapp/models.py — imports app.models class UserCreate(UserBase) class UserUpdate(SQLModel) class User(UserBase, table=True) class ItemCreate(ItemBase) +1 more
## used byapp/api/routes/login.py — imports app.crudapp/api/routes/users.py — imports app.crudapp/core/db.py — imports app.crud
## tests that reach ittests/api/routes/test_login.pytests/api/routes/test_users.pytests/crud/test_user.pytests/utils/item.pytests/utils/user.pytests/api/routes/test_items.pytests/conftest.py
## declaresdef create_user(*, session: Session, user_create: UserCreate) -> Userdef update_user(*, session: Session, db_user: User, user_in: UserUpdate) -> Anydef get_user_by_email(*, session: Session, email: str) -> User | Nonedef authenticate(*, session: Session, email: str, password: str) -> User | Nonedef create_item(*, session: Session, item_in: ItemCreate, owner_id: uuid.UUID) -> ItemIt’s --ai for one file: hand it to an agent before it edits, or read it yourself before touching code you don’t know. Agents get it as the context MCP tool.
--json prints the same parts as one object, for scripts and agents:
{ "schemaVersion": 1, "command": "context", "file": "b/b.go", "dependencies": [{ "path": "a/a.go", "reason": "uses a.Hello", "signatures": ["func Hello() string"] }], "users": [{ "path": "c/c.go", "reason": "uses b.B" }], "tests": ["b/b_test.go"], "declarations": ["func B() string"]}