---
name: repository-context-file-optimizer
description: "Restructures repository agent instruction files by splitting historical notes, task logs, and verbose references into on-demand secondary docs while keeping the root file lean. Use when coding sessions start with excessive context overhead."
license: CC-BY-4.0
compatibility: "Needs access to: Terminal, Docs, Notes."
metadata:
  author: "BotBento Editorial"
  version: "2026-10-16"
  source: "https://botbento.com/usecases/repository-context-file-optimizer/"
  kind: skill
  hermes:
    tags: ["coding", "context", "prompting", "repository", "docs"]
    category: coding
    requires_toolsets: ["terminal", "file"]
---
# Repository context file optimizer

Restructure repository instruction files into modular docs to reduce startup context overhead

## When to use

Analyze project agent instructions, prompt context, and setup files to split historical notes, completed task logs, and verbose reference documentation into on-demand secondary files. Keep the primary root instruction file lean and organized so coding sessions start with minimal token overhead while preserving access to project guidelines.

## Inputs

- `repository_path`: Path to the repository whose root agent instruction and documentation files should be analyzed.
- `instruction_file_scope` (optional): Specific root instruction or documentation files to review; defaults to the repository root files.
- `retention_preferences` (optional): Notes or references that must stay in the primary instruction file rather than move to secondary docs.

## Steps

1. When you ask: Request context file cleanup (A person asks to clean up or reduce the repository's startup instruction context.)
2. Analyze doc structure and draft splits
3. Present modular docs for approval

## Instructions

Inspect the repository for root agent instruction files and documentation. Analyze file sizes, repetitive task logs, and architectural notes. Draft a modular file structure that separates immediate core rules from reference documentation. Present the planned file restructuring and backups to the user. Require explicit approval before modifying, moving, or deleting any files or writing new configurations in the workspace.

## Approvals

- Modifying any repository files waits for explicit user approval.
- Moving existing documentation into secondary files waits for explicit user approval.
- Deleting any files waits for explicit user approval.
- Writing new configuration files in the workspace waits for explicit user approval.

## Output

Proposed modular document structure with split plan and backup notes for review. (format: markdown)

## Harness notes

- Claude Code: Save this file as ~/.claude/skills/repository-context-file-optimizer/SKILL.md (or .claude/skills/repository-context-file-optimizer/SKILL.md in the repo). Claude Code loads it when the task matches; run /repository-context-file-optimizer to start it directly.

## Source

Summarized in our own words from [claude-token-optimizer: Cut the tokens Claude Code loads at session start. CLI that sets up a small CLAUDE.md with on-demand docs, measures ](https://github.com/nadimtuhin/claude-token-optimizer) (GitHub, checked 2026-10-16). Any results described there are the authors’ own.

From the BotBento use-case directory: https://botbento.com/usecases/repository-context-file-optimizer/. Licence: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
