Skip to content

About

Antigravity ใง็คพๅ†…ใ‚ขใƒ—ใƒชใ‚’้‡็”ฃใ™ใ‚‹ใŸใ‚ใฎ Firebase ใ‚ฌใƒผใƒ‰ใƒฌใƒผใƒซๅŸบ็›ค๏ผˆๅ…ฑๆœ‰ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใฎใƒ†ใƒŠใƒณใƒˆๅˆ†้›ขใƒปๆœ€ๅฐๆจฉ้™ใƒ‡ใƒ—ใƒญใ‚คใƒปAgent Skill๏ผ‰

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

7 Commits

Folders and files

Repository files navigation

๐Ÿ›ก๏ธ Antigravity Firebase Guardrail

English | ๆ—ฅๆœฌ่ชž

Firebase guardrails for mass-producing internal apps with AI agents.

Many apps share one Firebase project, each isolated as its own "tenant".
Engineers build the foundation once. App builders just tell an AI agent what they want.

CI License: MIT Google Antigravity Firebase Terraform


๐Ÿ’ก Why

Non-engineers can now build real internal apps with AI. Security and privacy checks, however, still depend on engineers reviewing each one. Builders wait, and engineers drown in a steady trickle of reviews.

Agent Skills (instructions to the AI) Mechanisms (Terraform ยท IAM ยท build config ยท CI)
Owns repeatable procedure ยท steering toward safe patterns the boundaries that must not be crossed
When it drifts AI output can vary permissions and checks stop it

Instead of handing out a long rulebook, this repository ships the guardrail platform and two role-specific Agent Skills together. Engineers and app builders both point an AI agent at this repository and work through it in conversation.

flowchart LR
    REPO["This repository<br/>guardrail platform + 2 Agent Skills"]

    subgraph DEV["Engineer (once)"]
        P1["'Set up the initial Firebase<br/>environment from this repo'"]
        S1["init-firebase-platform skill<br/>shared project ยท Terraform ยท WIF ยท<br/>least-privilege SAs ยท budget and audit alerts"]
        P1 --> S1
    end

    subgraph USER["App builder (any number of times)"]
        P2["'Build an app that<br/>summarizes ...'"]
        S2["build-firebase-app skill<br/>check the data first ยท register in catalog ยท<br/>no HTTP functions ยท verify on emulator ยท open a PR"]
        P2 --> S2
    end

    REPO --> S1
    REPO --> S2
    S1 -->|"foundation"| ENV[("Shared Firebase project<br/>one isolated tenant per app")]
    S2 -->|"standard apps: CI checks only<br/>others: engineer review"| ENV
Loading

โœจ What it does

