en un clic
drupalorg-work-on-issue
// Agentic workflow for contributing to a Drupal.org issue via GitLab MR. Orchestrates fork verification, directory alignment, remote setup, branch checkout, and the fix/push/pipeline loop.
// Agentic workflow for contributing to a Drupal.org issue via GitLab MR. Orchestrates fork verification, directory alignment, remote setup, branch checkout, and the fix/push/pipeline loop.
CLI for Drupal.org issue lifecycle management. Use when fetching issue details, generating patches/interdiffs, listing project or maintainer issues, looking up releases, or working with GitLab merge requests on issue forks. Also supports projects that have migrated to GitLab work items. Pass --format=llm to every read command for structured XML output optimised for agent consumption.
Search for Drupal.org issues by keyword. Combines CLI API search, Drupal.org issue queue scraping, and web search, then deduplicates and presents a unified summary.
Fetches a Drupal.org issue with all its comments and analyses whether the "Proposed resolution" in the issue summary matches the current discussion consensus. Drafts an updated summary for the user to paste back.
CLI for Drupal.org issue lifecycle management. Use when fetching issue details, generating patches/interdiffs, listing project or maintainer issues, looking up releases, or working with GitLab merge requests on issue forks. Also supports projects that have migrated to GitLab work items. Pass --format=llm to every read command for structured XML output optimised for agent consumption.
Run PHPStan and fix all reported errors in src/
Run the full local CI suite before opening a PR
| name | drupalorg-work-on-issue |
| description | Agentic workflow for contributing to a Drupal.org issue via GitLab MR. Orchestrates fork verification, directory alignment, remote setup, branch checkout, and the fix/push/pipeline loop. |
Purpose: Agentic workflow for contributing to a Drupal.org issue via GitLab MR.
Usage: /drupalorg-work-on-issue <nid-or-ref>
The argument can be:
3586157ai_context#3586157https://git.drupalcode.org/project/ai_context/-/work_items/3586157All three formats are accepted by issue:show, issue:get-fork, and mr:list.
When the user invokes /drupalorg-work-on-issue <nid>, execute the following workflow. Pause at
each checkpoint marked [PAUSE] — present findings and wait for the user to confirm
before proceeding.
Run both commands to gather context (substitute <nid> with whatever ref was provided):
drupalorg issue:show <nid> --format=llm
drupalorg issue:get-fork <nid> --format=llm
Report to the user:
Directory detection: Before prompting the user, read CLAUDE.md in the current directory.
If it documents the path to the <project> module or repository, cd there automatically
and skip the directory prompt. Only fall back to running git remote get-url origin and
asking the user if CLAUDE.md provides no guidance.
Branch selection: Count branches from the issue:get-fork output that match <nid>-*:
No fork at all (GitLab work item projects): If issue:get-fork reports no fork
exists AND the project uses GitLab work items (the ref is a project_name#nid or
work item URL, not a classic Drupal.org NID), offer to create one:
drupalorg issue:fork <ref>
The Drupal.org bot processes the comment asynchronously. Wait a few seconds, then
re-run drupalorg issue:get-fork <ref> --format=llm --no-cache to confirm the fork
exists before proceeding. To pick up an existing fork you don't yet have push access
to (Example #2 in the upstream docs), run drupalorg issue:get-access <ref> before
issue:setup-remote.
[PAUSE] Only pause here if the working directory could not be determined automatically OR if multiple branches exist. Present your findings and wait for confirmation before proceeding.
Important: All
gitanddrupalorgcommands from this point forward must be run from the project module directory (not the Drupal site root). Ensure you havecd'd into the correct directory before executing any command below.
Once the directory and branch are confirmed:
drupalorg issue:setup-remote <nid>
drupalorg issue:checkout <nid> <branch>
Optional (GitLab work items): Self-assign so others can see you are working on this issue:
drupalorg issue:assign <ref>
SSH remote URL check: issue:setup-remote sets the remote URL to HTTPS
(https://git.drupal.org/issue/<project>-<nid>.git). Contributors using SSH authentication
must switch to the SSH equivalent before pushing. After the remote is set:
git remote get-url drupalorg
https://, warn the user and offer to convert it:
git remote set-url drupalorg git@git.drupal.org:issue/<project>-<nid>.git
where <project> and <nid> match the values from the HTTPS URL.git@, no action needed.Report the branch that is now active.
Important: Run all commands from the project module directory.
Diff the branch first to understand what has already been changed vs. what is still
missing. Determine the upstream default branch from the fork data (e.g. main, 10.3.x),
then run:
git diff origin/<default-branch>...HEAD
Read this diff carefully before analysing the MR — it is the authoritative record of what the branch already contains. Do not assume a file is unchanged without checking the diff.
drupalorg mr:list <nid> --format=llm
If mr:list returns no MRs:
git push, capture the GitLab MR-creation URL printed in the push
output and surface it to the user. Then re-run drupalorg mr:list <nid> --format=llm
to pick up the newly created MR IID before polling pipeline status.If one or more MRs exist, for the relevant MR (confirm with user if multiple exist):
drupalorg mr:files <nid> <mr-iid>
drupalorg mr:diff <nid> <mr-iid>
drupalorg mr:status <nid> <mr-iid> --format=llm
Summarise:
drupalorg mr:logs <nid> <mr-iid>[PAUSE] Present your analysis of the MR and the pipeline results, then ask: "What would you like me to work on?"
Important: Run all
gitanddrupalorgcommands from the project module directory.
Iterate until the pipeline is green or the user asks to stop:
vendor/bin/phpcs is available, run it on the module directory and fix any violations
before proceeding:
vendor/bin/phpcs <module-path>
Do not stage or commit files while PHPCS reports errors. Skip this step if PHPCS is
not installed.git log --oneline -5
Match the observed style (e.g. conventional commits, Issue #<nid> by <username>:, etc.)
rather than defaulting to any fixed template.git add <specific-changed-files>
git commit -m "<message matching project style>"
git pushdrupalorg mr:status <nid> <mr-iid> --format=llm
drupalorg mr:logs <nid> <mr-iid>
[PAUSE] After each push, report the pipeline outcome and ask whether to continue or stop.
Hand off for review (GitLab work items only): When the pipeline is green and the user confirms the work is ready for review, flip the state label and unassign:
drupalorg issue:label <ref> state::needsReview
drupalorg issue:unassign <ref>
issue:setup-remote is idempotent — safe to re-run.--format=llm output is optimised for parsing; always use it when reading structured data.