In VS Code, cody is not understanding my codebase

I’ve been trying multiple ways to make Cody understand my large and complex codebase, but I keep running into issues. Here’s what I tried:

  1. Using @whole_repo and similar prompts:
    When I ask Cody to understand the entire codebase using @whole_repo, it often asks me to run commands like ls -la or other directory listings. These outputs are quite large, so I redirect them to a file and reference that file in the prompt. However, Cody doesn’t seem to comprehend the structure or content of the codebase even after this.

  2. Preloading context by explaining the structure:
    I’ve also tried prompting Cody with something like:
    “Please go through the codebase first so I can ask specific questions later.”
    But when I follow up with a question, Cody responds with messages like:
    • “I don’t have access to that specific folder or file.”
    • “Please include the file using @.”

The problem is — despite my efforts, Cody still doesn’t seem to grasp the codebase context. This makes it very difficult to get meaningful help for complex, interconnected parts of the system.

Questions:
• Is there a reliable and effective way to get Cody to understand a large, multi-module codebase?
• Are there known limitations with Cody’s ability to handle large repositories?
• If there are size/context limits, what’s the best practice for working within those limits?

Given that Cody is promoted as a tool that excels in navigating large codebases, I’m trying to understand if I’m missing something in how to use it effectively — or if there are hard limitations I should be aware of.

Hey @swapnil66

Thank you for reporting the issue.
First and foremost, Cody has a hard limit in regards to input tokens. They are, for the most models, constraint to 45k tokens. Within this limitations there are a lot use cases, which can be processed successfully. You can read more here: Cody Input and Output Token Limits - Sourcegraph docs

Based on your description, you are using the Agentic Chat model and have difficulties to find a way for Cody understand and comprehend your codebase.
Which works for me with the Agent Chat model in a mid-size till large codebase is to create a kind of rule document, where I include several rules in it for specific scenarios as a Markdown .md file

To understand the project structure, I use the git ls-tree -r --name-only HEAD command in that rule file with the following prompt:

- **Project Structure:** Use `git ls-tree -r --name-only HEAD` to inspect the project structure

Then in the chat, I reference this rule document without using the @whole_repo item and let Cody comprehend the project structure. It can mostly derive what purpose a folder have. The advantage of this shell command is, that it follows the .gitignore file and only shows the up-to-date worktree. In follow-up messages, I include the files of a specific folder if I’m interested of a feature or module in general (depending on the size of the file contents).

Here and then, it is advisable to let Cody summarize what it knows so far for later use as reference in future sessions.

Important in all those steps is, that your project is initialized as a git repository and you made a first commit including all files from your project since Cody uses internally git commands for fetching context and in local scenarios indexing the whole repo is beneficial.

You can manually trigger the indexing by open the command palette with CTRL + SHIFT + P and searching for “Cody: Update search index…”. This triggers the local indexing for Codys’ symbol finder code search module which is needed especially if you include the @whole-repo item. After every commit, the automatic indexing update triggers.

I hope that helps and if you have additional questions, then I’m here.

Can you help me step by step process for VS code and Jetbrains differently separate step because my code base is big and complex.

FYI: My all codebase is git related only.

I have not received any reply on above query yet

Hey @swapnil66

Sorry for not replying in time. We have Easter weekend and I had a day off.

I already replied to you here: In VS Code, cody is not understanding my codebase - #2 by PriNova with an explanation on how to use Cody understand a code base.

If you have further question, you can Cody ask itself. :wink:

But the issue is even referring file like above cody_rules.md its not able to access/list/run commands and giving error attached:

If you are receiving error, then it would be very helpful to provide the logs for further inspection.
If you want Cody to have more context, you need to provide it directly in the chat with the @-mention menu or use specific symbol names in the prompt.

What log and how I get that log in VS code editor, can you please re-read my last message because in screenshot I am not getting error but what you told after trying that even its not understanding my codebase.

I referred to this post statement from you.

In VS Code, if you press CTRL + ShIFT + U, the output pane opens and you can switch to “Cody by Sourcegraph” for Cody logs.

The CLI command I gave you is meant to be used with the Agentic Chat model. You need to configure what shell commands are allowed in the settings.json file so that it can execute them or Cody will not do that:

