Code Search & Generation

By linking Glean to your code repositories like GitHub or GitLab, you can boost Glean Assistant's capabilities to include code search and code generation features, thereby improving the productivity and efficiency of your software engineers.
Unlike other generative AI or co-pilot code tools on the market, Glean is able to understand and incorporate context from code, design docs, technical documentation, tickets, PRs, issues, discussion threads, and more, to help your engineers progress their work.
Overview
When integrating Glean with your organizations code repositories, Glean can bring the context of this data into the existing enterprise knowledge graph to provide contextually relevant search results for your software engineers, and code suggestions that conform to organizational standards across all of your applications.
Capabilities
- Code Search: Empowers users to perform advanced searches across all current and historical code content, including pull requests and commits.
- Code Generation: Automatically generates code snippets that conform to organizational standards, aiding in feature development and bug fixes.
Use Cases
- Rapid Error Resolution: Quickly identify and resolve bugs or errors by accessing a comprehensive database of code snippets, documentation, and previously encountered solutions.
- Automated Code Generation: Enhance productivity by automatically generating code snippets for both routine tasks and new feature development.
- Organizational Knowledge Sharing: Facilitate continuous learning and effective communication of coding practices and standards across the organization.
- Streamlined Onboarding: Accelerate the integration of new engineers by providing structured learning resources and insights into the codebase and architecture.
Examples
Code Context
- How is
<system>implemented at our company? - How do I debug/solve
<error>? - Help me write code to do
Xin<language>. - Where is the code file that does
X? - Help me write unit tests for
<file>.
Process & Customer Context
- What is the status of this week's backend release?
- Who can I ask about
<system or feature>? - How do I set up my dev environment?
- Which customers are using
<feature>? - What customers have raised issues this week?
Scenarios
Scenario 1: Adding to existing code
Situation
An engineer wants to create a new evalset. There are other evalsets that have been added before, but the code spans several files across different languages. The engineer needs to reuse past code as much as possible instead of starting from scratch, but doesn't know where to start.
Glean Assistant Queries
- How do I add a new search evalset?
- How to create a new autocomplete evalset for history suggestions?
Result
Glean Assistant will find the relevant files where the changes need to be made, along with explanations on what those changes are. It will then help write code snippets that can either be copy/pasted or adapted further by the engineer.

Scenario 2: Debugging errors
Situation
An engineer is on call this week and has come across an issue where there is a panic occurring in the product in certain situations.
Glean Assistant Queries
- Help me debug
<full panic error>. - Can you review the code and help me fix the panic?
- Give me a list of reviewers I can add for this code change.
- Can you also create a PR description?
Result
Glean Assistant helps the user locate the cause of the panic by analyzing the stack trace. On further prompts by the user, it suggests a fix for the panic, and helps them craft a PR to implement the fix.


Scenario 3: Status of a feature
Situation
An engineer wants to know the status of a feature, whether it has already been implemented, and what customers have asked for it. If the feature already exists, they need to know how it can be enabled. This information is present in code files and in conversations regarding the feature, but would be time-consuming to find manually.
Glean Assistant Queries
- Is
<feature>enabled? - What customers have asked for this feature?
Result
Glean Assistant looks through recent design docs, code changes, and Jira tickets to find information on the specified feature. It is also able to find the exact flag that needs to be flipped to enable the feature for certain customer environments.
When queried, Glean Assistant responds with the customers that requested the feature as they were tagged on the relevant Jira ticket addressing the feature.

Scenario 4: Impact of a code change
Situation
An engineer is trying to debug an error, and to do that they need to understand any recent changes that might affect the component they’re debugging.
Glean Assistant Queries
- What recent changes could have caused errors in runtime configs?
Result
Glean Assistant looks through recent code changes, tickets, and discussions; reads any relevant code, understands what recent changes have been made, and summarizes the findings to the engineer.

Scenario 5: Providing a starting point
Situation
An engineer is starting to implement a piece of code, but doesn’t know where to begin. The implementation requires them to potentially touch multiple files across the stack, fragmented in different directories.
Glean Assistant Queries
- Where can I add a new endpoint for QE?
Result
Glean Assistant is able to generalize from similar changes in the past and able to answer with the files that need to be touched and the code changes that need to be made. It is able to understand any company-specific acronyms used (i.e. "QE") as it is aware of the specifics of the language used throughout the organization.

FAQ
Which datasources are supported?
Code repositories in GitHub and GitLab are currently supported.
What code will Glean Assistant have access to?
Glean Assistant will search through code in:
- Code contents of Pull Request and Merge Request differentials.
-
All files in the latest commit and Main / Master branch with the following extensions:
- asm
- bas
- cmd
- c
- h
- cs
- csx
- cpp
- c++
- cc
- h++
- hh
- hpp
- cmake
- cob
- cbl
- css
- clj
- cljs
- dockerfile
- go
- graphql
- gql
- graphqls
- html
- hs
- ini
- cfg
- cnf
- java
- js
- jl
- ipynb
- kt
- kts
- lua
- ml
- php
- pas
- pl
- perl
- proto
- py
- py3
- r
- rd
- rb
- rs
- scss
- sql
- mysql
- scala
- sc
- sh
- bash
- swift
- tf
- ts
- tsx
- vhdl
- vhd
- vlg
- verilog
Is code search supported in search results?
No. Indexed code is only used for Glean Assistant responses today. In Glean Search, we will match on PR descriptions and file names, but not on code contents directly. This is to reduce noise in search results.
What permissions are required?
As this functionality comes from the data sourced via the Glean GitHub and GitLab connectors, the permissions are exactly the same as those connectors.
How is my data secured?
Code snippets that are indexed by Glean become part of the Glean Knowledge Graph created for your organization. This means that only the users that have access to the code in the first place are able to access it via Glean Assistant.
The code snippets themselves are secured as per all other content that Glean indexes and adhere to the same privacy guarantees.