.agents/skills/oat-repo-knowledge-index/SKILL.md
Use when onboarding OAT to a repository or when knowledge artifacts are stale. Generates or refreshes the codebase knowledge index using parallel mapper agents.
npx skillsauth add tkstang/open-agent-toolkit oat-repo-knowledge-indexInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Generate a comprehensive analysis of the codebase using parallel mapper agents.
When executing this skill, provide lightweight progress feedback so the user can tell what’s happening after they confirm.
Print a phase banner once at start using horizontal separators, e.g.:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ OAT ▸ CREATE REPO KNOWLEDGE INDEX ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Before multi-step work (thin index generation, spawning mappers, writing outputs), print 2–5 short step indicators, e.g.:
[1/4] Checking existing knowledge…[2/4] Generating thin index…[3/4] Spawning mappers…[4/4] Writing knowledge files…For long-running operations (subagent runs, synthesis, large repo scans), print a start line and a completion line (duration optional).
Keep it concise; don’t print a line for every shell command.
# Check for actual knowledge files (not just .gitkeep)
EXISTING_MD=$(find .oat/repo/knowledge -name "*.md" -type f 2>/dev/null | head -1)
If $EXISTING_MD is non-empty (actual content exists):
ls -la .oat/repo/knowledge/*.md 2>/dev/nullrm -rf .oat/repo/knowledge/*.md && mkdir -p .oat/repo/knowledgeIf $EXISTING_MD is empty (no content or only .gitkeep):
mkdir -p .oat/repo/knowledge
# Get current HEAD SHA
HEAD_SHA=$(git rev-parse HEAD)
# Get merge base with origin/main (fallback to HEAD if not available)
MERGE_BASE_SHA=$(git merge-base HEAD origin/main 2>/dev/null || git rev-parse HEAD)
Store as HEAD_SHA and MERGE_BASE_SHA for frontmatter.
Purpose: Create a fast, lightweight index immediately so other skills can load it without waiting for full analysis.
oat index init --head-sha "$HEAD_SHA" --merge-base-sha "$MERGE_BASE_SHA"
This script:
.oat/repo/knowledge/project-index.md with thin metadataWhy thin first:
Test if the runtime allows Write tool in background agents.
# Create test directory
mkdir -p .oat/repo/knowledge/.preflight
Spawn a test agent to check Write permission (must use the same subagent type as the mapper agents):
subagent_type: "oat-codebase-mapper"
model: "haiku"
run_in_background: true
description: "Test write permissions"
prompt: |
Test if Write tool works in background mode.
Try to write a test file:
- File: .oat/repo/knowledge/.preflight/test.txt
- Content: "test"
If Write succeeds, return: "WRITE_OK"
If Write fails or is blocked, return: "WRITE_BLOCKED"
Check result:
if [ -f .oat/repo/knowledge/.preflight/test.txt ]; then
echo "✓ Write works in background agents - using direct-write approach"
WRITE_MODE="direct"
rm -rf .oat/repo/knowledge/.preflight
else
echo "⚠ Write blocked in background agents - using read-only fallback"
WRITE_MODE="readonly"
fi
Store $WRITE_MODE for use in Step 5.
Use the approach determined by Step 4b pre-flight check.
If $WRITE_MODE="direct" (Write works in background):
If $WRITE_MODE="readonly" (Write blocked in background):
Use Task tool with subagent_type="oat-codebase-mapper" and run_in_background=true.
Approach:
.oat/repo/knowledge/ using the Write toolAgent 1: Tech Focus
subagent_type: "oat-codebase-mapper"
model: "haiku"
run_in_background: true
description: "Map codebase tech stack"
Prompt:
Focus: tech
Analyze this codebase for technology stack and external integrations.
Produce these documents:
- stack.md - Languages, runtime, frameworks, dependencies, configuration
- integrations.md - External APIs, databases, auth providers, webhooks
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
Include frontmatter:
---
oat_generated: true
oat_generated_at: {today}
oat_source_head_sha: {HEAD_SHA}
oat_source_main_merge_base_sha: {MERGE_BASE_SHA}
oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
---
Instructions:
- Write documents directly to `.oat/repo/knowledge/` using the Write tool
- Follow the oat-codebase-mapper agent instructions for exploration and writing
- Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
- Include frontmatter with both SHA fields in every document
- Return only a brief confirmation when done (do NOT return document contents)
Agent 2: Architecture Focus
subagent_type: "oat-codebase-mapper"
model: "haiku"
run_in_background: true
description: "Map codebase architecture"
Prompt:
Focus: arch
Analyze this codebase architecture and directory structure.
Produce these documents:
- architecture.md - Pattern, layers, data flow, abstractions, entry points
- structure.md - Directory layout, key locations, naming conventions
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
Include frontmatter:
---
oat_generated: true
oat_generated_at: {today}
oat_source_head_sha: {HEAD_SHA}
oat_source_main_merge_base_sha: {MERGE_BASE_SHA}
oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
---
Instructions:
- Write documents directly to `.oat/repo/knowledge/` using the Write tool
- Follow the oat-codebase-mapper agent instructions for exploration and writing
- Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
- Include frontmatter with both SHA fields in every document
- Return only a brief confirmation when done (do NOT return document contents)
Agent 3: Quality Focus
subagent_type: "oat-codebase-mapper"
model: "haiku"
run_in_background: true
description: "Map codebase conventions"
Prompt:
Focus: quality
Analyze this codebase for coding conventions and testing patterns.
Produce these documents:
- conventions.md - Code style, naming, patterns, error handling
- testing.md - Framework, structure, mocking, coverage
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
Include frontmatter:
---
oat_generated: true
oat_generated_at: {today}
oat_source_head_sha: {HEAD_SHA}
oat_source_main_merge_base_sha: {MERGE_BASE_SHA}
oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
---
Instructions:
- Write documents directly to `.oat/repo/knowledge/` using the Write tool
- Follow the oat-codebase-mapper agent instructions for exploration and writing
- Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
- Include frontmatter with both SHA fields in every document
- Return only a brief confirmation when done (do NOT return document contents)
Agent 4: Concerns Focus
subagent_type: "oat-codebase-mapper"
model: "haiku"
run_in_background: true
description: "Map codebase concerns"
Prompt:
Focus: concerns
Analyze this codebase for technical debt, known issues, and areas of concern.
Produce this document:
- concerns.md - Tech debt, bugs, security, performance, fragile areas
Use template from .agents/skills/oat-repo-knowledge-index/references/templates/
Include frontmatter:
---
oat_generated: true
oat_generated_at: {today}
oat_source_head_sha: {HEAD_SHA}
oat_source_main_merge_base_sha: {MERGE_BASE_SHA}
oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
---
Instructions:
- Write documents directly to `.oat/repo/knowledge/` using the Write tool
- Follow the oat-codebase-mapper agent instructions for exploration and writing
- Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
- Include frontmatter with both SHA fields in every document
- Return only a brief confirmation when done (do NOT return document contents)
Use Task tool with subagent_type="Explore" and run_in_background=true.
Approach:
Agent 1: Tech Focus
subagent_type: "Explore"
model: "haiku"
run_in_background: true
description: "Map codebase tech stack"
Prompt:
Focus: tech
Analyze this codebase for technology stack and external integrations.
Produce these documents:
- stack.md - Languages, runtime, frameworks, dependencies, configuration
- integrations.md - External APIs, databases, auth providers, webhooks
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
Include frontmatter:
---
oat_generated: true
oat_generated_at: {today}
oat_source_head_sha: {HEAD_SHA}
oat_source_main_merge_base_sha: {MERGE_BASE_SHA}
oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
---
Constraints:
- Do NOT use Write or Bash tools.
- Return the complete markdown contents in your final response.
- Format as:
--- stack.md ---
```markdown
<content here>
--- integrations.md ---
<content here>
**Agent 2: Architecture Focus**
subagent_type: "Explore" model: "haiku" run_in_background: true description: "Map codebase architecture"
Prompt: Focus: arch
Analyze this codebase architecture and directory structure.
Produce these documents:
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
oat_generated: true oat_generated_at: {today} oat_source_head_sha: {HEAD_SHA} oat_source_main_merge_base_sha: {MERGE_BASE_SHA} oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
Constraints:
--- architecture.md ---
<content here>
--- structure.md ---
<content here>
**Agent 3: Quality Focus**
subagent_type: "Explore" model: "haiku" run_in_background: true description: "Map codebase conventions"
Prompt: Focus: quality
Analyze this codebase for coding conventions and testing patterns.
Produce these documents:
Use templates from .agents/skills/oat-repo-knowledge-index/references/templates/
oat_generated: true oat_generated_at: {today} oat_source_head_sha: {HEAD_SHA} oat_source_main_merge_base_sha: {MERGE_BASE_SHA} oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
Constraints:
--- conventions.md ---
<content here>
--- testing.md ---
<content here>
**Agent 4: Concerns Focus**
subagent_type: "Explore" model: "haiku" run_in_background: true description: "Map codebase concerns"
Prompt: Focus: concerns
Analyze this codebase for technical debt, known issues, and areas of concern.
Produce this document:
Use template from .agents/skills/oat-repo-knowledge-index/references/templates/
oat_generated: true oat_generated_at: {today} oat_source_head_sha: {HEAD_SHA} oat_source_main_merge_base_sha: {MERGE_BASE_SHA} oat_warning: "GENERATED FILE - Do not edit manually. Regenerate with oat-repo-knowledge-index"
Constraints:
--- concerns.md ---
<content here>
---
### Step 6: Wait for Agent Completion
**If using Step 5a (direct write):**
- Wait for all 4 mapper agents to complete
- Each agent writes documents directly to `.oat/repo/knowledge/` and returns a brief confirmation
- Expected confirmations should indicate which documents were written
- Proceed to Step 7
**If using Step 5b (read-only):**
- Wait for all 4 mapper agents to complete
- Each agent returns markdown content in their response
- Proceed to Step 6b to extract and write files
### Step 6b: Extract and Write Files (Read-Only Mode Only)
If using read-only mode, extract markdown from agent outputs and write to files.
Use Python to extract markdown blocks:
```python
import json
import re
agents = [
{'id': 'AGENT_ID_1', 'files': ['stack.md', 'integrations.md']},
{'id': 'AGENT_ID_2', 'files': ['architecture.md', 'structure.md']},
{'id': 'AGENT_ID_3', 'files': ['conventions.md', 'testing.md']},
{'id': 'AGENT_ID_4', 'files': ['concerns.md']}
]
for agent in agents:
output_path = f"/private/tmp/claude-502/-Users-thomas-stang-Code-open-agent-toolkit/tasks/{agent['id']}.output"
with open(output_path, 'r') as f:
lines = f.readlines()
# Find the last JSON message with agent response
for line in reversed(lines):
if line.strip().startswith('{') and '"message"' in line:
data = json.loads(line)
if 'message' in data and 'content' in data['message']:
content = data['message']['content']
if isinstance(content, list) and len(content) > 0:
text = content[0].get('text', '')
# Extract markdown blocks - handle both formats
# Standard: --- filename.md ---
pattern = r'---\s+(\w+\.md)\s+---\s*\n\s*```markdown\n(.*?)\n```'
matches = re.findall(pattern, text, re.DOTALL)
# Alternative: ## filename.md (fallback)
if not matches:
alt_pattern = r'##\s+(\w+\.md)\s*\n\s*```markdown\n(.*?)\n```'
matches = re.findall(alt_pattern, text, re.DOTALL)
for filename, markdown in matches:
with open(f'.oat/repo/knowledge/{filename}', 'w') as out:
out.write(markdown)
print(f"✓ Wrote {filename}")
break
This extracts markdown and writes all 7 knowledge files.
ls -la .oat/repo/knowledge/
wc -l .oat/repo/knowledge/*.md
Checklist:
Now that all 7 detailed knowledge files exist, enrich the thin project-index.md with full details.
Read all 7 knowledge files to extract key information:
stack.md - Technologies, runtime, key dependenciesarchitecture.md - Overall pattern, key abstractionsstructure.md - Directory layout, file organizationintegrations.md - External services, APIstesting.md - Test framework, approachconventions.md - Code style, patternsconcerns.md - Technical debt, issuesEnrichment approach:
Read existing .oat/repo/knowledge/project-index.md (thin version from Step 4).
Replace placeholder sections with full details:
Update frontmatter:
oat_index_type: thin → oat_index_type: fullUpdate links at bottom to show files are available (not "pending"):
**Generated Knowledge Base Files:**
- [stack.md](stack.md) - Technologies and dependencies
- [architecture.md](architecture.md) - System design and patterns
- [structure.md](structure.md) - Directory layout
- [integrations.md](integrations.md) - External services
- [testing.md](testing.md) - Test structure and practices
- [conventions.md](conventions.md) - Code style and patterns
- [concerns.md](concerns.md) - Technical debt and issues
cat .oat/repo/knowledge/project-index.md | head -50
Expected: Complete overview with frontmatter and links
git add .oat/repo/knowledge/
git commit -m "docs: generate knowledge base
- project-index.md - High-level codebase overview
- stack.md - Technologies and dependencies
- architecture.md - System design and patterns
- structure.md - Directory layout
- conventions.md - Code style and patterns
- testing.md - Test structure and practices
- integrations.md - External services and APIs
- concerns.md - Technical debt and issues
Generated from commit: {MERGE_BASE_SHA}"
Record the knowledge index run in the shared tracking manifest:
ROOT_TARGET=$(bash .oat/scripts/resolve-tracking.sh root)
ROOT_HASH=$(echo "$ROOT_TARGET" | jq -r '.commitHash')
ROOT_BRANCH=$(echo "$ROOT_TARGET" | jq -r '.baseBranch')
bash .oat/scripts/resolve-tracking.sh \
write knowledgeIndex "$ROOT_HASH" "$ROOT_BRANCH" full \
--artifact-path ".oat/repo/knowledge/"
This enables delta mode for future runs — other OAT operations can check when the knowledge index was last generated.
Knowledge base generated in .oat/repo/knowledge/
Files created:
- project-index.md ({N} lines) - High-level overview
- stack.md ({N} lines) - Technologies and dependencies
- architecture.md ({N} lines) - System design and patterns
- structure.md ({N} lines) - Directory layout
- conventions.md ({N} lines) - Code style and patterns
- testing.md ({N} lines) - Test structure and practices
- integrations.md ({N} lines) - External services and APIs
- concerns.md ({N} lines) - Technical debt and issues
---
Next: Start a project with oat-project-new or explore knowledge files
After knowledge base generation, regenerate the repo state dashboard:
oat state refresh
This ensures the dashboard reflects fresh knowledge status immediately.
documentation
Use when OAT implementation changes and repository reference docs must be synchronized. Updates .oat/repo/reference to match current behavior.
business
Merge multiple analysis artifacts into a single coherent report with provenance tracking. Reads existing artifacts from /deep-research, /analyze, and /compare.
testing
Use when the user questions or suspects an agent claim is wrong. Adversarially gathers evidence to verify or refute the claim using the best sources available in the current environment.
tools
Use when prioritizing backlog work or evaluating a roadmap. Produces value-effort ratings, dependency mapping, and execution recommendations.