GitLab App

Install the Sophonz GitLab App on your project to automatically create issues and suggest code fixes driven by real-user error data collected by the Sophonz SDK.

Install sophonz-gitlab on your app repository and it will analyze problems (errors, crashes, performance issues) collected from real users instrumented with the Sophonz SDK, then automatically open issues and propose code fixes as merge requests.

How it works

sophonz-gitlab fetches runtime error data via Sophonz MCP, then an AI agent creates a patch branch and opens a Merge Request (MR).

gitlab-app

On every tick of the schedule defined in .sophonz/config.yml, the app:

  1. Queries Sophonz for the top errors within the configured time window
  2. Maps stack frames to files inside the project
  3. Drafts a patch with a Claude-based AI agent
  4. Opens a merge request, grouping changes by error signature

For a full overview of the AI Agent pipeline, see AI Agent Overview.

Prerequisites

sophonz-gitlab supports both GitLab.com and self-hosted GitLab instances. Integration requires a Group or Project Access Token.

NOTE — Difference from the GitHub App

GitLab does not have an equivalent to GitHub's Manifest Flow for automatic OAuth app creation. You need to generate an Access Token manually and provide it in the configuration.

Installation

Step 1: Generate an Access Token

Generate an Access Token on your GitLab group or project.

  • Group Access Token: Group → Settings → Access Tokens
  • Project Access Token: Project → Settings → Access Tokens

Required scopes: api, read_repository, write_repository

Copy the token immediately — it will not be shown again after you leave the page.

Step 2: Configure the integration in the Sophonz console

In the Sophonz console under Integrations → GitLab App, enter:

  • GitLab instance URL (default: https://gitlab.com)
  • The Access Token you just generated
  • Target group ID or project path

Step 3: Trigger the onboarding MR

After saving, trigger the onboarding MR from the Sophonz console or via the API. The MR adds .sophonz/config.yml to the project root.

Single project onboarding:

curl -X POST "https://your-sophonz-instance/gitlab/onboard" \
  -H "Authorization: Bearer $SERVICE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId": 12345, "projectPath": "your-org/your-repo"}'

Group bulk onboarding:

curl -X POST "https://your-sophonz-instance/gitlab/onboard/group/9999" \
  -H "Authorization: Bearer $SERVICE_TOKEN"

Response statuses: config-already-present / branch-exists / pr-created / skipped-error

Step 4: Configure the app connection

Fill in the app details in .sophonz/config.yml — either in the onboarding MR or in a follow-up MR.

.sophonz/config.yml
service:
  namespace: "<your-project>"
  name: "<your-app-name>"
  key: "${{ secrets.SOPHONZ_SERVICE_KEY }}"  # reference a GitLab CI/CD variable
 
schedule: "every weekday before 9am"  # or cron, e.g. "0 0 * * 1-5"
window: "24h"
topN: 10
 
ai:
  model: "claude-sonnet-4-6"
  maxIterations: 4
 
mr:
  branchPrefix: "sophonz/"
  labels: ["sophonz", "bug"]
  draft: false
  groupBySignature: true
 
scope:
  allowedPaths: ["src/**", "apps/**"]
  blockedPaths: ["**/node_modules/**", "**/dist/**"]
 
triggers:
  schedule: true

Store service.key as a GitLab CI/CD variable (Settings → CI/CD → Variables) and reference it as ${{ secrets.SOPHONZ_SERVICE_KEY }}. Do not commit the key in plaintext.

Once the configuration file is merged, the App runs automatically on the defined schedule.

Required permissions (Access Token scopes)

ScopePurpose
apiQuery projects, create MRs, write issues
read_repositoryRead source code and map stack frames
write_repositoryCreate patch branches and commits

GitHub ↔ GitLab concept mapping

GitHubGitLab
Pull RequestMerge Request
owner/reponamespace/project_path
Manifest FlowAccess Token + /gitlab/setup guide
Webhook HMACX-Gitlab-Token

Merge request contents

Each generated MR includes:

  • Error message and the most affected app version
  • Occurrence count and number of affected sessions
  • Last-seen timestamp
  • Mapped stack frames
  • Related trace IDs (linked to the Sophonz dashboard)
  • A short summary of the AI agent's reasoning

One-shot manual run

To process a single error signature immediately without waiting for the schedule:

curl -X POST "https://your-sophonz-instance/sophonz/agent-run" \
  -H "Authorization: Bearer $SERVICE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"projectId": 12345, "projectPath": "your-org/your-repo", "forceDryRun": true}'

Providing a signature field processes only that signature. When omitted, the top error is selected automatically.

Data handling

  • service.key is read from the GitLab CI/CD variable at runtime, used transiently for the Sophonz MCP call, and never persisted.
  • Repository code is sent to the LLM only at patch-generation time and is not used for model training, per the Anthropic API policy.
  • Error data and repository code are not sent anywhere outside your Sophonz workspace and the LLM provider used to draft patches.

CAUTION — Experimental

sophonz-gitlab is currently at v0.x, validating the Access Token integration, MCP connection, and single-signature patch merge requests. Test it on a staging or sample project before pointing it at production code.