Skip to content
CodeLayersCodeLayers

GitHub Action

The CodeLayers GitHub Action (codelayers-ai/codelayers-action@v1) automatically generates a 3D code visualization for every PR and posts a comment with the interactive share link.

Free for open source. No account required.


Quick Start (Open Source)

# .github/workflows/codelayers.yml
name: CodeLayers
on:
  pull_request:

jobs:
  visualize:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: codelayers-ai/codelayers-action@v1

No API key. No sign-up. Open a PR and the action posts a comment with a link to the 3D visualization.


Private Repos

For private repositories, add an API key:

      - uses: codelayers-ai/codelayers-action@v1
        with:
          api_key: ${'$'}{{ secrets.CODELAYERS_API_KEY }}

Setup

  1. Create an API key:
brew install codelayers-ai/tap/codelayers
codelayers login
codelayers api-keys create "GitHub CI"

Save the key immediately — it won't be shown again. See API Keys for details.

  1. Add the secret — Go to your repo on GitHub: SettingsSecrets and variablesActionsNew repository secret. Name: CODELAYERS_API_KEY.

  2. Add the workflow — Create .github/workflows/codelayers.yml with the YAML above.

  3. Open a PR — The action runs automatically and posts a comment with the 3D visualization link.

Requires a CodeLayers Pro subscription.


Inputs

InputRequiredDefaultDescription
api_keyYesCodeLayers API key
base_branchNoauto-detect from PRBase branch to compare against
expires_daysNo7Days until the share link expires
max_viewsNounlimitedMaximum number of views
commentNotruePost/update a PR comment with the link
link_to_prNotrueLink share to GitHub repo/PR metadata

Outputs

Use outputs in subsequent workflow steps:

OutputDescription
share_urlFull share URL with encryption key
share_idShare ID (UUID)
node_countTotal nodes in the graph
file_countNumber of file nodes
changed_file_countFiles changed in the PR
blast_radius_countTotal files affected by changes (via dependency BFS)

Using Outputs

- uses: codelayers-ai/codelayers-action@v1
  id: codelayers
  with:
    api_key: ${'$'}{{ secrets.CODELAYERS_API_KEY }}
    comment: false  # disable auto-comment

- name: Custom step
  run: |
    echo "Share: ${'$'}{{ steps.codelayers.outputs.share_url }}"
    echo "Changed: ${'$'}{{ steps.codelayers.outputs.changed_file_count }}"
    echo "Blast radius: ${'$'}{{ steps.codelayers.outputs.blast_radius_count }}"

What Gets Posted

The action posts (or updates) a PR comment like this:

## CodeLayers — PR Visualization

> **12 files changed** · **47 files affected** by blast radius
> across **582 files** · **45,230 LOC** · Rust (312) · TypeScript (156) · Swift (89)

### Open 3D Visualization →

Expires in 7 days · Updated Feb 11, 2026 19:42 UTC · Generated by CodeLayers Action

The comment is idempotent — pushing new commits to the PR updates the existing comment rather than creating a new one.


How It Works Under the Hood

  1. Checks out your code in the GitHub Action runner
  2. Runs codelayers share with --base origin/<pr-base> and --head HEAD
  3. Tree-sitter parses the entire codebase (11 languages)
  4. Builds the dependency graph with metrics
  5. Computes git diff between base and head:
    • Identifies changed files
    • Computes per-file lines added/deleted
    • Annotates graph nodes with diff metadata
    • Computes blast radius (BFS through reverse import edges)
  6. Encrypts everything with a random AES-256 key
  7. Uploads encrypted blob (server never sees your code)
  8. Posts PR comment with the link (key is in the URL fragment)

Important: fetch-depth: 0

The actions/checkout step must use fetch-depth: 0 (full clone) so the CLI can compute the diff between base and head branches. Without full history, the diff computation will fail.


Monorepo Support

The action works with monorepos — it parses the entire repository and highlights only the files changed in the PR. The blast radius shows how changes ripple through the dependency graph across the whole repo.