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_SECRETNEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEYCLERK_JWT_ISSUER_DOMAIN
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. - If Convex-authenticated partner portal work is involved, remember that
CLERK_JWT_ISSUER_DOMAINmust also be set in Convex withbunx convex env set CLERK_JWT_ISSUER_DOMAIN <value>.
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 (app/partner-portal, components/partner-portal, convex/auth.config.ts)
Login and env
- Partner portal auth is Clerk-based, not GHL SSO.
- Required Next env:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYCLERK_SECRET_KEY
- Required Convex auth env:
CLERK_JWT_ISSUER_DOMAINin.env.localCLERK_JWT_ISSUER_DOMAINin Convex viabunx convex env set CLERK_JWT_ISSUER_DOMAIN <value>
- Public auth routes are
/partner-portal/sign-inand/partner-portal/sign-up. proxy.tsskips Lead Built auth for partner portal routes and lets Clerk handle them.
Targeted test workflow
- Manual check:
- Start
bun run convex:devandbun run dev - Visit
/partner-portal/sign-in - Confirm sign-in renders instead of redirecting to the main-app SSO flow
- Start
- Automated checks:
- There is no clearly named partner-portal-only Bun test file today, so use the shared repo gate after portal changes:
bunx tsc --noEmitbun run lintbun test
- There is no clearly named partner-portal-only Bun test file today, so use the shared repo gate after portal changes:
4. Convex backend and data scripts (convex/**, scripts/**)
Practical workflow
- Keep
bun run convex:devrunning while editing Convex functions. - If auth behavior changed for the partner portal, re-check
convex/auth.config.tsand the Convex env value forCLERK_JWT_ISSUER_DOMAIN. scripts/seed-cards.tsreads.env.localdirectly and requiresNEXT_PUBLIC_CONVEX_URLplus a CSV path argument.scripts/seed-demo-data.tsloads.env.localwithdotenvand can use:SEED_LOCATION_IDSEED_ADMIN_EMAIL
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 runbun run scripts/seed-demo-data.ts
- 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>. - The main app and admin expect GHL/Lead Built context; the partner portal does not.
- 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.

