- Read context from earlier steps (tickets, logs, stack traces, code search results).
- Plan a targeted change.
- Open a draft pull request in the right repository and branch.
- Return the pull request URL and a summary to later steps in the workflow.
Usage examples
Jira bug‑fix agent
Use Code Writer to automatically propose a fix when a bug ticket arrives.Example flow
- Trigger: Jira issue created or updated.
-
Steps:
- Read the Jira issue summary and description.
- Optional: use code search to find relevant files.
- Code Writer: generate a fix and open a draft pull request.
- Respond with the pull request URL in Assistant or post it back to Jira or Slack.
What Code Writer does here
- Uses the issue text and any attached context from earlier steps as instructions.
- Targets the configured repository and branch.
- Returns the draft pull request link and a short summary to downstream steps.
Escalation channel helper
Use Code Writer in an incident or escalation channel workflow to propose quick fixes.Example flow
- Trigger: message posted in a specific Slack escalation channel.
-
Steps:
- Read the message and any attached logs or stack traces.
- Optional: run code search based on the error.
- Code Writer: propose a fix as a draft pull request.
- Post the pull request URL and summary in the channel for engineers to review.
What Code Writer does here
- Uses the message text and any attached logs or stack traces as instructions.
- Targets the configured repository and branch.
- Returns the draft pull request link and a short summary to downstream steps.
Configuration
Prerequisites
- The Code Writer feature is enabled and configured by an admin.
- A GitHub data source is connected and indexing the repositories where the agent will propose changes.
- The Glean GitHub App is installed in your GitHub organization, with read/write access to the relevant repositories.
- The Code Writer action is configured in the Admin console.
- Access to Code Writer granted to you or your group in the action pack settings.
- For agent users, GitHub OAuth must be completed on first use so Code Writer can run on their behalf.
- Open Agent Builder and select the agent you want to edit.
- Choose the step after you have collected enough context (for example, after reading a Jira issue, logs, or running code search).
- Click Add step.
- In Select step, go to Actions → By datasource → GitHub / Code generation and select Code Writer.
Configure step inputs
In the Code Writer step, configure:-
Instructions
Describe what you want Code Writer to do, in plain language. For example:
- “Propose a fix that resolves the bug described in the
issue_descriptionfield.” - “Update the function documented in
stack_traceso it handles null inputs gracefully.”
- “Propose a fix that resolves the bug described in the
-
Target repository and branch
- Choose or map the GitHub repository where Code Writer should open a pull request.
- Select or map the branch to base the work on (for example a staging branch).
-
Additional context (optional)
Depending on your design, you can pass:
- Ticket titles and descriptions.
- Stack traces or logs.
- File paths, function names, or code snippets from Read or code search steps.
- User‑provided fields, such as a “change description”.
Outputs available to later steps
After Code Writer runs successfully, it returns:- Pull request URL: link to the draft pull request in GitHub.
- Summary: a short description of what changed (if configured).
- Status information: whether the operation succeeded or failed.
- Respond to the user in Assistant with a link and explanation.
- Post the pull request URL back to Jira or Slack.
- Trigger follow‑up checks or notifications.
Best practices
- Keep changes small Use instructions that focus on a fix or a narrow update, rather than broad refactors.
- Insert human‑in‑the‑loop steps Combine Code Writer with a “wait for user input” or review step where appropriate.
- Use upstream context Feed Code Writer with structured context from earlier steps (tickets, logs, code search results) rather than pasting long free‑form prompts into the step configuration.
-
Handle errors gracefully
Plan how your agent should respond when:
- The pull request cannot be created.
- The user does not have permission on the target repository.