You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(workflows): improve prompts to use env vars directly (#342)
The prompts in the workflows are updated to directly embed environment
variables using `${{ env.VAR }}` syntax.
This makes the prompts clearer and avoids instructing the model to use
`echo` to retrieve values, simplifying the instructions.
This should also improve quality of response.
cc @anj-s
2. **Deepen Context with Tools**: Use `mcp__github__get_issue`, `mcp__github__get_pull_request_diff`, and `mcp__github__get_file_contents` to investigate the request thoroughly.
Copy file name to clipboardExpand all lines: .github/workflows/gemini-issue-fixer.yml
+2-5Lines changed: 2 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -102,17 +102,14 @@ jobs:
102
102
<issue>
103
103
<repository>${{ env.REPOSITORY }}</repository>
104
104
<number>${{ env.ISSUE_NUMBER }}</number>
105
-
<title>The title exists in the ISSUE_TITLE environment variable. Run `echo $ISSUE_TITLE` to fetch it.</title>
106
-
<body>The title exists in the ISSUE_BODY environment variable. Run `echo $ISSUE_BODY` to fetch it.</body>
105
+
<title>${{ env.ISSUE_TITLE }}</title>
106
+
<body>${{ env.ISSUE_BODY }}</body>
107
107
</issue>
108
108
</github_event>
109
109
</context>
110
110
<instructions>
111
111
<description>Follow these steps sequentially to resolve the issue.</description>
112
112
<steps>
113
-
<step id="0" name="Get Issue Title and Issue Body">
114
-
The issue's title and body are stored in the ISSUE_TITLE and ISSUE_BODY environment variables. Read them with `echo $ISSUE_TITLE` and `echo $ISSUE_BODY`.
115
-
</step>
116
113
<step id="1" name="Understand Project Standards">
117
114
The initial context provided to you includes a file tree. If you see a `GEMINI.md` or `CONTRIBUTING.md` file, use the GitHub MCP `get_file_contents` tool to read it first. This file may contain critical project-specific instructions, such as commands for building, testing, or linting.
- **Additional User Instructions**: ${{ env.ADDITIONAL_CONTEXT }}
144
144
- Use `mcp__github__get_pull_request` to get the title, body, and metadata about the pull request.
145
145
- Use `mcp__github__get_pull_request_files` to get the list of files that were added, removed, and changed in the pull request.
146
146
- Use `mcp__github__get_pull_request_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
Copy file name to clipboardExpand all lines: .github/workflows/gemini-scheduled-triage.yml
+24-20Lines changed: 24 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -143,33 +143,37 @@ jobs:
143
143
144
144
5. **Command Substitution**: When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
145
145
146
-
## Input Data Description
146
+
## Input Data
147
147
148
-
You will work with the following environment variables:
148
+
The following data is provided for your analysis:
149
149
150
-
- **`AVAILABLE_LABELS`**: Contains a single, comma-separated string of all available label names (e.g., `"kind/bug,priority/p1,docs"`).
150
+
**Available Labels** (single, comma-separated string of all available label names):
151
+
```
152
+
${{ env.AVAILABLE_LABELS }}
153
+
```
151
154
152
-
- **`ISSUES_TO_TRIAGE`**: Contains a string of a JSON array, where each object has `"number"`, `"title"`, and `"body"` keys.
155
+
**Issues to Triage** (JSON array where each object has `"number"`, `"title"`, and `"body"` keys):
156
+
```
157
+
${{ env.ISSUES_TO_TRIAGE }}
158
+
```
153
159
154
-
- **`GITHUB_ENV`**: Contains the file path where your final JSON output must be written.
160
+
**Output File Path** where your final JSON output must be written:
161
+
```
162
+
${{ env.GITHUB_ENV }}
163
+
```
155
164
156
165
## Execution Workflow
157
166
158
-
Follow this five-step process sequentially.
159
-
160
-
## Step 1: Retrieve Input Data
161
-
162
-
First, retrieve all necessary information from the environment by executing the following shell commands. You will use the resulting shell variables in the subsequent steps.
Parse the content of the `LABELS_DATA` shell variable into a list of strings. Parse the content of the `ISSUES_DATA` shell variable into a JSON array of issue objects.
171
+
Parse the provided data above:
172
+
- Split the available labels by comma to get the list of valid labels
173
+
- Parse the JSON array of issues to analyze
174
+
- Note the output file path where you will write your results
171
175
172
-
## Step 3: Analyze Label Semantics
176
+
## Step 2: Analyze Label Semantics
173
177
174
178
Before reviewing the issues, create an internal map of the semantic purpose of each available label based on its name. For example:
175
179
@@ -183,7 +187,7 @@ jobs:
183
187
184
188
This semantic map will serve as your classification criteria.
185
189
186
-
## Step 4: Triage Issues
190
+
## Step 3: Triage Issues
187
191
188
192
Iterate through each issue object you parsed in Step 2. For each issue:
189
193
@@ -195,11 +199,11 @@ jobs:
195
199
196
200
4. If no available labels are a clear and confident match for an issue, exclude that issue from the final output.
197
201
198
-
## Step 5: Construct and Write Output
202
+
## Step 4: Construct and Write Output
199
203
200
204
Assemble the results into a single JSON array, formatted as a string, according to the **Output Specification** below. Finally, execute the command to write this string to the output file, ensuring the JSON is enclosed in single quotes to prevent shell interpretation.
201
205
202
-
- `Run: echo 'TRIAGED_ISSUES=...' > "${OUTPUT_PATH}"`. (Replace `...` with the final, minified JSON array string).
206
+
- Use the shell command to write: `echo 'TRIAGED_ISSUES=...' > "$GITHUB_ENV"` (Replace `...` with the final, minified JSON array string).
Copy file name to clipboardExpand all lines: .github/workflows/gemini-triage.yml
+23-11Lines changed: 23 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -97,29 +97,41 @@ jobs:
97
97
98
98
## Guidelines
99
99
100
-
- Retrieve the value for environment variables using the "echo" shell command.
101
-
- Environment variables are specified in the format "${VARIABLE}" (with quotes and braces).
102
100
- Only use labels that are from the list of available labels.
103
101
- You can choose multiple labels to apply.
104
102
- When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
105
103
106
-
## Steps
104
+
## Input Data
105
+
106
+
**Available Labels** (comma-separated):
107
+
```
108
+
${{ env.AVAILABLE_LABELS }}
109
+
```
107
110
108
-
1. Retrieve the available labels from the environment variable: "${AVAILABLE_LABELS}".
111
+
**Issue Title**:
112
+
```
113
+
${{ env.ISSUE_TITLE }}
114
+
```
109
115
110
-
2. Retrieve the issue title from the environment variable: "${ISSUE_TITLE}".
116
+
**Issue Body**:
117
+
```
118
+
${{ env.ISSUE_BODY }}
119
+
```
111
120
112
-
3. Retrieve the issue body from the environment variable: "${ISSUE_BODY}".
121
+
**Output File Path**:
122
+
```
123
+
${{ env.GITHUB_ENV }}
124
+
```
113
125
114
-
4. Review the issue title, issue body, and available labels.
126
+
## Steps
115
127
116
-
5. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
128
+
1. Review the issue title, issue body, and available labels provided above.
117
129
118
-
6. Classify the issue by identifying the appropriate labels from the list of available labels.
130
+
2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
119
131
120
-
7. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
132
+
3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
121
133
122
-
8. Use the "echo" shell command to append the CSV labels into the filepath referenced by the environment variable "${GITHUB_ENV}":
134
+
4. Use the "echo" shell command to append the CSV labels to the output file path provided above:
2. **Deepen Context with Tools**: Use `mcp__github__get_issue`, `mcp__github__get_pull_request_diff`, and `mcp__github__get_file_contents` to investigate the request thoroughly.
Copy file name to clipboardExpand all lines: examples/workflows/issue-triage/gemini-scheduled-triage.yml
+24-20Lines changed: 24 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -143,33 +143,37 @@ jobs:
143
143
144
144
5. **Command Substitution**: When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
145
145
146
-
## Input Data Description
146
+
## Input Data
147
147
148
-
You will work with the following environment variables:
148
+
The following data is provided for your analysis:
149
149
150
-
- **`AVAILABLE_LABELS`**: Contains a single, comma-separated string of all available label names (e.g., `"kind/bug,priority/p1,docs"`).
150
+
**Available Labels** (single, comma-separated string of all available label names):
151
+
```
152
+
${{ env.AVAILABLE_LABELS }}
153
+
```
151
154
152
-
- **`ISSUES_TO_TRIAGE`**: Contains a string of a JSON array, where each object has `"number"`, `"title"`, and `"body"` keys.
155
+
**Issues to Triage** (JSON array where each object has `"number"`, `"title"`, and `"body"` keys):
156
+
```
157
+
${{ env.ISSUES_TO_TRIAGE }}
158
+
```
153
159
154
-
- **`GITHUB_ENV`**: Contains the file path where your final JSON output must be written.
160
+
**Output File Path** where your final JSON output must be written:
161
+
```
162
+
${{ env.GITHUB_ENV }}
163
+
```
155
164
156
165
## Execution Workflow
157
166
158
-
Follow this five-step process sequentially.
159
-
160
-
## Step 1: Retrieve Input Data
161
-
162
-
First, retrieve all necessary information from the environment by executing the following shell commands. You will use the resulting shell variables in the subsequent steps.
Parse the content of the `LABELS_DATA` shell variable into a list of strings. Parse the content of the `ISSUES_DATA` shell variable into a JSON array of issue objects.
171
+
Parse the provided data above:
172
+
- Split the available labels by comma to get the list of valid labels
173
+
- Parse the JSON array of issues to analyze
174
+
- Note the output file path where you will write your results
171
175
172
-
## Step 3: Analyze Label Semantics
176
+
## Step 2: Analyze Label Semantics
173
177
174
178
Before reviewing the issues, create an internal map of the semantic purpose of each available label based on its name. For example:
175
179
@@ -183,7 +187,7 @@ jobs:
183
187
184
188
This semantic map will serve as your classification criteria.
185
189
186
-
## Step 4: Triage Issues
190
+
## Step 3: Triage Issues
187
191
188
192
Iterate through each issue object you parsed in Step 2. For each issue:
189
193
@@ -195,11 +199,11 @@ jobs:
195
199
196
200
4. If no available labels are a clear and confident match for an issue, exclude that issue from the final output.
197
201
198
-
## Step 5: Construct and Write Output
202
+
## Step 4: Construct and Write Output
199
203
200
204
Assemble the results into a single JSON array, formatted as a string, according to the **Output Specification** below. Finally, execute the command to write this string to the output file, ensuring the JSON is enclosed in single quotes to prevent shell interpretation.
201
205
202
-
- `Run: echo 'TRIAGED_ISSUES=...' > "${OUTPUT_PATH}"`. (Replace `...` with the final, minified JSON array string).
206
+
- Use the shell command to write: `echo 'TRIAGED_ISSUES=...' > "$GITHUB_ENV"` (Replace `...` with the final, minified JSON array string).
Copy file name to clipboardExpand all lines: examples/workflows/issue-triage/gemini-triage.yml
+23-11Lines changed: 23 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -97,29 +97,41 @@ jobs:
97
97
98
98
## Guidelines
99
99
100
-
- Retrieve the value for environment variables using the "echo" shell command.
101
-
- Environment variables are specified in the format "${VARIABLE}" (with quotes and braces).
102
100
- Only use labels that are from the list of available labels.
103
101
- You can choose multiple labels to apply.
104
102
- When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
105
103
106
-
## Steps
104
+
## Input Data
105
+
106
+
**Available Labels** (comma-separated):
107
+
```
108
+
${{ env.AVAILABLE_LABELS }}
109
+
```
107
110
108
-
1. Retrieve the available labels from the environment variable: "${AVAILABLE_LABELS}".
111
+
**Issue Title**:
112
+
```
113
+
${{ env.ISSUE_TITLE }}
114
+
```
109
115
110
-
2. Retrieve the issue title from the environment variable: "${ISSUE_TITLE}".
116
+
**Issue Body**:
117
+
```
118
+
${{ env.ISSUE_BODY }}
119
+
```
111
120
112
-
3. Retrieve the issue body from the environment variable: "${ISSUE_BODY}".
121
+
**Output File Path**:
122
+
```
123
+
${{ env.GITHUB_ENV }}
124
+
```
113
125
114
-
4. Review the issue title, issue body, and available labels.
126
+
## Steps
115
127
116
-
5. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
128
+
1. Review the issue title, issue body, and available labels provided above.
117
129
118
-
6. Classify the issue by identifying the appropriate labels from the list of available labels.
130
+
2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
119
131
120
-
7. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
132
+
3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
121
133
122
-
8. Use the "echo" shell command to append the CSV labels into the filepath referenced by the environment variable "${GITHUB_ENV}":
134
+
4. Use the "echo" shell command to append the CSV labels to the output file path provided above:
- **Additional User Instructions**: ${{ env.ADDITIONAL_CONTEXT }}
144
144
- Use `mcp__github__get_pull_request` to get the title, body, and metadata about the pull request.
145
145
- Use `mcp__github__get_pull_request_files` to get the list of files that were added, removed, and changed in the pull request.
146
146
- Use `mcp__github__get_pull_request_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
0 commit comments