Workflow: Understand a Codebase
December 29, 2025 · View on GitHub
You've cloned an unfamiliar repository. Here's how Claude uses narsil-mcp to help you understand it.
The Scenario
You're new to a project and need to understand:
- What the project does
- How it's organized
- Where key functionality lives
- How components connect
Example Conversation
Step 1: Get the big picture
You: "What is this project and how is it structured?"
Claude calls:
get_project_structure(repo: "myproject")
Result: Claude sees the directory tree:
myproject/
├── src/
│ ├── api/
│ │ ├── routes.py
│ │ ├── auth.py
│ │ └── handlers.py
│ ├── models/
│ │ ├── user.py
│ │ └── order.py
│ ├── services/
│ │ ├── payment.py
│ │ └── email.py
│ └── main.py
├── tests/
├── docs/
└── requirements.txt
Claude responds: "This is a Python web API with a typical layered architecture..."
Step 2: Find entry points
You: "Where does the application start? What are the main entry points?"
Claude calls:
find_symbols(repo: "myproject", symbol_type: "function", pattern: "main*")
search_code(query: "if __name__", repo: "myproject")
find_symbols(repo: "myproject", symbol_type: "function", pattern: "*route*")
Result: Claude finds:
main.py:15-def main()api/routes.py- Route definitions with@app.routedecorators
Claude responds: "The application starts in main.py which initializes the Flask app. API routes are defined in api/routes.py..."
Step 3: Understand a specific feature
You: "How does authentication work?"
Claude calls:
search_code(query: "authentication login token", repo: "myproject")
find_symbols(repo: "myproject", pattern: "*auth*")
get_file(repo: "myproject", path: "src/api/auth.py")
get_callers(repo: "myproject", function: "authenticate")
Result: Claude reads the auth module and traces how it's used.
Claude responds: "Authentication uses JWT tokens. The flow is:
- User calls
/loginwith credentials authenticate()inauth.py:42validates and returns a token- Protected routes use the
@require_authdecorator - Token is validated on each request by
verify_token()at line 78..."
Step 4: Map dependencies
You: "What external libraries does this use? Are there any dependency issues?"
Claude calls:
get_dependencies(repo: "myproject", path: "requirements.txt")
check_dependencies(repo: "myproject")
get_import_graph(repo: "myproject")
Result: Claude sees all dependencies and their relationships.
Claude responds: "The project uses Flask, SQLAlchemy, PyJWT, and Redis. I found one vulnerability in an older version of cryptography..."
Step 5: Trace data flow
You: "How does a request flow from the API to the database?"
Claude calls:
get_callers(repo: "myproject", function: "create_order", transitive: true)
get_callees(repo: "myproject", function: "create_order", transitive: true)
find_call_path(repo: "myproject", from: "handle_order", to: "db_session.commit")
Result: Claude traces the entire call chain.
Claude responds: "When a POST hits /orders:
routes.py:handle_order()validates input- Calls
services/order.py:create_order() - Which calls
models/order.py:Order.create() - Finally commits via SQLAlchemy's
db_session.commit()..."
Tools Used in This Workflow
| Tool | Purpose |
|---|---|
get_project_structure | See directory layout and file organization |
find_symbols | Find classes, functions, methods by name pattern |
search_code | Full-text search across the codebase |
get_file | Read specific source files |
get_dependencies | Analyze imports and requirements |
get_import_graph | Visualize module dependencies |
get_callers | Find what calls a function |
get_callees | Find what a function calls |
find_call_path | Trace path between two functions |
Tips
-
Start broad, then narrow: Begin with structure, then drill into specific features
-
Let Claude explore: Don't micromanage - ask questions and let Claude choose which tools to use
-
Use follow-up questions: "What else calls that function?" or "Show me the actual code"
-
Enable all features: Use
--git --call-graphflags for the richest understanding
Sample Prompts
"Give me an overview of this codebase"
"What are the main components and how do they interact?"
"Find all the API endpoints"
"How is data validated before reaching the database?"
"What's the relationship between User and Order models?"
"Show me the dependency graph for the auth module"
"Where is configuration loaded from?"
"What design patterns does this project use?"
Related Workflows
- Fix a Bug - Now that you understand the code, debug an issue
- Security Audit - Check for vulnerabilities
- Code Review - Review changes effectively