Files
Vince Lozada efabfbcf8a feat: document JSON body pattern for inline MR diff comments (#31)
* feat: document JSON body pattern for inline MR comments + add post-inline-comment.py script

glab api --field silently falls back to general comments when GitLab
rejects position data (common with new files, encoded paths). Fix is
to use Python urllib with Content-Type: application/json.

- glab-mr: new 'Posting Inline Comments on MR Diffs' section with
  full code example, line number parsing helper, and batch script usage
- scripts/post-inline-comment.py: reusable script supporting single
  and batch comment posting; auto-reads token from glab config;
  reports inline vs general fallback per comment

Closes #28

* security: harden post-inline-comment.py + add openclaw.requires metadata

Security fixes before ClawHub publish:
- Enforce HTTPS-only for --host (prevents token leakage over HTTP)
- Validate --project path format with regex
- Validate --file path (no null bytes or newlines)
- Cap --body at 10,000 chars with truncation warning
- Validate --line is a positive integer
- Batch file size limit (1MB) and count limit (100 comments)
- Validate token is non-empty and whitespace-free before first API call
- Fetch token after input validation (avoids credential access on bad input)
- Explicit SSL context on all urllib calls (strict CA verification)
- Error body truncated in exception messages (prevents token reflection)

Root SKILL.md: add openclaw.requires block declaring:
- GITLAB_TOKEN credential (optional, falls back to glab config)
- Outbound HTTPS network access scope
- Write-access warning (comments, thread resolution, MR approval)

---------

Co-authored-by: Steven (Bot) <steven@winkintel.com>
2026-03-03 09:57:31 -06:00
..

GitLab CLI Scripts

Automation scripts for common GitLab CLI workflows.

Available Scripts

mr-review-workflow.sh

Automated MR review: checkout → run tests → approve if passed.

./scripts/mr-review-workflow.sh <MR_ID> [test_command]

# Examples
./scripts/mr-review-workflow.sh 123
./scripts/mr-review-workflow.sh 123 "pnpm test"
./scripts/mr-review-workflow.sh 123 "cargo test"

What it does:

  1. Checks out the MR locally
  2. Runs your test command (default: npm test)
  3. If tests pass: adds approval comment + approves MR
  4. If tests fail: adds failure comment with details

create-mr-from-issue.sh

Create branch from issue with proper naming.

./scripts/create-mr-from-issue.sh <ISSUE_ID> [--create-mr]

# Examples
./scripts/create-mr-from-issue.sh 456
./scripts/create-mr-from-issue.sh 456 --create-mr  # Also creates draft MR

What it does:

  1. Fetches issue title
  2. Creates branch named <issue-id>-<slugified-title>
  3. Optionally creates draft MR linked to the issue

ci-debug.sh

Debug CI failures by showing failed job logs.

./scripts/ci-debug.sh <PIPELINE_ID>

# Example
./scripts/ci-debug.sh 987654

What it does:

  1. Lists all failed jobs in the pipeline
  2. Shows last 50 lines of each failed job's log
  3. Provides next steps for debugging

add-inline-comment.sh

Post inline code review comments at specific line numbers in MR diffs.

./scripts/add-inline-comment.sh <repo> <mr_iid> <file_path> <line_number> <comment_text>

# Examples
./scripts/add-inline-comment.sh owner/repo 42 "src/main.js" 100 "Bug: Add null check"
./scripts/add-inline-comment.sh owner/repo 42 "lib/util.py" 25 "**Performance**: Use dict comprehension"

What it does:

  1. Fetches MR metadata (project ID, commit SHAs)
  2. Posts inline comment at exact file:line location
  3. Comment appears in GitLab UI directly in the diff
  4. Returns URL to the comment

Documentation: See scripts/README-inline-comments.md for detailed usage and integration examples.

batch-label-issues.sh

Apply label to multiple issues at once.

./scripts/batch-label-issues.sh <label> <issue_id1> [issue_id2] ...

# Examples
./scripts/batch-label-issues.sh bug 100 101 102
./scripts/batch-label-issues.sh "priority::high" 200 201

What it does:

  1. Applies the specified label to all listed issues
  2. Shows progress for each issue
  3. Reports success/failure summary

sync-fork.sh

Sync your fork with upstream repository.

./scripts/sync-fork.sh [branch] [upstream_remote]

# Examples
./scripts/sync-fork.sh                    # Syncs main with upstream
./scripts/sync-fork.sh develop            # Syncs develop with upstream
./scripts/sync-fork.sh main my-upstream   # Custom upstream remote name

What it does:

  1. Fetches from upstream remote
  2. Merges upstream changes into local branch
  3. Pushes to your fork's origin

Usage Tips

Make scripts available globally:

# Add to your PATH
export PATH="$PATH:/path/to/gitlab-cli-skills/scripts"

# Or create aliases
alias mr-review="/path/to/gitlab-cli-skills/scripts/mr-review-workflow.sh"
alias ci-debug="/path/to/gitlab-cli-skills/scripts/ci-debug.sh"

Use with OpenClaw:

The agent can execute these scripts directly:

"Run the MR review workflow for MR 123"
"Debug the failed CI pipeline 456789"
"Create a branch for issue 789 and draft MR"

Requirements

  • glab CLI installed and authenticated
  • git for branch/fork operations
  • Test framework for mr-review-workflow.sh (npm, pnpm, cargo, etc.)

Token Efficiency

These scripts are designed for OpenClaw's progressive disclosure pattern:

  • Scripts execute without loading into context
  • Only script output consumes tokens
  • Deterministic behavior vs AI-generated code
  • Reusable across multiple tasks