|
| 1 | +--- |
| 2 | +name: glab-discussion |
| 3 | +description: >- |
| 4 | + This skill should be used when the user asks to "read MR discussions", |
| 5 | + "list MR comments", "reply to a discussion", "resolve a discussion", |
| 6 | + "add a diff note", "review MR comments", "dump discussions", |
| 7 | + "show MR diff for commenting", or needs to interact with GitLab merge request |
| 8 | + discussions. Provides CLI reference for the glab-discussion tool. |
| 9 | +--- |
| 10 | + |
| 11 | +# glab-discussion CLI |
| 12 | + |
| 13 | +CLI for listing, creating, and managing GitLab merge request discussions. |
| 14 | +Auto-detects the MR from the current git branch. Override with `--mr-url <url>` |
| 15 | +or `--hostname <host> --project <path> --mr-iid <n>`. |
| 16 | + |
| 17 | +## Subcommands |
| 18 | + |
| 19 | +### read — Read discussions |
| 20 | + |
| 21 | +```bash |
| 22 | +glab-discussion read # auto-selects dump mode in non-interactive environments |
| 23 | +glab-discussion read --dump # write per-thread TXT files, incrementally updated |
| 24 | +glab-discussion read --dump --full # force full rewrite of all files |
| 25 | +glab-discussion read --no-dump # print to stdout instead |
| 26 | +``` |
| 27 | + |
| 28 | +Writes one TXT file per discussion thread to `/tmp/glab-discussion/<host>/mr-<iid>/`. |
| 29 | +Incremental — only rewrites files when content has changed. Prints a summary of new/updated/deleted files. |
| 30 | + |
| 31 | +Each file contains: |
| 32 | +- Header: discussion ID, type (General/DiffNote), resolved status, file/line for diff notes, URL |
| 33 | +- Body: chronological notes with timestamps, usernames, `[BOT]` for bot accounts |
| 34 | + |
| 35 | +### diff — Show commentable diff with line numbers |
| 36 | + |
| 37 | +```bash |
| 38 | +glab-discussion diff # all changed files |
| 39 | +glab-discussion diff --file src/Foo.java # single file |
| 40 | +glab-discussion diff --version <version_id> # specific diff version |
| 41 | +``` |
| 42 | + |
| 43 | +Outputs an annotated diff showing both old and new line numbers for each line. |
| 44 | +Use these line numbers with `write --new-line` or `write --old-line`. |
| 45 | + |
| 46 | +Output format: |
| 47 | +``` |
| 48 | +Version: <id> |
| 49 | +base_sha: <sha> |
| 50 | +head_sha: <sha> |
| 51 | +start_sha: <sha> |
| 52 | +
|
| 53 | +--- a/src/Foo.java |
| 54 | ++++ b/src/Foo.java |
| 55 | + old | new | |
| 56 | + 41 | 41 | var x = 1; |
| 57 | + 42 | | - var y = old(); |
| 58 | + | 42 | + var y = newMethod(); |
| 59 | + 43 | 43 | var z = 3; |
| 60 | +``` |
| 61 | + |
| 62 | +### write — Create discussion, reply, or diff note |
| 63 | + |
| 64 | +```bash |
| 65 | +# New general discussion thread |
| 66 | +glab-discussion write --body "Starting a thread" |
| 67 | +glab-discussion write --body - # read body from stdin |
| 68 | + |
| 69 | +# Reply to existing thread |
| 70 | +glab-discussion write --reply-to <discussion_id> --body "My reply" |
| 71 | + |
| 72 | +# Diff note on a specific line |
| 73 | +glab-discussion write --file src/Foo.java --new-line 42 --body "Issue here" |
| 74 | +glab-discussion write --file src/Foo.java --old-line 10 --body "Was wrong" |
| 75 | +glab-discussion write --file src/Foo.java --new-line 42 --commit <sha> --body "On this version" |
| 76 | +``` |
| 77 | + |
| 78 | +**Modes** (mutually exclusive): |
| 79 | +- `--reply-to <discussion_id>` — reply to an existing thread |
| 80 | +- `--file <path>` — create a diff note (requires `--new-line` and/or `--old-line`) |
| 81 | +- Neither — create a new general discussion thread |
| 82 | + |
| 83 | +For diff notes, `--commit <sha>` optionally pins to a specific diff version (matched against `head_commit_sha`). Without it, uses the latest version. |
| 84 | + |
| 85 | +### resolve — Resolve/unresolve a discussion |
| 86 | + |
| 87 | +```bash |
| 88 | +glab-discussion resolve <discussion_id> |
| 89 | +glab-discussion resolve <discussion_id> --unresolve |
| 90 | +``` |
| 91 | + |
| 92 | +## Typical AI Workflow |
| 93 | + |
| 94 | +1. **Read discussions:** `glab-discussion read` |
| 95 | +2. **Review dumped files:** Read the TXT files to understand discussion threads |
| 96 | +3. **Check diff context:** `glab-discussion diff --file <path>` to see commentable lines |
| 97 | +4. **Reply:** `glab-discussion write --reply-to <id> --body "..."` |
| 98 | +5. **Add diff note:** `glab-discussion write --file <path> --new-line <n> --body "..."` |
| 99 | +6. **Resolve:** `glab-discussion resolve <id>` |
| 100 | +7. **Re-read:** `glab-discussion read` to see updated state (incremental, only changed files) |
| 101 | + |
0 commit comments