-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[ACIX-1916] feat(ai): Create /follow-pr skill
#54482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gh-worker-dd-mergequeue-cf854d
merged 9 commits into
main
from
pierrelouis.veyrenc/ACIX-1916-create-follow-pr-skill
Aug 7, 2026
+122
−1
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b6c8bae
feat: add `/follow-pr` skill
Ishirui cff0ba3
feat: add a hint to `/create-pr` to invoke `/follow-pr`
Ishirui c2a2d4a
fix: properly `babysit`->`follow`
Ishirui e1368a6
fix: mention appropriate behavior when running insde a dev env
Ishirui 8626ff9
fix: remove variable export from `create-devenv.sh`
Ishirui 72c09e6
fix: final missing `babysit->follow` rename
Ishirui 4ac1264
fix: explicitely specify retry time
Ishirui fd4e813
feat: give a bit more detail to `create-devenv.sh`'s final `echo`
Ishirui 8d01ea8
feat: add guidance for dealing with flaky failures
Ishirui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| --- | ||
| name: follow-pr | ||
| description: >- | ||
| Monitor the current PR's GitLab pipeline to completion, then report success or investigate a failure. | ||
| Use when the user asks to follow, babysit, watch, or wait on a PR/pipeline, or just after pushing to / creating a PR. | ||
| model: sonnet | ||
| --- | ||
|
|
||
| # Follow PR | ||
|
|
||
| Watch the latest Gitlab CI pipeline for the current PR to a terminal state and report the outcome. | ||
|
|
||
| ## Step 0: Ensure correct environment | ||
| The appropriate tool for this usecase is `ddgl`, and more specifically `ddgl attach`. | ||
| Check if `ddgl` is available - `which ddgl`. If so, move to [Step 1](#step-1-determine-the-target). Otherwise, use a dev env as specified below. | ||
|
|
||
| ### Ensuring a dev env | ||
| First, check if you are running in a dev env: `test -f /.started` will exit 0 if so. If you are in an outdated devenv without `ddgl`, stop and notify the user to recreate his dev env. | ||
| Otherwise, check for the existence of a dev env by using `dda env dev show`. | ||
|
|
||
| **If there are existing dev envs**: | ||
| - Check if the current repo is properly mounted into that env (`repos` and `extra_(mount|volume)_specs` fields) | ||
| - Check the current state of that dev env. | ||
|
|
||
| If the environment is already started and contains the right repo, move to [the next step](#using-a-dev-env). | ||
| Otherwise, create one by using `./create_devenv.sh`, then use the environment ID printed by the script in subsequent commands. | ||
|
|
||
| ### Using a dev env | ||
| To run commands inside a dev env, use the following template: | ||
| ```bash | ||
| dda env dev run --id <dev-env-id> -- [command] | ||
| ``` | ||
| Watch out for space-splitting. For example: | ||
| ```bash | ||
| dda env dev run --id follow-pr-attach-7C2C42F6 -- ddgl attach --detail=normal --follow --plain | ||
| ``` | ||
|
|
||
| ## Step 1: Determine the target | ||
|
|
||
| If the user gave a ref, branch, or pipeline ID, pass it through (`--ref <ref>` or `--pipeline <id>`). | ||
| Otherwise omit both — `ddgl attach` resolves the pipeline for the current branch on its own. | ||
|
|
||
| ## Step 2: Start monitoring | ||
|
|
||
| All pipeline discovery, polling, follow/rebind, and timeout handling is covered by the internals of `ddgl attach`. | ||
| Do not implement a second polling loop or persist monitoring state of your own. | ||
|
|
||
| Check whether you have a long-lived monitoring tool available, one that can run a command in the background and forward each stdout line as it arrives, without a timeout of its own (e.g. Claude Code's `Monitor` tool). | ||
|
|
||
| **With such a tool:** start it on | ||
|
|
||
| ```bash | ||
| ddgl attach --plain --follow --detail=full [--ref <ref> | --pipeline <id>] | ||
| ``` | ||
|
|
||
| and wait for a `[FINAL]` line — no `--timeout` needed. | ||
|
|
||
| **Without one:** run it in the foreground, bounded so the invocation cannot | ||
| outlive your own harness timeout: | ||
|
|
||
| ```bash | ||
| ddgl attach --plain --follow --detail=full --timeout 600 [--ref <ref> | --pipeline <id>] | ||
| ``` | ||
|
|
||
| If the `[FINAL]` line reports a timeout (not a pipeline outcome), start an identical invocation again. | ||
| This is safe: `attach` is stateless and each invocation begins with a fresh snapshot of the pipeline. | ||
|
|
||
| > NOTE: If the pipeline is already terminal or does not exist when you start monitoring, the user might have just pushed and the pipeline is still waiting to be created. | ||
| > In this case, wait for 60 seconds and then re-attempt monitoring. The `--follow` argument will make sure `ddgl attach` always monitors the latest pipeline for the ref. | ||
|
|
||
| ## Step 3: Interpret the output | ||
|
|
||
| You may see: | ||
|
|
||
| - `[POLL]` - rollup summary after a changed poll tick (jobs done/total, stage, | ||
| failure count). Informational only. | ||
| - `[INFO]` - an informational log from `ddgl` itself. | ||
| - `[PIPE]` - a change in the pipeline status. | ||
| - `[JOB]` - a job finished running and changed state. | ||
| - `[FINAL]` - the terminal, authoritative outcome. Treat this line as the | ||
| source of truth regardless of the command's exit code — it names the pipeline id, terminal status, and, on failure, the failed job names. | ||
|
|
||
| ## Step 4: Act on the outcome | ||
|
|
||
| - **Pipeline Success:** stop monitoring and report the pipeline succeeded. | ||
| - **Some job failed, but the pipeline is still running**: | ||
| Note that most jobs on `datadog-agent` CI have at least one retry for combating flakiness - especially jobs running e2e tests, kmt etc. | ||
| Unit test, linter or build failures are less likely to be flakes. If you think it is likely the job's failure is just a flake, continue monitoring - gitlab will retry the job once automatically. | ||
| Otherwise, ask the user whether to continue monitoring, or if this job failure is already a problem. In the latter case, move to [Step 5](#step-5-follow-up-on-failures) | ||
| - **Pipeline failed or canceled:** Stop monitoring, report the status, and move to [Step 5](#step-5-follow-up-on-failures). | ||
| - **Timeout `[FINAL]`:** re-invoke `ddgl attach` as in Step 2; this is not a true terminal outcome. | ||
| - **Unexpected error** (from `ddgl` itself, or from the monitoring tool): report what happened. Do not attempt a recovery action. | ||
|
|
||
| ## Step 5: follow-up on failures | ||
| Use other `ddgl` features to investigate failures on the pipeline that failed | ||
| Using the pipeline id from the `[FINAL]` line: | ||
| 1. `ddgl jobs get --pipeline <id> --failed --json` — failed-job metadata. | ||
| 2. `mkdir -p failures && ddgl logs --pipeline <id> --failed --output failures/` — export failed-job log output to `failures/` | ||
| 3. Compare the failure evidence against the current PR's diff. Decide | ||
| whether the failure is likely caused by this PR, needs more evidence, or | ||
| is unrelated (e.g. flaky infra, an unrelated pre-existing failure). | ||
| 4. If PR-caused, propose the smallest concrete fix — do not apply it. If | ||
| not, or inconclusive, report the evidence and your reasoning. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/bin/sh | ||
|
|
||
| set -e pipefail | ||
|
|
||
| # Get the repo path | ||
| REPO=$(git rev-parse --show-toplevel) | ||
|
|
||
| # Create a unique ID | ||
| ID=follow-pr-attach-$(uuidgen | cut -d'-' -f1) | ||
|
|
||
| # Use --no-pull to make sure it starts quickly | ||
| # Explicitly pass the repo to avoid cloning or missing the automatic bind-mount. Note it will be mounted as `/repos/the/full/absolute/path` inside the container | ||
| # But the CWD is changed appropriately when doing this way, so it's fine | ||
| dda env dev start --no-pull --repo "${REPO}" --id "${ID}" | ||
|
|
||
| echo "Created env to use for the PR attach task: ${ID}" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.