Skip to content

Latest commit

 

History

History
139 lines (104 loc) · 8.79 KB

skill.md

File metadata and controls

139 lines (104 loc) · 8.79 KB
name predev
description Work with pre.dev from code or an agent. Run browser tasks that read or act on websites, call hundreds of AI models through one OpenAI-compatible API, generate software specifications, take Stripe payments in an app built on pre.dev, and use the pre.dev coding agent from a terminal. Use when a task mentions pre.dev, api.pre.dev, PREDEV_API_KEY, or a project built on pre.dev.
license Proprietary
compatibility Needs a pre.dev API key in PREDEV_API_KEY. Examples use curl, jq, and the OpenAI SDK for Node.js or Python.
metadata
author version
pre.dev
2.0

pre.dev

pre.dev is the Long Horizon Coding Agent: it plans, builds, verifies and ships software in a web workspace or a terminal. pre.dev Labs also builds and sells verified RL coding tasks to frontier AI labs for model post-training: https://docs.pre.dev/labs/overview.md. Its APIs are also usable on their own: Browser Agents, the AI Gateway (hundreds of models from every major lab through one OpenAI-compatible API), specification generation, and payments for apps built on pre.dev.

Authenticate

  • One API key per workspace, pdk_…. Copy it from Integrations → Built-in in the pre.dev dashboard. Projects built on pre.dev already have it as PREDEV_API_KEY.
  • Send it as Authorization: Bearer $PREDEV_API_KEY. x-api-key also works.
  • Keep it on a server. It spends the workspace's credits.

Pick an interface

Goal Use
Read data from a website, or act on one POST https://api.pre.dev/browser-agent
Call a model (AI Gateway): chat, embeddings, images, video, speech https://api.pre.dev/v1 with an OpenAI or Anthropic SDK
Plan software before building it POST https://api.pre.dev/fast-spec or /deep-spec, or the fast_spec MCP tool
Give an agent pre.dev tools, plus the user's own Chrome, profiles, and logins The pre.dev MCP server: npx -y @predotdev/mcp setup signs in to pre.dev and adds it to every coding agent on the Mac (run it with a 10 minute timeout and tell the user what to click). Without Node.js, the hosted server https://api.pre.dev/mcp has every tool except the Chrome ones. See https://docs.pre.dev/browser-agents/local.md
Follow what the user told pre.dev to remember, or save a lasting preference they state The MCP tools memory_list (call it before you answer or write anything), memory_search, memory_remember, and memory_forget. See https://docs.pre.dev/coding-agent/memory.md
Take payments in an app built on pre.dev The Stripe SDK, pointed at STRIPE_API_HOST
Build or change code The coding agent, on the web or in the CLI; predev run with PREDEV_API_KEY runs one task unattended
Search these docs Docs MCP server https://docs.pre.dev/mcp (no key)

Browser tasks and AI calls work on every plan, Free included: a Free personal account can spend 2 credits on browser tasks, and a Free workspace 5 credits on AI calls, before it needs a plan. Specifications and the MCP server need Premium, Pro, Team or Enterprise; Plus and team workspaces without a plan get 3 trial specifications. The MCP memory tools work on every plan, Free included.

Recipes

1. Browser task over REST

ID=$(curl -s https://api.pre.dev/browser-agent \
  -H "Authorization: Bearer $PREDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"async": true, "tasks": [{"url": "https://example.com", "instruction": "Return the page heading", "output": {"type": "object", "properties": {"heading": {"type": "string"}}, "required": ["heading"]}}]}' | jq -r .id)

while :; do
  RUN=$(curl -s "https://api.pre.dev/browser-agent/$ID" -H "Authorization: Bearer $PREDEV_API_KEY")
  case $(echo "$RUN" | jq -r .status) in completed|failed) break ;; esac
  sleep 5
done
echo "$RUN" | jq '.results[] | {status, data, error}'

The batch status is lowercase (processing, completed, failed). Each task has its own uppercase status; read data only when it is SUCCESS.

2. AI call with the OpenAI SDK

import os
from openai import OpenAI