"cody.agentic.context": {
        "shell": {
            "allow": [
                "*"
            ],
            "block": []
        }
    },

Thanks for quick reply here is my settings.json

Here is the error I am getting on log:



█ telemetry-v2 recordEvent: cody.extension/savedLogin:
█ auth Authenticating to https://sourcegraph.com/...
█ ModelsService User model preferences changed: {"defaults":{"chat":"anthropic::2023-06-01::claude-3.5-sonnet","edit":"anthropic::2023-06-01::claude-3.5-sonnet","autocomplete":"fireworks::v1::deepseek-coder-v2-lite-base"},"selected":{"chat":"sourcegraph::2023-06-01::deep-cody"}}
█ ChatsController:constructor init
█ auth Authentication succeed to endpoint https://sourcegraph.com/
█ telemetry-v2 recordEvent: cody.auth/connected:
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ ClientConfigSingleton refreshing configuration
█ AutoEdits:Constructor Constructing AutoEditsProvider
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}
█ ModelsService new models API enabled
█ auth Authenticating to https://sourcegraph.com/...
█ ChatController updateClientConfig:
█ ChatController updateViewConfig:
█ ChatController updateViewConfig:
█ auth Authentication succeed to endpoint https://sourcegraph.com/
█ ModelsService ModelsData changed: 24 primary models
█ UpstreamHealth Ping took 467ms (Gateway: 388ms):
█ telemetry-v2 recordEvent: cody.editChatButton/clicked:
█ ChatController handleUserMessageSubmission: traceId: 71da2cc8d29b47113633072a72bb592c
█ telemetry-v2 recordEvent: cody.humanMessageEditor/submit:
█ telemetry-v2 recordEvent: cody.chat-question/submitted:
█ Completions:onComplete duration:"1072ms" stopReason:"undefined" outputChannelId:"25e7a855-968f-47fb-985f-0ae9f138a36d":
█ telemetry-v2 recordEvent: cody.chat.customTitle/generated:
█ Completions:onComplete duration:"1605ms" stopReason:"undefined" outputChannelId:"93d65d72-443e-4aee-adde-11ace44f933f":
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (start)
█ SymfRunner reindexIfStale: /Users/SWAP/Documents/local/localtools
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner statIndex: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools status /Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner running symf: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools query --scopes /Users/SWAP/Documents/local/localtools --fmt json --boosted-keywords "Are you able to understand all codebase" Are you able to understand all codebase
█ ClientConfigSingleton refreshing configuration
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (error): EvalError: symf failed: Error: Command failed: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools query --scopes /Users/SWAP/Documents/local/localtools --fmt json --boosted-keywords "Are you able to understand all codebase" Are you able to understand all codebase
...Scopes: /Users/SWAP/Documents/local/localtools
...Num results limit: 15