Guardrail What it prevents Where
Two lanes instead of a review queue Every new app waiting for an engineer. Non-confidential Tier 0 apps using a pre-approved Rules template (or statically verified internal-only firestore.rules) and at most pre-approved notification webhooks / public RSS via safeFetch (such as the news-watcher sample) are registered in platform/catalog/self-service/ and get their database without review or approval. Exceptions (Tier 1, non-webhook API keys, unapproved outbound calls, raw fetch()) go through apps.yaml and engineer review pnpm policy (lane verdict, posted on the PR), plan-guard.mjs (auto-apply only when the plan touches nothing but that app's tenant), CODEOWNERS
Data check before any code Personal or confidential data landing in a self-service database Skill (asks about personal data, outbound calls, retention) + pnpm policy (blocks handles_pii: true or confidential in Tier 0, flags fetch() that bypasses safeFetch) + PR checklist
Budget alerts and database-creation alerts Runaway cost; databases created outside the catalog. Budgets notify Pub/Sub and email (they notify only โ€” they do not stop billing). Every CreateDatabase audit log entry raises an alert, and one made by anyone but the Terraform SA raises a critical one budget.tf, audit_alerts.tf (both on by default)
Only Terraform deploys Security Rules Rules permissions can only be granted project-wide. Give them to an app's deploy path and it can open every other app's database The deployer SA has no permission to release firebaserules.*. Custom apps/*/firestore.rules requires CODEOWNERS review and is applied by the platform job in deploy.yml with approval; standard templates live in platform/rules-templates/
No HTTP functions in Tier 0 Missing auth checks and accidental public exposure. The UI only writes to Firestore; Firestore triggers and onSchedule do the work Skill + pnpm policy (detects onRequest / onCall)
Supply-chain protection Hijacked packages and postinstall abuse. Cloud Functions reinstalls dependencies in the cloud, so functions are bundled into one file with esbuild and only two dependencies are installed cloud-side pnpm-workspace.yaml, dependency allowlist, OSV-Scanner
No (default) database or default bucket Writing to a shared location when someone forgets to name the database Terraform never creates them, and the deployer SA cannot create databases
Per-tenant runtime SA with IAM Conditions A function reading another app's database or secrets modules/app-tenant
Keyless deploys (WIF) Production credentials on a laptop. Only workflows running on main can impersonate the service accounts bootstrap/github_wif.tf, deploy.yml
App catalog with expiry dates Apps that nobody owns living on forever platform/catalog/, pnpm policy (an expired app fails CI)

Design details are in docs/platform_design.md (Japanese). Section 9 of that document lists the places where a least-privilege firebase deploy got stuck, and the fix for each.

๐Ÿš€ Getting started

Engineers (once)

  1. Copy this repository into your own GitHub account with Use this template, then clone it. Make it private if you use it for work.

  2. Open the repository in Antigravity (or the AI agent you use) and ask:

    Using this repository and the initial setup skill, build the initial environment for a governed, shared Firebase project, including budget alerts and database-creation audit alerts. Always show me the diff and ask before applying anything to the cloud.

    To call the skill explicitly, use /init-firebase-platform. To do it by hand, follow docs/runbook.md (Japanese).

You need: an active Google Cloud Billing account (or an existing billing-linked project with create_project = false), gcloud, terraform, Node.js 24, and pnpm.

Note

What is automated vs. manual during initial setup

  • Automated (Terraform): GCP project creation, Cloud Billing linkage (which automatically enables the Firebase Blaze pay-as-you-go planโ€”no manual upgrade in Firebase Console), API enablement, WIF, least-privilege SAs, budgets, quotas, and DB audit alerts.
  • Manual (once): Creating a Cloud Billing account beforehand if you do not have one yet, enabling Google Sign-In in Firebase Console (OAuth client creation is not exposed via API; the skill guides you through the exact click path), and registering any app secrets (e.g., Slack webhook URLs) outside chat.

App builders (any number of times)

  1. Open the repository in Antigravity.

  2. Describe the app you want:

    Use this repository's app-building skill to make a Firebase app. I want a shared link collection and memo tool for my team.

  3. Answer the agent's questions about the data (personal data, outbound calls, how long to keep it). It asks before writing any code.

  4. Try it on the local emulator, which never connects to production, and say what you want changed.

  5. When it looks right, ask the agent to open a pull request on GitHub.

App builders never touch the Google Cloud console or Terraform, and their machine holds no production deploy permission. Non-confidential Tier 0 apps that pass policy checks (including the news-watcher sample with verified internal-only Rules and notification webhooks) are published by CI after the merge with no engineer in the loop. Engineers review only the exceptions in apps.yaml (Tier 1, non-webhook API keys, unapproved outbound calls, or raw fetch()).

You need: a GitHub account, Antigravity, Node.js 24, pnpm, and Java 21 or later (for the emulator).

Note

The skills, AGENT.md, the docs, and code comments are written in Japanese. The agent is instructed to reply in Japanese.

๐Ÿงฉ What's inside

.
โ”œโ”€โ”€ AGENT.md                                 # Repository-wide rules the AI agent reads first
โ”œโ”€โ”€ .agents/
โ”‚   โ””โ”€โ”€ skills/
โ”‚       โ”œโ”€โ”€ init-firebase-platform/          # [Engineers] initial guardrail setup skill
โ”‚       โ”‚   โ””โ”€โ”€ SKILL.md
โ”‚       โ””โ”€โ”€ build-firebase-app/              # [App builders] app-building skill
โ”‚           โ”œโ”€โ”€ SKILL.md
โ”‚           โ””โ”€โ”€ reference.md                 #   naming rules, Rules and function skeletons
โ”œโ”€โ”€ platform/
โ”‚   โ”œโ”€โ”€ config.json                          # The one place for environment values (project ID, domain, ...)
โ”‚   โ”œโ”€โ”€ catalog/
โ”‚   โ”‚   โ”œโ”€โ”€ apps.yaml                        # Apps that engineers review (custom Rules, secrets, outbound calls)
โ”‚   โ”‚   โ””โ”€โ”€ self-service/                    # Standard-shape Tier 0 apps, one file each: no review, auto-applied
โ”‚   โ”œโ”€โ”€ rules-templates/                     # Pre-approved standard Security Rules
โ”‚   โ”œโ”€โ”€ terraform/                           # Shared project, WIF, deployer SA, budget and audit alerts, tenants
โ”‚   โ””โ”€โ”€ policies/                            # CI policy check, lane verdict, plan guard, dependency allowlist
โ”œโ”€โ”€ apps/
โ”‚   โ””โ”€โ”€ news-watcher/                        # First app: scores and summarizes RSS with Gemini, posts to Slack
โ”œโ”€โ”€ scripts/                                 # bootstrap / deploy / destroy
โ”œโ”€โ”€ .github/                                 # CI, deploy, CODEOWNERS, issue templates
โ”œโ”€โ”€ docs/                                    # Design and runbook (Japanese)
โ””โ”€โ”€ pnpm-workspace.yaml                      # Supply-chain settings (7-day release age, install scripts allowlisted)
Skill For What it does
init-firebase-platform Engineers Builds the shared project, WIF, least-privilege SAs, budget and audit alerts, and tenants, confirming each diff first
build-firebase-app App builders Checks what data the app handles, registers it in the right catalog, implements it within the rules, verifies it on the emulator, and opens a PR

๐Ÿ“Š Verification status

Area Status Details
Shared platform and tenant provisioning Verified on a real project (*) Terraform (creates a tenant's 7 resources at once), no (default) database, Rules deployed by Terraform, Artifact Registry npm remote repository
Least-privilege deploy and news-watcher Verified on a real project (*) Deployer SA + scripts/deploy_app.sh, pnpm protections + single-file esbuild bundle, news-watcher (Gemini scoring and summaries, sharing to Slack)
Parts generalized for this public release Static checks only Centralizing settings in platform/config.json, restricting WIF per branch (attribute.repo_ref), scripts rewritten in bash, the deploy.yml workflow. terraform validate, unit tests, the policy check, and CI all pass, but this exact form has not been applied to a fresh project
CI policy check Implemented (simple) Catalog, lane verdict, firebase.json scope, no HTTP functions, Rules, dependency allowlist, secrets. It uses strings and regular expressions, not a parser
Two lanes, budget alerts, database-creation alerts, TTL Local checks only terraform validate, unit tests for the policy check and the plan guard, and both standard Rules templates exercised on the Firestore emulator (allow/deny cases). Not yet applied to a real project, and the auto-apply job in deploy.yml has not run on GitHub Actions
Not there yet Not implemented Rules unit tests in CI, gitleaks, a real-project check of isolation with a second tenant, Storage buckets for Tier 1, App Check

(*) Verified in the author's test environment, in the form before it was generalized (with the project ID and similar values written directly).

๐Ÿ› ๏ธ Development
corepack enable pnpm
pnpm install --frozen-lockfile
pnpm policy                     # policy check
pnpm policy:test                # tests for the policy check
pnpm typecheck && pnpm test     # news-watcher unit tests
pnpm build
terraform fmt -check -recursive platform/terraform

None of this connects to the cloud, so no Google Cloud credentials are needed.


๐Ÿค Contributing

A personal, MIT-licensed project. Issues, PRs, and โญ are all welcome. See CONTRIBUTING.md (Japanese), and SECURITY.md for reporting vulnerabilities. Issues and PRs in English or Japanese are both fine.


โš ๏ธ Disclaimer

Community project. Not affiliated with, endorsed by, or supported by Google. The content reflects the author's personal views. "Antigravity", "Gemini", "Firebase", and "Google Cloud" are trademarks of their respective owners. You are responsible for the cost of the Google Cloud resources you create with this repository, and for your own credentials and data. The verified scope is listed under "Verification status"; test it in your own environment before using it in production. MIT licensed โ€” see LICENSE.

About

Antigravity ใง็คพๅ†…ใ‚ขใƒ—ใƒชใ‚’้‡็”ฃใ™ใ‚‹ใŸใ‚ใฎ Firebase ใ‚ฌใƒผใƒ‰ใƒฌใƒผใƒซๅŸบ็›ค๏ผˆๅ…ฑๆœ‰ใƒ—ใƒญใ‚ธใ‚งใ‚ฏใƒˆใฎใƒ†ใƒŠใƒณใƒˆๅˆ†้›ขใƒปๆœ€ๅฐๆจฉ้™ใƒ‡ใƒ—ใƒญใ‚คใƒปAgent Skill๏ผ‰

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages