Give your model the code that matters.

Rank your repository by relevance and dependencies, then fit the useful source into an exact token budget.

A native CLI and a typed Python SDK, powered by Zig.

One task. The context it needs.

The task is smaller than the repository.

You’re working on authentication. The repository also contains HTTP routes, application settings, reports, and export tools. Pasting it all spends tokens on code the task doesn’t need.

Example repository

Focus authenticationBudget 560 tokens

Repository files6 files
  • app/auth.py
  • app/routes.py
  • app/session.py
  • app/config.py
  • tools/report.py
  • tools/export.py
app/auth.py · sourcePython
"""Authenticate API requests and refresh sessions."""
from app.session import Session

class Authenticator:
    """Validate tokens and manage authentication sessions."""
    def authenticate(self, token: str) -> Session:
        """Verify a token before creating an authenticated session."""
        if not token or token.startswith("expired:"):
            raise ValueError("invalid token")
        return Session(user_id=token, authenticated=True)

    def refresh(self, session: Session) -> Session:
        """Keep an authenticated session active."""
        if not session.authenticated:
            raise ValueError("authentication required")
        return Session(user_id=session.user_id, authenticated=True)

Keep the code that explains the change.

Focus on authentication. ContextCraft ranks the authentication module and follows its Session dependency, keeping the interface you need to understand the change.

Example repository

Focus authenticationBudget 560 tokens

app/auth.py → app/session.py

app/session.py · dependencyPython
from dataclasses import dataclass

@dataclass
class Session:
    user_id: str
    authenticated: bool = False

Spend the budget on useful detail.

Authentication and sessions keep their full source. Routes become a skeleton, export helpers keep signatures, and the report module contributes only its path. The selection uses the engine’s actual output for this example.

Example repository

Focus authenticationBudget 560 tokens

Repository filesSelected detail
  • app/auth.pyFULL
  • app/routes.pySKEL
  • app/session.pyFULL
  • app/config.pyFULL
  • tools/report.pyTREE
  • tools/export.pySIGS
tools/export.py · signaturesPython
def export_0(rows)
def export_1(rows)
def export_2(rows)
def export_3(rows)
def export_4(rows)
def export_5(rows)
def export_6(rows)
def export_7(rows)
def export_8(rows)

Complete artifact540 / 560 tokens

Take the context, within budget.

The complete JSON artifact uses 540 of 560 cl100k_base tokens, including paths and framing. Copy it as input for your model, or generate your own with the CLI.

Example repository

Focus authenticationBudget 560 tokens

Selected source, by file

FULL
app/auth.py · FULLPython
"""Authenticate API requests and refresh sessions."""
from app.session import Session

class Authenticator:
    """Validate tokens and manage authentication sessions."""
    def authenticate(self, token: str) -> Session:
        """Verify a token before creating an authenticated session."""
        if not token or token.startswith("expired:"):
            raise ValueError("invalid token")
        return Session(user_id=token, authenticated=True)

    def refresh(self, session: Session) -> Session:
        """Keep an authenticated session active."""
        if not session.authenticated:
            raise ValueError("authentication required")
        return Session(user_id=session.user_id, authenticated=True)
Complete JSON artifact

Copy the original JSON output, including all paths and selected source.

context.jsonJSON
{"files":["app/auth.py","app/routes.py","app/session.py","app/config.py","tools/report.py","tools/export.py"],"context":[{"path":"app/auth.py","language":"python","tier":"FULL","content":"\"\"\"Authenticate API requests and refresh sessions.\"\"\"\nfrom app.session import Session\n\nclass Authenticator:\n    \"\"\"Validate tokens and manage authentication sessions.\"\"\"\n    def authenticate(self, token: str) -> Session:\n        \"\"\"Verify a token before creating an authenticated session.\"\"\"\n        if not token or token.startswith(\"expired:\"):\n            raise ValueError(\"invalid token\")\n        return Session(user_id=token, authenticated=True)\n\n    def refresh(self, session: Session) -> Session:\n        \"\"\"Keep an authenticated session active.\"\"\"\n        if not session.authenticated:\n            raise ValueError(\"authentication required\")\n        return Session(user_id=session.user_id, authenticated=True)\n"},{"path":"app/routes.py","language":"python","tier":"SKEL","content":"\"\"\"HTTP entry points.\"\"\"\nfrom app.auth import Authenticator\n\ndef route_profile(request)\n    \"\"\"Handle the profile endpoint.\"\"\"\ndef route_settings(request)\n    \"\"\"Handle the settings endpoint.\"\"\"\ndef route_preferences(request)\n    \"\"\"Handle the preferences endpoint.\"\"\"\ndef route_notifications(request)\n    \"\"\"Handle the notifications endpoint.\"\"\"\ndef route_activity(request)\n    \"\"\"Handle the activity endpoint.\"\"\"\ndef route_history(request)\n    \"\"\"Handle the history endpoint.\"\"\""},{"path":"app/session.py","language":"python","tier":"FULL","content":"from dataclasses import dataclass\n\n@dataclass\nclass Session:\n    user_id: str\n    authenticated: bool = False\n"},{"path":"app/config.py","language":"python","tier":"FULL","content":"\"\"\"Application settings.\"\"\"\nfrom dataclasses import dataclass\n\n@dataclass\nclass Config:\n    host: str = \"127.0.0.1\"\n    port: int = 8080\n    timeout_seconds: int = 30\n"},{"path":"tools/export.py","language":"python","tier":"SIGS","content":"def export_0(rows)\ndef export_1(rows)\ndef export_2(rows)\ndef export_3(rows)\ndef export_4(rows)\ndef export_5(rows)\ndef export_6(rows)\ndef export_7(rows)\ndef export_8(rows)"}]}

Complete artifact540 / 560 tokens

  1. Repository
  2. Focus
  3. Detail
  4. Context

Example repository

Focus authenticationBudget 560 tokens

Repository files6 files
  • app/auth.py
  • app/routes.py
  • app/session.py
  • app/config.py
  • tools/report.py
  • tools/export.py
app/auth.py · sourcePython
"""Authenticate API requests and refresh sessions."""
from app.session import Session

class Authenticator:
    """Validate tokens and manage authentication sessions."""
    def authenticate(self, token: str) -> Session:
        """Verify a token before creating an authenticated session."""
        if not token or token.startswith("expired:"):
            raise ValueError("invalid token")
        return Session(user_id=token, authenticated=True)

    def refresh(self, session: Session) -> Session:
        """Keep an authenticated session active."""
        if not session.authenticated:
            raise ValueError("authentication required")
        return Session(user_id=session.user_id, authenticated=True)

Use it where your code lives.

Install the CLI for your terminal, or keep an engine alive in Python while you try different budgets and focus queries.

Install
InstallShell
uv tool install 'contextcraft-ai[cli]'
Generate contextShell
contextcraft . --budget 8000 \
  --focus "authentication" \
  -o context.md

Download a standalone binary from GitHub Releases, or follow the installation guide.

One budget. Room for the right detail.

Keep the implementation you’re working on and the interfaces around it. Less relevant files can contribute an outline or a path, leaving space for useful context.

Full source
The complete source, with secret protection applied.
Skeleton
Structure and documentation, with implementation bodies removed.
Signatures
A compact declaration outline.
Tree
A path in the repository listing.

Keep sensitive source out of the output.

Potential secrets are redacted by default, and sensitive files stay path-only.

Use block mode when findings should stop generation, and review the result before sharing it.

Read about secret protection

Start with your next question.

Choose a repository, describe the task, and decide how much context to give your model.

Generate your first context