Repository analysis is the foundational process that examines a codebase from multiple perspectives, providing context for AI-driven feature development.
When a user runs shep in a repository, the system can perform analysis before feature work begins. This analysis:
The analysis is implemented as a LangGraph graph in packages/core/src/infrastructure/services/agents/analyze-repo/. It uses the AnalyzeRepositoryState annotation with a single analyze node that delegates to an IAgentExecutor.
// packages/core/src/infrastructure/services/agents/analyze-repo/analyze-repository-graph.ts
export const AnalyzeRepositoryState = Annotation.Root({
repositoryPath: Annotation<string>,
analysisMarkdown: Annotation<string>,
error: Annotation<string | undefined>,
});
The analysis node builds a prompt from the repository path and delegates execution to the injected IAgentExecutor (Claude Code, Gemini CLI, etc.).
The AI agent examines the repository across multiple dimensions:
Analysis output is persisted for instant access:
~/.shep/repos/<base64-encoded-repo-path>/
+-- data # SQLite database
+-- docs/ # Analysis documents
+-- architecture.md
+-- dependencies.md
+-- patterns.md
+-- conventions.md
+-- tech-stack.md
+-- documentation.md
+-- summary.json # Quick-access summary
Repository paths are base64-encoded for directory safety:
function encodeRepoPath(repoPath: string): string {
return Buffer.from(repoPath).toString('base64url');
}
1. User runs: shep (or analysis is triggered for a feature)
|
v
2. AnalyzeRepository LangGraph invoked
|
v
3. IAgentExecutor generates analysis document
|
v
4. Analysis markdown persisted to docs/
|
v
5. Analysis available for subsequent agent workflows
Analysis context is available to the FeatureAgent LangGraph during:
Update when:
Related docs: