Skip to main content

Endpoint

POST/GET /api/claude-code-check Monitors the @anthropic-ai/claude-code npm package for new releases and sends formatted Discord notifications. Runs automatically via Vercel Cron every 30 minutes.

Trigger Methods

Vercel Cron (Automatic)

Configured in vercel.json:
{
  "crons": [{
    "path": "/api/claude-code-check",
    "schedule": "*/30 * * * *"
  }]
}
Runs every 30 minutes.

Manual Trigger

curl -X POST https://www.aitmpl.com/api/claude-code-check

Process Flow

  1. Fetch latest npm version from https://registry.npmjs.org/@anthropic-ai/claude-code/latest
  2. Check database if version already notified
  3. Fetch changelog from GitHub (CHANGELOG.md)
  4. Parse changes using Claude AI (via _parser-claude.js)
  5. Save to database (Neon PostgreSQL)
  6. Send Discord notification with formatted embed
  7. Update metadata tracking

Response

Success - New Version Detected

status
string
success
version
string
Version number detected (e.g., 1.2.3)
versionId
number
Database ID of the version record
changes
object
Summary of changes
changes.total
number
Total number of changes
changes.byType
object
Change counts by type (features, fixes, improvements, breaking)
discord
object
Discord notification status
discord.sent
boolean
Whether notification was sent
discord.status
number
HTTP status code from Discord webhook

Example Success Response

{
  "status": "success",
  "version": "1.2.3",
  "versionId": 42,
  "changes": {
    "total": 12,
    "byType": {
      "features": 5,
      "fixes": 4,
      "improvements": 3,
      "breaking": 0
    }
  },
  "discord": {
    "sent": true,
    "status": 200
  }
}

Success - Already Processed

status
string
already_processed
version
string
Version number
message
string
Explanation message

Example Already Processed Response

{
  "status": "already_processed",
  "version": "1.2.3",
  "message": "Version already notified to Discord"
}

Error Response (500)

error
string
Error type
message
string
Error message
details
string
Stack trace (development mode only)

Example Error Response

{
  "error": "Internal server error",
  "message": "Could not find version 1.2.3 in changelog",
  "details": "Error: Could not find version 1.2.3 in changelog\n    at parseVersionChangelog..."
}

Discord Notification Format

The endpoint sends a rich embed to Discord:
{
  "username": "Claude Code Monitor",
  "avatar_url": "https://raw.githubusercontent.com/anthropics/claude-code/main/assets/icon.png",
  "embeds": [{
    "title": "🚀 Claude Code 1.2.3 Released",
    "description": "A new version of Claude Code is available with **12 changes**!",
    "url": "https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#123",
    "color": 9067510,
    "fields": [
      {
        "name": "⚠️ Breaking Changes",
        "value": "• Removed deprecated API\n• Changed config format",
        "inline": false
      },
      {
        "name": "✨ New Features",
        "value": "• Added feature X\n• Added feature Y",
        "inline": false
      },
      {
        "name": "⚡ Improvements",
        "value": "• Improved performance\n• Better error messages",
        "inline": false
      },
      {
        "name": "🐛 Bug Fixes",
        "value": "• Fixed crash on startup\n• Fixed memory leak",
        "inline": false
      },
      {
        "name": "📦 Installation",
        "value": "```bash\nnpm install -g @anthropic-ai/claude-code@1.2.3\n```",
        "inline": false
      },
      {
        "name": "🔗 Links",
        "value": "[NPM Package](https://www.npmjs.com/package/@anthropic-ai/claude-code/v/1.2.3) • [Full Changelog](https://github.com/anthropics/claude-code/blob/main/CHANGELOG.md#123)",
        "inline": false
      }
    ],
    "footer": {
      "text": "Claude Code Changelog Monitor",
      "icon_url": "https://avatars.githubusercontent.com/u/100788936?s=200&v=4"
    },
    "timestamp": "2026-02-28T12:34:56.789Z"
  }]
}

Change Categories

  • ⚠️ Breaking Changes: Changes that break backwards compatibility
  • ✨ New Features: New functionality added
  • ⚡ Improvements: Enhancements to existing features
  • 🐛 Bug Fixes: Bug fixes and corrections
