agentleFS
matiasbattocchiamatiasbattocchia/open-bsp-api/CLAUDE.md

open-bsp-api

CLAUDE.md602 starsChanged 6 months agoUnlicenseView on GitHub

Open BSP API — a multi-tenant WhatsApp Business Platform integration built with Deno, Postgres, and Supabase Edge Functions. See README.md for full details. CI (.github/workflows/check.yml) runs: deno check only works from inside the package dir. Run cd supabase/functions && deno check . — NOT deno check <file> from the repo root. The import map lives in supabase/functions/deno.json (there is no root deno.json), so checking a file from the root resolves no bare specifiers and prints false Import "@supabase/supabase-js" not a…

  • Reads credentials

The file

We split this CLAUDE.md into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    deno check only works from inside the package dir: Run cd supabase/functions && deno check .

    line 18
  2. Very specific:

    Use the Supabase Management API to query function_logs (edge function stdout):

    line 47
  3. Very specific:

    Use the Supabase MCP server get_logs tool with service: "edge-function".

    line 67
  4. Distinctive:

    Commit — the user pushes and CI deploys automatically

    line 76
  5. Distinctive:

    Never modify applied migrations.

    line 92

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

Project overview

Open BSP API — a multi-tenant WhatsApp Business Platform integration built with Deno, Postgres, and Supabase Edge Functions. See README.md for full details.

Local checks must match CI (deno)

CI (.github/workflows/check.yml) runs:

deno fmt --check
cd supabase/functions && deno lint && deno check .
cd plugin && deno lint && deno check .

deno check only works from inside the package dir. Run cd supabase/functions && deno check . — NOT deno check <file> from the repo root. The import map lives in supabase/functions/deno.json (there is no root deno.json), so checking a file from the root resolves no bare specifiers and prints false Import "@supabase/supabase-js" not a dependency / "ky"/"zod"/"postgres" errors. These are an artifact of the wrong CWD, not real errors — don't treat them as a pre-existing baseline.

The .claude/settings.json PostToolUse hook runs deno check <file> without cd and swallows output with || true, so it always "passes" for functions files and verifies nothing there. Run the CI command yourself to actually verify.

deno fmt output is deno-version-dependent. The repo pins fmt config (lineWidth 80, semicolons, double quotes) but not the deno binary (CI uses v2.x). A different local deno can report spurious diffs on generated files (e.g. _shared/db_types.ts). Only format files you actually changed; never reformat the whole tree to chase a version-difference diff.

Debugging production edge functions

Timestamps

The current date/time is NOT reliably in the conversation context. When querying logs with time ranges (e.g., "last 12 hours"), always run date -u first to get the actual current UTC time. Do not guess or hardcode timestamps.

Querying stdout logs (console.log / console.error)

Use the Supabase Management API to query function_logs (edge function stdout):

ACCESS_TOKEN=$(cat ~/.supabase/access-token)
REF="nheelwshzbgenpavwhcy"

curl -s "https://api.supabase.com/v1/projects/${REF}/analytics/endpoints/logs.all" \
  -H "Authorization: Bearer ${ACCESS_TOKEN}" \
  -G \
  --data-urlencode "sql=select cast(timestamp as datetime) as ts, event_message from function_logs where regexp_contains(event_message, 'ERROR_KEYWORD') order by timestamp desc limit 10" \
  --data-urlencode "iso_timestamp_start=2026-04-10T00:00:00Z"

Available log tables: function_logs (stdout), function_edge_logs (HTTP-level), edge_logs, postgres_logs, auth_logs, storage_logs, realtime_logs. Uses BigQuery SQL syntax. Max 1000 rows per query. Always filter by timestamp.

Querying HTTP-level logs (status codes, execution time)

Use the Supabase MCP server get_logs tool with service: "edge-function". This returns invocation metadata (status code, execution time, function version) but not stdout content.

Applying database fixes

  1. Edit the schema file under supabase/schemas/
  2. Generate migration: npx supabase db diff -f <migration_name>
  3. Apply locally: npx supabase migration up --local (test before committing)
  4. Commit — the user pushes and CI deploys automatically

Application-level error logs

The public.logs table stores application-level errors written by edge functions (e.g., webhook errors from Meta). Query with:

SELECT level, category, message, metadata, created_at
FROM public.logs
WHERE level = 'error' AND created_at > now() - interval '24 hours'
ORDER BY created_at DESC;

Database migrations

  • Never modify applied migrations. Always create new ones.
  • Migrations are generated from schema diffs, not manually written: edit the schema files under supabase/schemas/, then run npx supabase db diff -f <migration_name>.
  • Never hand-create or hand-edit a migration except for a few exceptional cases that db diff can't produce:

    • Trim spurious revoke noise — db diff emits ~144 revoke ... from anon|authenticated|service_role lines every run (a migra/Supabase default-privilege artifact). Delete them; keep only your real changes.
    • DML / data backfills — db diff emits schema DDL only. Hand-write data updates (e.g. backfilling a new column on existing rows).
    • Imperative bits db diff can't model — e.g. cron.schedule(...) / pg_cron jobs (see *_cron.sql migrations).
    • Enum value additions — for an enum used by a column that an RLS policy (or other dependent) references, db diff's rename/recreate/recast fails to apply: "cannot alter type of a column used in a policy definition". Still add the value to the enum in supabase/schemas/01_types.sql, but replace the generated recast with hand-written alter type public.<enum> add value if not exists '<v>'; (appends in place, touches no columns/policies). The recast is only safe when nothing references the column (e.g. webhook_table).

    Everything else (columns, policies, triggers, functions) must come from editing supabase/schemas/ and re-running db diff — don't append DDL by hand.

  • Migrations apply automatically via CI: pushing to origin/develop deploys to DEV, pushing to origin/main deploys to PROD. Never apply migrations manually or execute DDL directly on production.
  • See README.md "Local development > Database" for the full workflow.

Generated types

supabase/functions/_shared/db_types.ts is autogenerated — never hand-edit it. Regenerate it from the local database after applying a migration:

npx supabase gen types typescript --local > supabase/functions/_shared/db_types.ts

The UI repo mirrors this file at open-bsp-ui/src/supabase/db_types.ts — copy it over after regenerating. See README.md "Local development > Database".

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.