Most DevOps teams approach automated security remediation with a flawed mental model. They assume they can slap a single flag onto a CLI runner inside a Jenkins or GitHub Actions container—something like snyk code test --auto-fix—and watch their pipeline autonomously author git commits and open merge requests.
It does not work that way. When engineering leaders realize this, they often feel cheated by marketing promises. But at 365Finds, we actually prefer Snyk's architectural reality. Automated AI code modification requires strict version control boundaries, webhook event loops, and multi-stage validation. If you want Snyk DeepCode AI (now integrated within Snyk Agent Fix) to reliably generate pull request fixes in your delivery pipeline, you must bridge two distinct layers: native Source Code Management (SCM) authorization for pull request synthesis, and CI/CD runner pipelines for policy enforcement.
Here is exactly how to wire both layers together, avoid common configuration traps, and deploy automated PR remediation that developers will actually merge.
The Two-Layer Architecture: SCM vs. Pipeline Runner
To configure automated fixes successfully, you have to separate two operational responsibilities:
- The SCM Integration Layer (The Fix Generator): Automated PR generation—whether proactive backlog remediation PRs or interactive inline PR suggestions—executes through Snyk’s SCM integration (GitHub App, GitLab integration, Bitbucket, or Azure DevOps). Snyk requires direct repository write tokens to branch off, write code diffs, open pull requests, and listen to pull request comment events.
- The CI/CD Pipeline Layer (The Enforcement Gate): The continuous integration pipeline runs
snyk code testvia the Snyk CLI or native workflow actions. It scans new commits, fails non-compliant builds, exports SARIF test artifacts, and prevents merge approval until security gates pass.
Trying to force a headless ephemeral CI container to manage Git branches and open pull requests directly from a bash script is brittle and unnecessary. 365Finds strongly advises utilizing Snyk's native SCM app for PR creation while letting your CI/CD pipeline serve as the immutable compliance gate.
Step 1: Enable Snyk Code in Your Organization
Snyk DeepCode AI powers Snyk Code, the static application security testing (SAST) engine. By default, Snyk Code must be explicitly toggled on at the organization level before any AI remediation features activate.
- Log in to the Snyk Web UI as an Organization Administrator.
- Navigate to Settings (gear icon in the top right) > Snyk Code.
- Under Snyk Code, toggle the setting to Enabled.
- Save the configuration.
If you skip this step, Snyk will only perform software composition analysis (SCA) on open-source packages and will never analyze proprietary source code or suggest DeepCode AI code patches.
Step 2: Connect SCM Integrations with Write Permissions
For Snyk DeepCode AI to author pull requests, it needs authenticated write access to your version control provider.
- In the Snyk Web UI, go to Settings > Integrations.
- Select your SCM provider (e.g., GitHub, GitHub Enterprise, GitLab, or Bitbucket).
- If using GitHub, we recommend installing the official Snyk GitHub App rather than personal access tokens. Ensure the app has permissions for:
- Repository contents: Read and write (required to create branches and commit fix code).
- Pull requests: Read and write (required to open Fix PRs and post inline review comments).
- Issues / Webhooks: Read and write (required to detect PR events).
- Select the target repositories you wish to import into Snyk.
Step 3: Configure Automatic Fix PRs and PR Checks
Once the repository is imported, configure the policies that govern when and how Snyk DeepCode AI opens pull requests.
- Navigate to Settings > Integrations > GitHub (or your selected SCM) > Edit settings, or open the individual Project Settings for repository-level overrides.
- Under Automatic PRs:
- Enable Automatic fix PRs for newly identified vulnerabilities. Whenever continuous monitoring identifies a newly flagged vulnerability on your monitored default branch, Snyk will automatically generate a dedicated pull request containing the remediation patch.
- Configure PR frequency: Snyk defaults to checking for fixes every 24 hours to prevent overwhelming teams with notifications.
- Set Limit open PRs to: We recommend setting this to 1 or 2 concurrent PRs per repository. Opening twenty automated PRs simultaneously triggers instant developer fatigue.
- Under Pull Request Checks (PR Checks):
- Toggle Snyk Code PR Checks to Enabled.
- Configure the gating condition: select Fail PR checks only for High or Critical severity issues. Blocking a pull request over a low-severity code smell frustrates engineers and erodes trust in automated security tooling.
- Enable The Pull Request Experience: Turn on Issue Summary Comments and Inline Comments.
Step 4: Configure the CI/CD Pipeline Workflow
With SCM pull request triggers active, configure your CI/CD pipeline to enforce security boundaries. Below is a production-ready GitHub Actions workflow demonstrating how to execute Snyk Code tests, gate pull requests, and upload findings to GitHub Security:
name: Security Pipeline - Snyk DeepCode AI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
snyk-code-analysis:
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Snyk CLI
uses: snyk/actions/setup@v0.4.0
- name: Run Snyk Code SAST Scan
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |
snyk code test --severity-threshold=high --sarif-file-output=snyk-code.sarif
continue-on-error: true
- name: Upload Snyk SARIF Results to GitHub Security Tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: snyk-code.sarif
if: always()
- name: Enforce Strict Pipeline Gate
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
run: |
snyk code test --severity-threshold=high
In this pipeline configuration:
- The runner scans the source code using the Snyk DeepCode AI engine via
snyk code test. - It exports SARIF diagnostics to populate the GitHub Security alerts dashboard.
- It fails the build if any unaddressed High-severity vulnerability exists, forcing the developer to address the issue before merging.
Step 5: Applying DeepCode AI Fixes in the Pull Request Workflow
When a developer opens a pull request that introduces an insecure code pattern, the integrated Snyk engine executes automatically:
- Inline Detection: Snyk Code identifies the taint analysis or vulnerability path and leaves an inline comment on the exact line of code.
- Interactive AI Fix Generation: In supported SCM setups, developers interact directly with Snyk in the PR comment thread. Replying with:
triggers Snyk Agent Fix (powered by DeepCode AI) to evaluate the surrounding codebase and generate up to five context-aware fix recommendations directly within the comment thread.@snyk /fix - Commit Application: After inspecting the suggested patch and its explanatory notes, the engineer applies the fix by replying:
Snyk immediately pushes a new commit to the active pull request branch containing the applied fix diff.@snyk /apply 1 - Automated Verification: The newly pushed commit triggers the CI/CD pipeline step (
snyk code test), the PR check re-evaluates the code, confirms the vulnerability is eliminated, and turns the pull request status check green.
Why 365Finds Recommends Human-in-the-Loop Over Unattended Merges
We frequently see engineering management asking: "Can Snyk DeepCode AI automatically merge the PR fix without human approval?"
Technically, you can stitch together auto-merge webhooks. 365Finds strongly advises against fully unattended merges for SAST fixes.
Unlike package version bumps in dependency files (e.g., upgrading lodash from 4.17.20 to 4.17.21), DeepCode AI rewrites application logic. It refactors database query interpolations, inserts sanitization wrappers, and modifies authorization checks.
DeepCode AI mitigates hallucinations through an agentic feedback loop: when the AI proposes a patch, Snyk re-runs a symbolic SAST scan against the generated snippet before displaying it. If the patch introduces a secondary flaw, the agent discards it and retries. Yet even with this verification loop, AI cannot infer organizational business logic. An engineer must verify that the patch preserves expected functional behavior.
Snyk DeepCode AI delivers its highest return on investment when treated as a tireless junior security engineer that drafts verified diffs on command, not an autonomous committer operating without peer review.