# ask-context-janitor

Aggressive token optimizer and context summarizer designed for AI orchestrators dealing with massive log files, pull requests, or audit reports.

## Purpose

When an AI orchestrator is handling complex, multi-agent tasks or digesting massive amounts of text (e.g., repository-wide audits, massive Git diffs, or verbose build logs), its context window fills up rapidly, leading to "context bloat", hallucination, or performance degradation. 

The `ask-context-janitor` is a highly-constrained skill that operates as a token-optimizing subagent. Its pure focus is taking verbose inputs and ruthlessly summarizing them into minimalist, structured data points (JSON or succinct Markdown lists) that are safe to feed back into the main agent's working memory. 

## Usage

This skill is intended for instances where large files or extensive outputs from parallel agents need to be digested without polluting the main contextual space.

Invoke the skill when you encounter:
- Massive `.log` files from build errors.
- Massive `ARCHITECTURAL_AUDIT.md` files generated by multiple agents.
- Large `git diff` outputs spanning many files.

The AI will output an `OPTIMIZED_CONTEXT.md` file stripping away boilerplate and leaving only vital information.

## Examples

### Before (Raw Log)
```text
2026-03-07T14:32:11 [INFO] Starting build process...
2026-03-07T14:32:11 [INFO] Fetching dependencies from registry.npmjs.org
2026-03-07T14:32:12 [WARN] Unmet peer dependency for React 18, found 17
2026-03-07T14:32:15 [ERROR] Webpack compilation failed: Cannot resolve module 'crypto' in /src/utils/hash.js
2026-03-07T14:32:15 [INFO] Shutting down build process.
```

### After (Optimized output)
```markdown
# Error Digest
- **Issue**: Webpack compilation failed. Missing module 'crypto'.
- **File**: `/src/utils/hash.js`
- **Warning**: Unmet peer dependency (React 18 expected, 17 found).
```

## Best Practices

- **Never allow write access**: This skill must operate purely as a reader and synthesizer. It must not modify source code.
- **Instruct strict schemas**: Always tell the janitor the exact JSON or markdown format you want returned.
- **Use for Subagent Aggregation**: If 5 subagents return 5 full markdown reports, use the context janitor to merge them into a 10-line executive summary.

## Notes
The agent running this skill should ideally be a smaller, faster model (e.g., Haiku or Flash) as its primary job is parsing and reduction, rather than deep logical reasoning.
