Code search tools

Hello!

Has anyone tried to add a tool for the agent to search the codebase? Like Claude Code or Codex does. The idea is to improve support agent responses by letting it search the codebase and not only the product’s documentation.

Kind Regards

Hey @Serg_Sokhatskyi, while you wait for a response, here are some things that might help:

Suggested resources

Automatically matched to your question.

Docs:

Forum:

@liam - you’ve helped with similar issues before, can you take a look?

Automatically suggested by n8n’s community bot. It’s a pilot - please share feedback here.

"Hi Serg! I haven’t built or integrate this but i am facing similar challenge

@Serg_Sokhatskyi in n8n no, however, perhaps the github node could help

Hi Serg — yes, this can work well as an n8n tool, but I would avoid sending the whole repository to the agent or rebuilding an embedding index for every question.

A practical retrieval workflow would be:

  1. Accept { repo, commitSha, query }.
  2. Allow-list the repository and searchable paths.
  3. Run lexical search first — GitHub Code Search through an HTTP Request node, or rg in a small internal service for self-hosted setups.
  4. Fetch only the matching files plus roughly 20–40 surrounding lines.
  5. Return structured results with file path, line numbers, commit SHA, and snippet.
  6. Cache by commit SHA and invalidate/reindex from a GitHub push webhook.

For support agents, lexical search often beats embeddings because stack traces, function names, and config keys are exact strings. I would add semantic search only for conceptual questions, then use lexical search to verify the final evidence.

One security detail: never concatenate the agent’s query into a shell command. Pass it as an argument, allow-list flags and paths, and keep private repositories inside your own network.

In n8n, I’d expose the retrieval workflow as a Workflow Tool or a small MCP tool returning JSON. The tiny but important field is the commit SHA — otherwise the agent may confidently quote code that was correct yesterday. Repositories age surprisingly fast :sweat_smile:

Hi @Serg_Sokhatskyi Welcome!
The GitHub node has no code search operation, its File resource covers only Create, Delete, Edit, Get and List, so the search itself has to be an HTTP Request node against /search/code. That node picks up your existing GitHub credential under Authentication > Predefined Credential Type and connects straight to the Agent’s tool connector, so the whole tool is that one node. Send q as a query parameter and let the model write it:

{{ $fromAI('q', 'GitHub code search query, include repo:owner/name', 'string') }}

Budget for the endpoint’s limit of 10 authenticated requests per minute, which an agent running several searches per answer reaches quickly.

Hey @Serg_Sokhatskyi

I have used tool nodes like this and it has worked wonders!

most of the time you need to use http node for these actions. If you go to use this, make sure to replace all the placeholders in the nodes with the actual repo name and owners

But there is a new way to do this nativly!

Our new agents feature can execute commands in a sandbox. So it can nativly just start a temporary sandbox, clone a git repo, and look through it with native bash commands just like claude code or any coding agent would.

Here is a screenshot of me asking a random agent to look through a repo

It has no GH tool access, it is doing it all in a daytona sandbox natively (i didnt need to set it up).
Here is the single prompt i input then it went through and did it

using a sandbox can you clone the n8n repo and show me a funny code comment from the new agents feature

see more here:

and here