Only non-empty categories are included in the embed.

Database Schema

claude_code_versions

Stores version metadata:
CREATE TABLE claude_code_versions (
  id SERIAL PRIMARY KEY,
  version VARCHAR(20) NOT NULL UNIQUE,
  published_at TIMESTAMP NOT NULL,
  changelog_content TEXT,
  npm_url TEXT,
  github_url TEXT,
  discord_notified BOOLEAN DEFAULT false,
  discord_notification_sent_at TIMESTAMP,
  created_at TIMESTAMP DEFAULT NOW()
);

claude_code_changes

Stores individual changes:
CREATE TABLE claude_code_changes (
  id SERIAL PRIMARY KEY,
  version_id INTEGER REFERENCES claude_code_versions(id),
  change_type VARCHAR(50),
  description TEXT,
  category VARCHAR(100),
  created_at TIMESTAMP DEFAULT NOW()
);

discord_notifications_log

Logs Discord webhook calls:
CREATE TABLE discord_notifications_log (
  id SERIAL PRIMARY KEY,
  version_id INTEGER REFERENCES claude_code_versions(id),
  webhook_url TEXT,
  payload JSONB,
  response_status INTEGER,
  response_body TEXT,
  created_at TIMESTAMP DEFAULT NOW()
);

monitoring_metadata

Tracks monitoring statistics:
CREATE TABLE monitoring_metadata (
  id INTEGER PRIMARY KEY,
  last_check_at TIMESTAMP,
  last_version_found VARCHAR(20),
  check_count INTEGER DEFAULT 0,
  error_count INTEGER DEFAULT 0,
  last_error TEXT
);

External Dependencies

NPM Registry API

GET https://registry.npmjs.org/@anthropic-ai/claude-code/latest
Returns package metadata including:
  • version - Latest version number
  • time.modified - Publication timestamp

GitHub Changelog

GET https://raw.githubusercontent.com/anthropics/claude-code/main/CHANGELOG.md
Markdown changelog with version sections.

Discord Webhook

POST $DISCORD_WEBHOOK_URL_CHANGELOG
Sends formatted embeds to Discord channel.

Environment Variables

NEON_DATABASE_URL
string
required
PostgreSQL connection string for Neon databaseFormat: postgresql://user:pass@host/db?sslmode=require
DISCORD_WEBHOOK_URL_CHANGELOG
string
required
Discord webhook URL for changelog notificationsFallback: DISCORD_WEBHOOK_URL
NODE_ENV
string
Environment mode (development or production)Controls error detail visibility

CORS Support

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type
Preflight OPTIONS requests return 200 OK.

Error Handling

Errors are logged and tracked:
  1. Console logging: All errors logged with context
  2. Database tracking: monitoring_metadata table updated with error count and message
  3. Graceful degradation: Metadata update failures don’t crash the endpoint

Example Manual Trigger

# Trigger check
curl -X POST https://www.aitmpl.com/api/claude-code-check

# Response
{
  "status": "success",
  "version": "1.2.3",
  "versionId": 42,
  "changes": {
    "total": 12,
    "byType": {
      "features": 5,
      "fixes": 4,
      "improvements": 3,
      "breaking": 0
    }
  },
  "discord": {
    "sent": true,
    "status": 200
  }
}

Monitoring

Check monitoring health:
SELECT 
  last_check_at,
  last_version_found,
  check_count,
  error_count,
  last_error
FROM monitoring_metadata
WHERE id = 1;
View recent notifications:
SELECT 
  v.version,
  v.discord_notification_sent_at,
  l.response_status
FROM claude_code_versions v
LEFT JOIN discord_notifications_log l ON v.id = l.version_id
ORDER BY v.created_at DESC
LIMIT 10;

Notes

  • The endpoint is idempotent: duplicate checks for the same version return already_processed
  • Changelog content is truncated to 50,000 characters before storage
  • GitHub URL uses version without dots (e.g., #123 for version 1.2.3)
  • Parser uses Claude AI (via _parser-claude.js) for intelligent changelog parsing
  • All timestamps stored in ISO 8601 format with timezone
  • Webhook URL can be overridden with DISCORD_WEBHOOK_URL_CHANGELOG environment variable