CLI
Examples

CLI Examples

Practical examples of using the DevTeam CLI in real-world scenarios.

CI/CD Integration

PR Review in GitHub Actions

.github/workflows/pr-review.yml
name: AI Code Review
on:
  pull_request:
    types: [opened, synchronize]
 
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Install DevTeam CLI
        run: npm install -g devteam-orchestrator-cli
 
      - name: Run AI Code Review
        env:
          DEVTEAM_API_KEY: ${{ secrets.DEVTEAM_API_KEY }}
          DEVTEAM_API_URL: https://devteam.marsala.dev
        run: |
          DIFF=$(git diff origin/main...HEAD)
          RESULT=$(devteam run "Review this code diff for:
            1. Security vulnerabilities
            2. Performance issues
            3. Best practice violations
            Provide specific line-level feedback.
 
            Diff:
            $DIFF" \
            --model sonnet \
            --system "You are a senior code reviewer. Be specific and constructive." \
            --wait \
            -o json)
 
          echo "$RESULT" | jq -r '.output' > review.md
 
      - name: Post Review Comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = fs.readFileSync('review.md', 'utf8');
            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `## AI Code Review\n\n${review}`
            });

Deploy Template on Merge

.github/workflows/post-deploy.yml
name: Post-Deploy Analysis
on:
  push:
    branches: [main]
 
jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - name: Run Post-Deploy Template
        env:
          DEVTEAM_API_KEY: ${{ secrets.DEVTEAM_API_KEY }}
        run: |
          devteam templates deploy post-deploy-check-v1 \
            --input commit_sha=${{ github.sha }} \
            --input repo=${{ github.repository }} \
            --wait \
            -o json > result.json

Batch Processing

Process a Directory of Documents

batch-summarize.sh
#!/bin/bash
# Summarize all .txt files in a directory
 
INPUT_DIR="./documents"
OUTPUT_DIR="./summaries"
mkdir -p "$OUTPUT_DIR"
 
for file in "$INPUT_DIR"/*.txt; do
  filename=$(basename "$file" .txt)
  echo "Processing: $filename"
 
  devteam run "Summarize this document in 3 paragraphs. Be comprehensive." \
    --context document=@"$file" \
    --model sonnet \
    --tags batch,summarization \
    --wait \
    -o json | jq -r '.output' > "$OUTPUT_DIR/${filename}_summary.txt"
 
  echo "  Saved: ${filename}_summary.txt"
done
 
echo "Done. Processed $(ls "$OUTPUT_DIR" | wc -l) files."

Parallel Batch with xargs

# Process 5 files in parallel
ls documents/*.txt | xargs -P 5 -I {} bash -c '
  FILE="{}"
  NAME=$(basename "$FILE" .txt)
  devteam run "Summarize: $(cat "$FILE")" --model haiku --wait -o json \
    | jq -r ".output" > "summaries/${NAME}.txt"
  echo "Done: $NAME"
'

Interactive Approval Workflow

Poll and Approve

approve-pending.sh
#!/bin/bash
# Interactive approval workflow
 
while true; do
  PENDING=$(devteam approvals list -o json | jq -r '.total')
 
  if [ "$PENDING" -eq 0 ]; then
    echo "No pending approvals. Waiting..."
    sleep 10
    continue
  fi
 
  echo "=== $PENDING Pending Approvals ==="
 
  devteam approvals list -o json | jq -r '.data[] | "[\(.taskId)] \(.summary) (confidence: \(.confidence))"'
 
  echo ""
  read -p "Enter task ID to review (or 'skip'): " TASK_ID
 
  if [ "$TASK_ID" = "skip" ]; then
    continue
  fi
 
  devteam status "$TASK_ID" -o json | jq -r '.output'
 
  echo ""
  read -p "Approve (a), Reject (r), or Skip (s)? " ACTION
 
  case $ACTION in
    a)
      read -p "Comment (optional): " COMMENT
      devteam approvals approve "$TASK_ID" --comment "$COMMENT"
      echo "Approved."
      ;;
    r)
      read -p "Reason: " REASON
      read -p "Retry with feedback? (y/n): " RETRY
      if [ "$RETRY" = "y" ]; then
        devteam approvals reject "$TASK_ID" --reason "$REASON" --retry
      else
        devteam approvals reject "$TASK_ID" --reason "$REASON"
      fi
      echo "Rejected."
      ;;
    *)
      echo "Skipped."
      ;;
  esac
done

Template Deployment Scripts

Legal Contract Pipeline

#!/bin/bash
# Deploy contract review template with full options
 
CONTRACT_FILE="$1"
JURISDICTION="${2:-New York}"
 
if [ -z "$CONTRACT_FILE" ]; then
  echo "Usage: $0 <contract-file> [jurisdiction]"
  exit 1
fi
 
echo "Deploying contract review..."
echo "  File: $CONTRACT_FILE"
echo "  Jurisdiction: $JURISDICTION"
 
RESULT=$(devteam templates deploy contract-review-v1 \
  --input contract=@"$CONTRACT_FILE" \
  --input jurisdiction="$JURISDICTION" \
  --input reviewDepth="comprehensive" \
  --model-override analyze-risk=opus \
  --wait \
  --timeout 300 \
  -o json)
 
echo ""
echo "=== Contract Review Results ==="
echo "$RESULT" | jq -r '.steps["generate-report"].output'
 
COST=$(echo "$RESULT" | jq -r '.usage.totalCost')
echo ""
echo "Total cost: \$$COST"

Monitoring Scripts

Worker Health Dashboard

worker-dashboard.sh
#!/bin/bash
# Simple terminal dashboard for worker status
 
watch -n 5 '
echo "=== DevTeam Worker Status ==="
echo ""
devteam status workers -o table 2>/dev/null || echo "Could not fetch worker status"
echo ""
echo "=== Queue Depths ==="
devteam status queues -o table 2>/dev/null || echo "Could not fetch queue status"
echo ""
echo "=== Recent Tasks ==="
devteam status recent --limit 10 -o table 2>/dev/null || echo "Could not fetch recent tasks"
'

Alert on Failed Tasks

alert-failures.sh
#!/bin/bash
# Check for failed tasks and send notifications
 
FAILED=$(devteam status recent \
  --status failed \
  --since "1 hour ago" \
  -o json | jq -r '.total')
 
if [ "$FAILED" -gt 0 ]; then
  echo "ALERT: $FAILED tasks failed in the last hour"
 
  devteam status recent --status failed --since "1 hour ago" -o json \
    | jq -r '.data[] | "  [\(.id)] \(.error)"'
 
  # Send to monitoring webhook
  curl -X POST "$SLACK_WEBHOOK" \
    -H 'Content-Type: application/json' \
    -d "{\"text\": \"$FAILED DevTeam tasks failed in the last hour.\"}"
fi

For production monitoring, consider using the WebSocket API for real-time event-driven alerts rather than polling scripts.

Piping and Composition

# Chain commands with jq
devteam run "List 5 startup ideas for AI" --model haiku --wait -o json \
  | jq -r '.output' \
  | devteam run "Pick the best idea and write a 1-page pitch" --model sonnet --wait
 
# Use output as input to another tool
devteam run "Generate a SQL schema for a blog" --model sonnet --wait -o json \
  | jq -r '.output' > schema.sql && psql < schema.sql
 
# Compare models
for model in sonnet opus haiku gpt4o; do
  echo "=== $model ==="
  devteam run "Explain the Riemann hypothesis in 2 sentences" \
    --model $model --wait -o json | jq -r '.output'
  echo ""
done

Next Steps