new-agent-endpoint

Scaffolds Vercel serverless API endpoints following the repo's _auth.js convention and checklist.

Updated Mar 3, 2026
One-click install
npx skills add https://github.com/dylanpoler-a11y/poler-team-website --skill new-agent-endpoint-dylanpoler-a11y
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: new-agent-endpoint
Source: https://github.com/dylanpoler-a11y/poler-team-website/tree/main/.claude/skills/new-agent-endpoint
Command: npx skills add https://github.com/dylanpoler-a11y/poler-team-website --skill new-agent-endpoint-dylanpoler-a11y

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding a new endpoint under api/ in this repo has repeatedly caused production bugs: field-shape mismatches between callers and endpoints silently dropped lead data, and positional token reads broke endpoints during credential rotation. This Skill provides the exact template and mandatory checklist that prevent both bug classes. ## Core Features & Use Cases - Endpoint Template: A zero-dependency ES-module Vercel edge function with CORS preflight handling, JSON helpers, and authorize() gating built in. - Mandatory Checklist: Eight enforced rules covering auth-first ordering, caller field-name diffing, SAMMY_ENGINE_TOKEN resolution, input allowlist validation, CRM note routing, MCP tool registration, env var recording, and CLAUDE.md updates. - Use Case: When asked to add an endpoint like api/agent/send-followup.js, the Skill produces code that matches every caller's field names, resolves the engine token correctly, and registers the tool in both hosted and local MCP servers. ## Quick Start Ask the agent to create a new endpoint under api/agent/ for a specific task and have it follow the new-agent-endpoint checklist.

Frequently Asked Questions about new-agent-endpoint

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new Vercel serverless endpoint to this repo?

Create an ES-module file under api/ or api/agent/ exporting a default handler with edge runtime config. Call authorize(req, body) first and return 401 on failure, handle OPTIONS preflight for browser callers, and follow the eight-item checklist before committing.

How do I resolve the engine token for Sammy/Railway API calls?

Use process.env.SAMMY_ENGINE_TOKEN first, falling back to (process.env.AGENT_API_TOKEN || '').split(',')[0]. A bare positional read of AGENT_API_TOKEN without the SAMMY_ENGINE_TOKEN check broke three endpoints during the 2026-07-17 credential rotation.

Why does the browser report 'Failed to fetch' on my new endpoint?

A JSON POST from the CRM triggers a CORS preflight because the CRM runs on a different origin. Your endpoint must answer OPTIONS with Access-Control-Allow-Origin, Methods, and Headers, and echo the origin header on every response.

How do I make a new endpoint callable from claude.ai?

Add a named tool for it in both api/mcp.js (hosted) and ~/poler-team-mcp/index.js (local), since claude.ai discovers tools by name. A new parameter on an existing tool is not discoverable, and local MCP requires a Claude Code restart.

Why did my endpoint silently drop lead name fields?

The caller and endpoint used different field names, such as firstName/lastName versus first/last. Grep api/mcp.js, the local MCP index, and client JS for call sites and match field names exactly, or accept both shapes like save-lead.js does.