client = OpenAI(base_url="https://api.pre.dev/v1", api_key=os.environ["PREDEV_API_KEY"])
reply = client.chat.completions.create(
    model="deepseek/deepseek-v4.1-flash-1017",
    messages=[{"role": "user", "content": "Write a one-line welcome message."}],
)
print(reply.choices[0].message.content)

Use model ids exactly as GET https://api.pre.dev/v1/models lists them. Each call is charged in credits from its metered cost; x-predev-credits-charged reports the charge.

3. Specification over MCP, headless

claude mcp add --scope user predev -e PREDEV_API_KEY="$PREDEV_API_KEY" -- npx -y @predotdev/mcp

This local server (Node.js 22 or later) carries every pre.dev tool plus chrome_* tools for the user's own Chrome. Without Node.js, add the hosted server instead: claude mcp add --transport http predev https://api.pre.dev/mcp --header "Authorization: Bearer $PREDEV_API_KEY".

Then call fast_spec with executiveSummary (what to build, at least 10 characters) and optional existingContext and docURLs. If it returns before the spec is done, poll get_spec with the spec id every few seconds until the status is completed or failed. get_spec and list_specs use no credits. Interactive clients can add the hosted URL without the header and sign in with OAuth.

4. Payments in an app built on pre.dev

The project's environment already holds STRIPE_SECRET_KEY (a project-tagged pre.dev key) and STRIPE_API_HOST. Point the Stripe SDK at that host and use Stripe as usual, from a server route:

import Stripe from 'stripe';

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!, {
  host: process.env.STRIPE_API_HOST,
  protocol: (process.env.STRIPE_API_PROTOCOL as 'https' | 'http') || 'https',
  ...(process.env.STRIPE_API_PORT ? { port: Number(process.env.STRIPE_API_PORT) } : {}),
});

export async function createCheckout(priceId: string, origin: string) {
  const session = await stripe.checkout.sessions.create({
    mode: 'payment',
    line_items: [{ price: priceId, quantity: 1 }],
    success_url: `${origin}/thanks`,
    cancel_url: `${origin}/cart`,
  });
  return session.url;
}

Payments run in Stripe test mode while you build (card 4242 4242 4242 4242). The preview runs the app in a frame, so open Checkout in a new tab when framed. Stripe events are delivered to /api/stripe/webhook, signed with STRIPE_WEBHOOK_SECRET.

5. Coding agent in a repository, unattended

curl -fsSL https://pre.dev/install | PREDEV_NO_AUTORUN=1 bash
export PREDEV_API_KEY="pdk_..."
cd path/to/repo
~/.predev/bin/predev run "add input validation to the signup form with a test"

predev run sends one request to the agent in the current directory, prints one [predev] line per step and then the agent's final message, and exits: 0 finished, 1 failed or stopped, 2 not signed in or key rejected (do not retry a 2 with the same key). With no prompt argument it reads the prompt from stdin. If the output ends with a question, answer it with another predev run in the same directory. Set the key in the environment, not in a .env file; a saved browser login wins over it, so run predev logout first on a machine where someone signed in. In CI, set CI=true where the service does not (Jenkins, Azure Pipelines, AWS CodeBuild), and use predev run --new for parallel jobs on one checkout path. Review the changes with git diff. The CLI runs on macOS and Linux. See Run one task without the app.

Rules for long-running work

  • Save every id (id, specId) as soon as you get it. A timeout or a dropped stream does not mean the work stopped: fetch it by id before submitting again.
  • Poll at a bounded interval, such as every 5 seconds, and stop on a terminal status. Do not infer completion from array lengths or counters.
  • Send Idempotency-Key on browser submissions you might retry.
  • AI Gateway errors use the OpenAI error shape; branch on error.code (insufficient_credits, subscription_required, rate_limit_exceeded) and honor Retry-After.

Costs

  • Browser tasks: each task is charged a 0.1-credit floor at submission, and a failed task keeps it; successful tasks can cost more.
  • AI calls: charged per call from the model's metered cost. Credit prices per model are in GET /v1/models; catalog reads are free.
  • Specifications: variable, based on the work.

References