@@ -66,27 +66,53 @@ async def codebase_search(
6666 cross-cutting questions.
6767
6868 include_content: Whether to include full file content in results (default: false).
69- Agents should proactively request content when needed by setting this to true.
70- Note: File content may be outdated compared to current local state.
7169
72- Returns :
73- Search results as JSON including source info, file paths, line numbers, and code snippets.
74-
75- Examples :
76- 1. Natural-language question (recommended):
77- codebase_search(query="What is the auth flow?", data_sources=["repo123"])
70+ IMPORTANT - When to include content :
71+ - For EXTERNAL repositories (not in your current working directory):
72+ SET TO TRUE - you don't have file access, so you need the content.
73+ - For CURRENT repository (the one you're working in) :
74+ SET TO FALSE - you already have file access via Read tool, so just get
75+ file paths and read them directly for the latest content.
7876
79- 2. Intent query:
80- codebase_search(query="Where is user registration logic?", data_sources=["repo123"])
77+ How to identify current vs external repositories:
78+ - Compare repository URLs from get_data_sources with your current git repo URL
79+ - Current repo: Use include_content=false, then use Read tool on result paths
80+ - External repos: Use include_content=true to get the content directly
8181
82- 3. Workspace-wide question:
83- codebase_search(query="How do microservices talk to the billing API?", data_sources=["backend-team"])
82+ Note: Indexed content may be from a different branch than your local state.
8483
85- 4. Mixed query with a known identifier :
86- codebase_search(query="Where do we validate JWTs (AuthService)?", data_sources=["repo123"])
84+ Returns :
85+ Search results as JSON including source info, file paths, line numbers, and code snippets.
8786
88- 5. Concise results without full file contents:
89- codebase_search(query="Where is password reset handled?", data_sources=["repo123"], include_content=false)
87+ Examples:
88+ 1. Search CURRENT repository (you have file access):
89+ codebase_search(
90+ query="Where is user authentication handled?",
91+ data_sources=["my-current-repo"],
92+ include_content=false # Get paths only, then use Read tool
93+ )
94+ # Then read the files: Read(file_path="/path/from/results")
95+
96+ 2. Search EXTERNAL repository (no file access):
97+ codebase_search(
98+ query="How does the payment service validate cards?",
99+ data_sources=["external-payments-repo"],
100+ include_content=true # Need content, can't read files directly
101+ )
102+
103+ 3. Workspace-wide question across external repos:
104+ codebase_search(
105+ query="How do microservices talk to the billing API?",
106+ data_sources=["backend-team"],
107+ include_content=true # External workspace, include content
108+ )
109+
110+ 4. Mixed query with known identifier:
111+ codebase_search(
112+ query="Where do we validate JWTs (AuthService)?",
113+ data_sources=["repo123"],
114+ include_content=false # Current repo, read files separately
115+ )
90116
91117 Note:
92118 - At least one data source name must be provided
0 commit comments