█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (end)
█ SymfRunner symf status error: RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ telemetry-v2 recordEvent: cody.chat-question/executed:
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}
█ Completions:onComplete duration:"4243ms" stopReason:"undefined" outputChannelId:"7b25199b-474e-495a-a24a-c81fc8336ab3":
█ telemetry-v2 recordEvent: cody.chatResponse/hasCode:
█ [CodyTraceExporterWeb] Removed span from queue: 68c7598bfda3d425 
█ [CodyTraceExporterWeb] Removed span from queue: bcc6bcaf82b0c63a 
█ [CodyTraceExporterWeb] Removed span from queue: 474ff6fc71fdbcb4 
█ [CodyTraceExporterWeb] Exporting spans {"count":3,"rootSpans":1,"renderSpans":1} 
█ TraceSender Trace data sent successfully
█ ClientConfigSingleton refreshing configuration
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}
█ telemetry-v2 recordEvent: cody.modelSelector/open:
█ ModelsService Setting selected chat model to sourcegraph::2023-06-01::deep-cody
█ telemetry-v2 recordEvent: cody.contextCell/opened:
█ telemetry-v2 recordEvent: cody.at-mention/selected:
█ ChatController handleUserMessageSubmission: traceId: 2bd670836378d824b1d149cb2fc07833
█ telemetry-v2 recordEvent: cody.humanMessageEditor/submit:
█ telemetry-v2 recordEvent: cody.chat-question/submitted:
█ Completions:onComplete duration:"966ms" stopReason:"undefined" outputChannelId:"71480658-701e-4802-b0b1-26544264f796":
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (start)
█ SymfRunner reindexIfStale: /Users/SWAP/Documents/local/localtools
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner statIndex: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools status /Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner running symf: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools query --scopes /Users/SWAP/Documents/local/localtools --fmt json --boosted-keywords "" 
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (end)
█ telemetry-v2 recordEvent: cody.chat-question/executed:
█ SymfRunner symf status error: RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ ClientConfigSingleton refreshing configuration
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}
█ Completions:onComplete duration:"5201ms" stopReason:"undefined" outputChannelId:"cf9adbf3-d8f1-4124-b143-aa151456f3f5":
█ telemetry-v2 recordEvent: cody.chatResponse/noCode:
█ [CodyTraceExporterWeb] Removed span from queue: 48f3f19c7293f34d 
█ [CodyTraceExporterWeb] Removed span from queue: 8be87db9cbd62d89 
█ [CodyTraceExporterWeb] Removed span from queue: c66a4027f8d25837 
█ [CodyTraceExporterWeb] Exporting spans {"count":3,"rootSpans":1,"renderSpans":1} 
█ TraceSender Trace data sent successfully
█ ClientConfigSingleton refreshing configuration
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}
█ telemetry-v2 recordEvent: cody.editChatButton/clicked:
█ ChatController handleUserMessageSubmission: traceId: f5bb4b97100acaa1ffade034f9f0202c
█ telemetry-v2 recordEvent: cody.humanMessageEditor/submit:
█ telemetry-v2 recordEvent: cody.chat-question/submitted:
█ Completions:onComplete duration:"817ms" stopReason:"undefined" outputChannelId:"38e30112-4aaf-43f8-92aa-d1a775c2aedd":
█ Completions:onComplete duration:"899ms" stopReason:"undefined" outputChannelId:"049ac924-76af-434a-b37f-78418dd34aeb":
█ telemetry-v2 recordEvent: cody.chat.customTitle/generated:
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (start)
█ SymfRunner reindexIfStale: /Users/SWAP/Documents/local/localtools
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner statIndex: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools status /Users/SWAP/Documents/local/localtools
█ symf using downloaded symf "/Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos"
█ SymfRunner running symf: /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/symf-v0.0.16-aarch64-macos --index-root /Users/SWAP/Library/Application Support/Code/User/globalStorage/sourcegraph.cody-ai/symf/indexroot/Users/SWAP/Documents/local/localtools query --scopes /Users/SWAP/Documents/local/localtools --fmt json --boosted-keywords "Are you able to understand all codebase" Are you able to understand all codebase
█ ChatController resolveContext > symf /Users/SWAP/Documents/local/localtools (end)
█ telemetry-v2 recordEvent: cody.chat-question/executed:
█ SymfRunner symf status error: RangeError [ERR_CHILD_PROCESS_STDIO_MAXBUFFER]: stdout maxBuffer length exceeded
█ SymfRunner unsafeEnsureIndex: file:///Users/SWAP/Documents/local/localtools
█ Completions:onComplete duration:"7995ms" stopReason:"undefined" outputChannelId:"b6c6fc52-8e01-4323-ba94-0229c52df13e":
█ telemetry-v2 recordEvent: cody.chatResponse/hasCode:
█ ClientConfigSingleton refreshing configuration
█ ClientConfigSingleton refreshed: {"codyEnabled":true,"chatEnabled":true,"autoCompleteEnabled":true,"customCommandsEnabled":true,"attributionEnabled":false,"attribution":"none","smartContextWindowEnabled":true,"modelsAPIEnabled":false,"latestSupportedCompletionsStreamAPIVersion":9}

Just to let you know it was working earlier something recently has been changed in Agentic chat or I dont know what but earlier it used to work with “@folder - Lookup the folder structure of this codebase and explain what the purpose might be”

@swapnil66 Cody has no ‘@folder’ mention functionality as context. Are you on the latest release?

Yes and @folder means @current_directory

I didnt get reply yet, I think I need to switch some other options. It was working earlier.