Cloud Agent Starter Skill
Use this file when you need to run or test the repo in Cursor Cloud. It is intentionally short and practical.Read this first
- Read
convex/_generated/ai/guidelines.mdbefore touching Convex code. - Check existing terminal sessions before starting long-running processes so you do not duplicate
bun run devorbun run convex:dev. - Use Bun for installs, dev servers, linting, and tests.
Repo-wide setup
Install and env
- Install dependencies with
bun install --frozen-lockfilewhennode_modulesis missing or stale. - When secrets are injected into the shell (Cursor Cloud) but
.env.localis missing, runbun run env:sync-local -- --devto materialize the file fromprocess.envwithout logging secret values. Use--forceto overwrite an existing file, or--dry-runto preview which keys would be filled. - Start Convex with
bun run convex:dev. This is the normal way to generate or refreshNEXT_PUBLIC_CONVEX_URLin.env.local. - Start Next.js with
bun run dev. bun run devusesscripts/next-dev-with-fallback.ts, so the app may start on port3000through3010. Read the server output to see which port won.- If both servers are not already running,
bun run dev:allstarts Next + Convex together. Avoidbun run dev:reset; it uses a blanket process kill pattern that Cloud agents should not rely on.
Minimum .env.local checklist
Copy values from .env.example or from the task context. The most common values agents need are:
NEXT_PUBLIC_CONVEX_URLCONVEX_SITE_URLwhen HTTP actions need a non-default Convex hostNEXT_PUBLIC_APP_URLCONVEX_INTERNAL_SECRETENCRYPTION_KEYGHL_APP_CLIENT_IDGHL_APP_CLIENT_SECRETGHL_APP_SSO_KEYGHL_API_DOMAINGHL_ADMIN_LOCATION_IDCRON_SECRET
Fast smoke checks
curl http://127.0.0.1:<port>/api/auth/statusshould return JSON, even when unauthenticated.- If
/does not redirect where you expect in dev, setDEV_DEFAULT_LOCATION_IDbecauseapp/page.tsxandproxy.tsboth use it for localhost redirects. - No Next.js route uses Clerk, so the Clerk keys are not needed in
.env.local.CLERK_JWT_ISSUER_DOMAINis still required as a Convex env var (bunx convex env set CLERK_JWT_ISSUER_DOMAIN <value>) becauseconvex/auth.config.tsreads it; without it the Convex push fails.
Codebase areas
1. Main app and admin (app/(main), app/admin, components/contact, components/funding-queue)
Login and local bypass
- These areas normally expect a Lead Built / GHL session.
- For localhost-only Cloud testing without a real iframe session, set:
ALLOW_LOCAL_DEV_AUTH_BYPASS=trueDEV_DEFAULT_LOCATION_ID=<real location id>
- The bypass only works in development and only for localhost requests. It is implemented in
components/contact/contactLocalDevAuth.ts. useAuthfirst checks/api/auth/status, then triesPOST /api/auth/location-session, and redirects to/setup-requiredwhen the location is missing an installation.
Start and verify
- Open
/dashboard?location_id=<location>for the main app. - Open
/admin/metrics?locationId=<location>or another admin route if you are testing admin-only behavior. - If the app redirects unexpectedly, inspect
proxy.tsbefore changing auth code.
Targeted test workflow
- Auth and routing:
bun test tests/adminAuth.test.ts tests/adminLocation360Auth.test.ts tests/contactRedirectDomain.test.ts
- Processing and funding queue:
bun test tests/processingQueueFilters.test.ts tests/internalContactProcessingStatus.test.ts tests/fundingPlanAutosave.test.ts tests/fundingQueueBulkActions.test.ts
- Credit reports and underwriting:
bun test tests/adminCreditReportQuery.test.ts tests/creditReportHistory.test.ts tests/underwriting.test.ts tests/stitchCreditReportAccountFiltering.test.ts
2. API routes and webhooks (app/api/**, lib/auth, lib/utils, proxy.ts)
Practical workflow
- Use
curlfor routes that do not require a browser. GET /api/auth/statusis the easiest reachability check.POST /api/auth/location-sessionis the main session bootstrap path when alocation_idis available but no stored session exists yet.- Many API routes are blocked by the proxy unless the request has a valid session, an allowed origin, or is listed in
EXEMPT_PATHSinsideproxy.ts. - Admin endpoints also validate origin + installation +
GHL_ADMIN_LOCATION_IDinlib/utils/admin-auth.ts.
Targeted test workflow
- Auth and impersonation:
bun test tests/adminAuth.test.ts tests/impersonationGuards.test.ts
- Credit pull and history paths:
bun test tests/creditPullContactSync.test.ts tests/creditPullNormalization.test.ts tests/creditReportErrors.test.ts tests/creditReportDownload.test.ts
- Webhook-style behavior:
bun test tests/appointmentStatus.test.ts
3. Partner portal — removed (convex/auth.config.ts only)
- The Clerk-authenticated partner portal UI was removed in July 2026. There are no
/partner-portalroutes, components, or API endpoints, andproxy.tsno longer runs Clerk middleware. Seedocs/archive/partner-portal.md. - Its Convex backend (
partnerOrganizations,partnerReferralLinks,partnerEarnings) andconvex/auth.config.tsare retained.CLERK_JWT_ISSUER_DOMAINmust still be set in Convex (bunx convex env set CLERK_JWT_ISSUER_DOMAIN <value>) or the Convex push fails at module-analysis time. - Do not confuse this with the operator-facing Partner module at
/partners, which is fully live.
4. Convex backend and data scripts (convex/**, scripts/**)
Practical workflow
- Keep
bun run convex:devrunning while editing Convex functions. convex/auth.config.tsstill readsCLERK_JWT_ISSUER_DOMAINfrom the Convex deployment; if a push fails at module-analysis time, check that value first.scripts/seed-cards.tsreads.env.localdirectly and requiresNEXT_PUBLIC_CONVEX_URLplus a CSV path argument.scripts/seed-demo-data.tsloads.env.localwithdotenvand uses:SEED_LOCATION_ID(required — the script exits with instructions if it is missing, because seeding and--cleanwrite to and delete from the real CRM location you name)SEED_ADMIN_EMAIL(optional)
Targeted test workflow
- For shared Convex/UI behavior that already has Bun coverage:
bun test tests/underwriting.test.ts tests/processingSubmissionStatusBackfill.test.ts tests/operatorInvoicesReadOnly.test.ts
- For script runs:
npx tsx scripts/seed-cards.ts ./data/cards.csv#seed-cards.tsexpectstsx, notbun runSEED_LOCATION_ID=<locationId> bun run scripts/seed-demo-data.ts(or set it in.env.local)
- Prefer seeding only when the task needs realistic data; otherwise stick to targeted tests.
Common gotchas
- There is no obvious central runtime feature flag system in the repo. The most useful local testing toggle is the auth bypass pair
ALLOW_LOCAL_DEV_AUTH_BYPASS=trueplusDEV_DEFAULT_LOCATION_ID=<id>. - Every remaining route expects GHL/Lead Built context. The Clerk-authenticated partner portal was the one exception and it no longer exists.
- The app may not use port
3000; read the dev server output before curling or opening localhost URLs. - If a task only changes docs or small non-runtime strings, do not start the full app just to look busy. Validate the affected commands, file references, and nearby checks instead.
Default quality gate
Use this when the area-specific tests are unclear or when you touched shared code:bunx tsc --noEmitbun run lintbun test
How to update this skill
When you discover a useful testing trick, setup shortcut, or runbook fact:- Add it to the relevant codebase-area section instead of creating a random notes dump.
- Prefer exact commands, routes, env vars, or file paths over prose.
- Delete stale steps when the repo changes; do not leave multiple conflicting workflows.
- If the new knowledge is required on every task, also add a one-line pointer in
AGENTS.mdandCLAUDE.md.

