context-generation

context-generation is a command for Claude Code from keychain-io/trustable-ai. It costs 0 tokens per session (4,879 once invoked), scanned A, original, MIT.

A workflow that creates repository-specific README.md files for people and CLAUDE.md files for directed agent context loading. A repository is a project's tracked file collection.

In plain words
What is it for?
Use it to analyze a repository and generate hierarchical documentation after initializing it with trustable-ai.
Why use it?
It creates documentation based on the actual directory structure, helping people and coding agents understand where and how to work.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/keychain-io/trustable-ai/context-generation
Clone the repo
git clone --depth 1 https://github.com/keychain-io/trustable-ai

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-generation

README.md
[![agentmods](https://agentmods.dev/badge/commands/keychain-io/trustable-ai/context-generation.svg)](https://agentmods.dev/commands/keychain-io/trustable-ai/context-generation)
Your own site
<a href="https://agentmods.dev/commands/keychain-io/trustable-ai/context-generation"><img src="https://agentmods.dev/badge/commands/keychain-io/trustable-ai/context-generation.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,879 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.04879
Opus 5 $0.00000 $0.02440
Sonnet 5 $0.00000 $0.00976
Haiku 4.5 $0.00000 $0.00488

Measured 3d ago against content hash c6fa89bf9573, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-generation scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/context-generation.md · 595 lines

How it starts

The opening of the file, as written. The whole thing — 595 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Generation Workflow

Generate hierarchical CLAUDE.md and README.md documentation structure with directed context loading for trusted-ai-development-workbench.

Purpose

This workflow analyzes your repository structure and creates:

  • README.md files for human-readable documentation
  • CLAUDE.md files with YAML front matter for directed context loading

Each file is tailored to the directory's actual contents, not generic templates.

Prerequisites

  1. Repository initialized with trustable-ai init
  2. Claude Code running in project root directory

Workflow Steps

Step 1: Analyze Repository Structure

Use Glob and Read tools to analyze the project:

from pathlib import Path
import os

# Project root
root = Path.cwd()

# Directories to skip
skip_dirs = {
    'node_modules', 'venv', '.venv', 'env', '.env',
    '__pycache__', '.git', '.svn', '.hg',
    'dist', 'build', 'out', 'target', 'bin', 'obj',
    '.idea', '.vscode', '.vs',
    'coverage', '.coverage', 'htmlcov',
    '.pytest_cache', '.mypy_cache', '.ruff_cache',
}

# Find significant directories (have source files)
def is_significant(directory):
    """Check if directory has source code files."""
    code_extensions = {'.py', '.js', '.ts', '.tsx', '.go', '.rs', '.java', '.cpp', '.c', '.rb'}
    files = list(directory.glob('*'))
    code_files = [f for f in files if f.is_file() and f.suffix in code_extensions]
    return len(code_files) >= 2  # At least 2 source files

def analyze_directory(dir_path):
    """Analyze a directory's contents."""
    files = []
    subdirs = []

    for item in dir_path.iterdir():
        if item.name.startswith('.') and item.name != '.claude':
            continue
        if item.name in skip_dirs:
            continue

        if item.is_dir():
            subdirs.append(item.name)
        elif item.is_file():
            files.append({
                'name': item.name,
                'extension': item.suffix,
                'size': item.stat().st_size
            })

    # Detect directory type
    dir_type = 'module'
    dir_name = dir_path.name.lower()

    type_patterns = {
        'src': 'source', 'lib': 'source', 'app': 'source', 'pkg': 'source',
        'tests': 'tests', 'test': 'tests', 'spec': 'tests', '__tests__': 'tests',
        'docs': 'documentation', 'documentation': 'documentation',
        'api': 'api', 'apis': 'api',
        'core': 'core',
        'config': 'configuration', 'configs': 'configuration',
        'scripts': 'scripts', 'bin': 'scripts',
        '.claude': 'claude_config',
    }

    dir_type = type_patterns.get(dir_name, 'module')

    # Count file types
    py_files = len([f for f in files if f['extension'] == '.py'])
    js_files = len([f for f in files if f['extension'] in ['.js', '.ts', '.tsx']])
    go_files = len([f for f in files if f['extension'] == '.go'])

    primary_lang = 'mixed'
    if py_files > js_files and py_files > go_files:
        primary_lang = 'python'
    elif js_files > py_files and js_files > go_files:
        primary_lang = 'javascript'
    elif go_files > 0:
        primary_lang = 'go'

    return {
        'path': str(dir_path),
        'relative_path': str(dir_path.relative_to(root)),
        'type': dir_type,
        'files': files,
        'subdirs': subdirs,
        'primary_language': primary_lang,
        'has_readme': (dir_path / 'README.md').exists(),
        'has_claude_md': (dir_path / 'CLAUDE.md').exists(),
    }

# Scan repository (max depth 3)
directories_to_document = []

# Always include root
directories_to_document.append(analyze_directory(root))

# Scan subdirectories
for item in root.rglob('*'):
    if not item.is_dir():
        continue

    relative = item.relative_to(root)

    # Check depth
    if len(relative.parts) > 3:
        continue

    # Skip ignored directories
    if any(skip in relative.parts for skip in skip_dirs):
        continue

    # Check if significant
    if is_significant(item):
        directories_to_document.append(analyze_directory(item))

print(f"📁 Found {len(directories_to_document)} directories to document:")
for d in directories_to_document:
    status = "✓ has docs" if d['has_claude_md'] else "○ needs docs"
    print(f"  {d['relative_path']:<30} {status} | {len(d['files'])} files | {d['type']}")

Read the full file on GitHub · 595 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 595 lines · 0 tokens per session scan A c6fa89bf9573

Subscribe to this mod's changes

context-generation is a command published in the GitHub repository keychain-io/trustable-ai (2 stars, last pushed 6mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 4,879 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.