JSPM

  • Created
  • Published
  • Downloads 870
  • Score
    100M100P100Q104882F
  • License MIT

Tanagram - Catch sloppy code before it ships

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tanagram/cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Tanagram CLI

    A lightweight Go CLI that enforces TQL policies on AI code changes via Claude Code hooks.

    Quick Start

    # 1. Install globally via npm
    npm install -g @tanagram/cli
    
    # 2. Login to Tanagram
    tanagram login
    
    # 3. Sync policies from your Tanagram account
    tanagram sync-policies
    
    # 4. Run via Claude Code Stop hook (automatic on first run)
    tanagram

    Installation

    Requirements:

    • Node.js >= 14.0.0
    • Tanagram account with TQL policies configured

    The CLI is written in Go but distributed via npm for easier installation. During installation, npm automatically downloads the Go compiler and builds the binary for your platform.

    Usage

    # Evaluate changes against TQL policies (run via Claude Code Stop hook)
    tanagram
    # or explicitly:
    tanagram run
    
    # Login to Tanagram
    tanagram login
    
    # Logout
    tanagram logout
    
    # Sync cloud policies from Tanagram
    tanagram sync-policies
    
    # View policies for current repository
    tanagram list
    
    # Show help
    tanagram help

    Commands

    • run (default) - Evaluate changed lines against TQL policies
    • login - Authenticate with Tanagram
    • logout - Sign out and remove stored credentials
    • sync-policies - Sync cloud policies from Tanagram
    • list - Show policies for current repository
    • help - Show usage information

    Claude Code Hook

    The CLI runs as a Claude Code Stop hook to evaluate changes after each edit.

    Automatic setup: The hook is automatically configured in ~/.claude/settings.json on first run.

    Manual setup: Add this to your ~/.claude/settings.json:

    {
      "hooks": {
        "Stop": [
          {
            "hooks": [
              {
                "type": "command",
                "command": "tanagram"
              }
            ]
          }
        ]
      }
    }

    How It Works

    1. Claude Code makes edits to files
    2. Stop hook fires, running tanagram run
    3. CLI reads transcript from Claude Code stdin
    4. Parses Write/Edit operations to find changed lines
    5. Evaluates changed lines against TQL policies
    6. If violations found, outputs to stderr
    7. Claude sees the violations and self-corrects

    Exit Codes

    • 0 - No violations found
    • 2 - Violations found (triggers Claude Code automatic fix behavior)

    Tanagram Web Integration

    Manage policies at tanagram.ai and enforce them locally:

    # Connect your account
    tanagram login
    
    # Sync policies
    tanagram sync-policies
    
    # View policies
    tanagram list

    For on-prem installations, set the TANAGRAM_WEB_HOSTNAME environment variable:

    export TANAGRAM_WEB_HOSTNAME=https://yourcompany.tanagram.ai
    tanagram login

    Built by @fluttermatt and the Tanagram team.