HUB
Sign inSign up

shinr3x/cbx-tools:latest

Multi-platform
Manifest digest

sha256:ceaebdb5796655cd962e5210cab7997d5d7815482a21dc5fa538ec44446eec79

Last pushed

6 days by shinr3x

Type

Sandbox Kit

Manifest digest

sha256:ceaebdb5796655cd962e5210cab7997d5d7815482a21dc5fa538ec44446eec79

yaml
schemaVersion: "3"
displayName: cbx tools
description: glab, Node LTS with npm and yarn, CodeGraph and the Figma MCP, with GitLab/GitHub credentials. With the default settings, the user's git rules for this sandbox (commit only when asked, never push, discard changes only when asked) are added to your context at session start and take precedence over the sandbox's default git guidance.
version: 1.1.4
kind: mixin
requires:
    - claude
capabilities:
    - type: com.docker.sandbox/network-policy@1
      config:
        runtime:
            allow:
                - gitlab.com:443
                - '*.gitlab.com:443'
                - github.com:443
                - api.github.com:443
                - codeload.github.com:443
                - raw.githubusercontent.com:443
                - objects.githubusercontent.com:443
                - registry.npmjs.org:443
                - registry.yarnpkg.com:443
                - repo.yarnpkg.com:443
                - mcp.figma.com:443
                - api.figma.com:443
                - www.figma.com:443
    - type: com.docker.sandbox/credential@1
      name: GitLab
      optional: true
      config:
        apiKey:
            inject:
                - domain: gitlab.com
                  format: '%s'
                  header: PRIVATE-TOKEN
            name: GITLAB_TOKEN
            proxyManaged: true
        phase: runtime
        service: gitlab
      description: GitLab API access for glab (sbx secret set gitlab)
    - type: com.docker.sandbox/credential@1
      name: GitHub
      optional: true
      config:
        apiKey:
            inject:
                - domain: api.github.com
                  format: Bearer %s
                  header: Authorization
                - domain: github.com
                  scheme: basic
                  username: x-access-token
            name: GH_TOKEN
            proxyManaged: true
        phase: runtime
        service: github
      description: GitHub access for gh and git over https (sbx secret set github)
    - type: com.docker.sandbox/volume@1
      config:
        path: /home/agent/.claude/projects
        size: 2g
    - type: com.docker.sandbox/lifecycle@1
      config:
        install:
            - command: chown agent:agent /home/agent/.claude/projects
              description: Give the agent the conversation volume
              user: "0"
            - command: |
                set -e
                [ "${{ kit.args.cbxGitGuard }}" = on ] || exit 0
                f=/home/agent/.claude/settings.json
                mkdir -p /home/agent/.claude
                [ -s "$f" ] || echo '{}' > "$f"
                jq --arg cmd "cat /usr/local/share/cbx/rules.md" '
                  .permissions.deny = ((((.permissions.deny // []) - ["Bash(git commit:*)"])
                    + ["Bash(git push:*)"]) | unique)
                  | .hooks.SessionStart = (
                      ((.hooks.SessionStart // []) | map(select(all(.hooks[]?; .command != $cmd))))
                      + [{"hooks": [{"type": "command", "command": $cmd, "timeout": 5}]}]
                    )' "$f" > "$f.cbx-tmp"
                mv "$f.cbx-tmp" "$f"
              description: Deny git push and load the user's git rules at session start (cbxGitGuard)
              user: agent
            - command: |
                set -e
                [ "${{ kit.args.cbxCodegraph }}" = on ] || exit 0
                f=/home/agent/.claude/settings.json
                mkdir -p /home/agent/.claude
                [ -s "$f" ] || echo '{}' > "$f"
                jq --arg cmd "/usr/local/bin/cbx-codegraph session" '
                  .hooks.SessionStart = (
                    ((.hooks.SessionStart // []) | map(select(all(.hooks[]?; .command != $cmd))))
                    + [{"hooks": [{"type": "command", "command": $cmd, "timeout": 10}]}]
                  )' "$f" > "$f.cbx-tmp"
                mv "$f.cbx-tmp" "$f"
              description: Register the CodeGraph SessionStart hook (cbxCodegraph)
              user: agent
            - command: |
                export PATH="$HOME/.local/bin:$HOME/.claude/local:/usr/local/bin:$PATH"
                command -v claude >/dev/null 2>&1 || exit 0
                claude mcp add --scope user --transport http figma https://mcp.figma.com/mcp >/dev/null 2>&1 || true
                claude mcp add --scope user codegraph -- codegraph serve --mcp >/dev/null 2>&1 || true
              description: Register the Figma and CodeGraph MCP servers
              user: agent
            - command: |
                f=/etc/sandbox-persistent.sh
                [ -f "$f" ] || exit 0
                grep -q 'cbx: CI_JOB_TOKEN' "$f" && exit 0
                printf '%s\n' \
                  '# cbx: CI_JOB_TOKEN mirrors the proxy-managed GITLAB_TOKEN sentinel' \
                  'if [ -n "${GITLAB_TOKEN:-}" ] && [ -z "${CI_JOB_TOKEN:-}" ]; then export CI_JOB_TOKEN="$GITLAB_TOKEN"; fi' \
                  >> "$f"
              description: Mirror GITLAB_TOKEN as CI_JOB_TOKEN
              user: "0"
        startup:
            - command: |
                export PATH="$HOME/.local/bin:$HOME/.claude/local:/usr/local/bin:$PATH"
                command -v claude >/dev/null 2>&1 || exit 0
                claude mcp add --scope user --transport http figma https://mcp.figma.com/mcp >/dev/null 2>&1 || true
                claude mcp add --scope user codegraph -- codegraph serve --mcp >/dev/null 2>&1 || true
              description: Register MCP servers (startup fallback)
              user: agent
            - background: true
              command: |
                [ "${{ kit.args.cbxCodegraph }}" = on ] || exit 0
                /usr/local/bin/cbx-codegraph boot "${WORKSPACE_DIR:-/nonexistent}"
              description: Build or sync the repository's CodeGraph index (background)
              env:
                - WORKSPACE_DIR
              user: agent
            - command: |
                [ -n "${HTTPS_PROXY:-}${HTTP_PROXY:-}" ] || exit 0
                printf 'httpProxy: "%s"\nhttpsProxy: "%s"\n' "${HTTP_PROXY:-}" "${HTTPS_PROXY:-}" > "$HOME/.yarnrc.yml"
              description: Point yarn at the sandbox proxy
              env:
                - HTTP_PROXY
                - HTTPS_PROXY
              user: agent
    - type: com.docker.sandbox/agent-context@1
      optional: true
      config:
        content: |
            ## cbx sandbox

            The user's git rules for this sandbox are added to your context at
            session start ("cbx: the user's rules for this sandbox"). They are
            also in /usr/local/share/cbx/rules.md; follow them.

            ### GitLab

            Use `glab` for GitLab; it is already authenticated (`GITLAB_TOKEN` is a
            sentinel the sandbox proxy replaces with the real token). When the user
            refers to an issue, read it first: `glab issue view <id> --comments`.
            Other useful commands: `glab issue list`, `glab mr list`,
            `glab mr view <id> --comments`.

            ### Tools

            Node LTS with npm and yarn, gh, ripgrep, jq, python3/uv. There is no C
            compiler; if an npm package needs to build native code, tell the user.

            MCP servers: `figma` (remote, OAuth on first use) and `codegraph`.

            ### CodeGraph

            `codegraph` is a pre-indexed code knowledge graph of the repository.
            Prefer it over `rg`/`fd` sweeps for structural questions (how does X
            work, who calls this, what imports this, what does changing this
            affect). Indexes are maintained for you: the repository's is built
            when the sandbox starts, worktrees under `.sbx/` get a copy that
            the server syncs to their branch, and a project without one gets it
            built in the background when your session starts (you will see a
            `cbx:` note if that is happening). The MCP server keeps the index in
            sync with your edits. You don't need to run `codegraph init` yourself;
            if a codegraph tool reports no project and there was no `cbx:` note,
            automatic indexing is turned off for this sandbox, so use rg/grep.
    - type: com.docker.sandbox/agent-context@2
      optional: true
      config:
        content: |
            ## cbx sandbox

            The user's git rules for this sandbox are added to your context at
            session start ("cbx: the user's rules for this sandbox"). They are
            also in /usr/local/share/cbx/rules.md; follow them.

            ### GitLab

            Use `glab` for GitLab; it is already authenticated (`GITLAB_TOKEN` is a
            sentinel the sandbox proxy replaces with the real token). When the user
            refers to an issue, read it first: `glab issue view <id> --comments`.
            Other useful commands: `glab issue list`, `glab mr list`,
            `glab mr view <id> --comments`.

            ### Tools

            Node LTS with npm and yarn, gh, ripgrep, jq, python3/uv. There is no C
            compiler; if an npm package needs to build native code, tell the user.

            MCP servers: `figma` (remote, OAuth on first use) and `codegraph`.

            ### CodeGraph

            `codegraph` is a pre-indexed code knowledge graph of the repository.
            Prefer it over `rg`/`fd` sweeps for structural questions (how does X
            work, who calls this, what imports this, what does changing this
            affect). Indexes are maintained for you: the repository's is built
            when the sandbox starts, worktrees under `.sbx/` get a copy that
            the server syncs to their branch, and a project without one gets it
            built in the background when your session starts (you will see a
            `cbx:` note if that is happening). The MCP server keeps the index in
            sync with your edits. You don't need to run `codegraph init` yourself;
            if a codegraph tool reports no project and there was no `cbx:` note,
            automatic indexing is turned off for this sandbox, so use rg/grep.
args:
    base:
        default: docker.io/sbx/claude:latest
        description: Image the overlay is built and checked against (the workload it lands on)
        pattern: ^[A-Za-z0-9./:@_-]+$
        buildArg: BASE
    cbxCodegraph:
        default: "on"
        description: '"on" keeps CodeGraph indexes current in the background: the mounted repository''s at every boot, and the project Claude starts in (e.g. a worktree) at session start if it has none.'
        enum:
            - "on"
            - "off"
    cbxGitGuard:
        default: "on"
        description: '"on" denies `git push` in Claude Code and gives Claude the user''s git rules (rules.md) at every session start, so the user reviews and pushes.'
        enum:
            - "on"
            - "off"