Get the FREE Ultimate OpenClaw Setup Guide →

firebase-development-debug

Scanned
npx machina-cli add skill aiskillstore/marketplace/firebase-development-debug --openclaw
Files (1)
SKILL.md
5.6 KB

Firebase Debugging

Overview

This sub-skill guides systematic troubleshooting of Firebase development issues. It handles emulator problems, rules violations, function errors, auth issues, and deployment failures.

Key principles:

  • Identify issue type first (emulator, rules, functions, auth, deployment)
  • Use Emulator UI and Rules Playground for diagnosis
  • Export emulator state before restarting
  • Document issues and solutions for future reference

When This Sub-Skill Applies

  • Emulators won't start or have port conflicts
  • Getting Firestore rules violations (PERMISSION_DENIED)
  • Cloud Functions returning errors or not executing
  • Authentication not working in emulators
  • Deployment fails with cryptic errors
  • User says: "debug", "troubleshoot", "error", "not working", "failing"

Do not use for:

  • Setting up new projects → firebase-development:project-setup
  • Adding new features → firebase-development:add-feature
  • Code review without specific errors → firebase-development:validate

TodoWrite Workflow

Create checklist with these 10 steps:

Step 1: Identify Issue Type

Categorize the error:

CategorySymptomsKeywords
Emulator Won't StartPort conflicts, initialization errors"EADDRINUSE", "emulator failed"
Rules ViolationPermission denied on read/write"PERMISSION_DENIED", "insufficient"
Function ErrorHTTP 500, timeout, not executing"function failed", "timeout"
Auth IssueToken errors, not authenticated"auth failed", "invalid token"
Deployment FailureDeploy command fails"deployment failed", "deploy error"

If unclear, use AskUserQuestion to clarify issue type.

Step 2: Check Emulator Logs and Terminal

For running emulators: Watch terminal output while reproducing the issue.

For emulators that won't start:

lsof -i :4000 && lsof -i :5001 && lsof -i :8080  # Check ports
kill -9 <PID>  # Kill conflicting process

For deployment errors: Check firebase-debug.log

Reference: docs/examples/emulator-workflow.md

Step 3: Open Emulator UI

open http://127.0.0.1:4000

Use Emulator UI to:

  • View Firestore data and structure
  • Check authenticated users
  • Review function invocation logs
  • Search consolidated logs

Step 4: Test Rules in Playground (If Rules Issue)

In Emulator UI → Firestore → Rules Playground:

  1. Select operation type (get/list/create/update/delete)
  2. Specify document path
  3. Set auth context (uid, custom claims)
  4. Add request data for writes
  5. Run simulation and review evaluation trace

Reference: docs/examples/firestore-rules-patterns.md

Step 5: Add Debug Logging (If Function Error)

Add strategic console.log statements:

  • Function entry confirmation
  • Input data (req.body, req.params)
  • Auth context (userId, API key)
  • Intermediate operation results
  • Error details with stack trace

Watch terminal output while reproducing.

Reference: docs/examples/express-function-architecture.md

Step 6: Verify Auth Configuration (If Auth Issue)

Check environment variables:

cat functions/.env
cat hosting/.env.local  # Should have NEXT_PUBLIC_USE_EMULATORS=true

Check emulator connection in client code and API key middleware.

Reference: docs/examples/api-key-authentication.md

Step 7: Check Deployment Config (If Deployment Failure)

cat firebase-debug.log  # Full error details
cat firebase.json       # Config issues
cat .firebaserc         # Project ID
firebase target:list    # Verify targets

Test predeploy hooks locally:

cd functions && npm run build

Step 8: Export Emulator State

Before making fixes:

# Graceful shutdown (Ctrl+C exports automatically)
# Or manual export:
firebase emulators:export ./backup-data

Verify export: ls -la .firebase/emulator-data/

Step 9: Implement and Test Fix

Apply fix based on diagnosis, then:

firebase emulators:start --import=.firebase/emulator-data

Verify:

  • Original error no longer occurs
  • Terminal shows success logs
  • Emulator UI confirms expected behavior

Step 10: Document Issue and Solution

Create entry in docs/debugging-notes.md:

  • Symptom and exact error message
  • Root cause
  • Solution applied
  • Prevention for future

Common Issues Quick Reference

IssueSolution
Port conflictslsof -i :<port>, kill process
Data persistence lostUse Ctrl+C (not kill) to stop emulators
Cold start delaysFirst call takes 5-10s (normal)
Rules not reloadingRestart emulators
Admin vs Client SDKAdmin bypasses rules, client respects them
Missing CORSAdd app.use(cors({ origin: true }))
Emulator connectionSet NEXT_PUBLIC_USE_EMULATORS=true
API key prefixVerify prefix matches actual keys

Integration with Superpowers

If Firebase-specific tools don't reveal root cause, invoke superpowers:systematic-debugging for:

  • Complex multi-service interactions
  • Race conditions or timing issues
  • Call stack tracing beyond Firebase layer

Pattern References

  • Emulator workflow: docs/examples/emulator-workflow.md
  • Rules patterns: docs/examples/firestore-rules-patterns.md
  • Auth patterns: docs/examples/api-key-authentication.md
  • Functions: docs/examples/express-function-architecture.md

Source

git clone https://github.com/aiskillstore/marketplace/blob/main/skills/2389-research/firebase-development-debug/SKILL.mdView on GitHub

Overview

Firebase Debugging provides a systematic approach to troubleshoot emulator issues across emulator, rules, functions, auth, and deployment. It emphasizes using the Emulator UI, Rules Playground, logs, and a documented workflow to diagnose and fix problems efficiently.

How This Skill Works

The skill follows a structured 10-step TodoWrite workflow to identify issue type, check logs, open the Emulator UI, test rules, add debug logging, verify auth configuration, and review deployment settings. It promotes exporting emulator state before restarts and documenting issues and solutions for future reference.

When to Use It

  • Emulators won't start or have port conflicts
  • Getting Firestore rules violations (PERMISSION_DENIED)
  • Cloud Functions returning errors or not executing
  • Authentication not working in emulators
  • Deployment fails with cryptic errors

Quick Start

  1. Step 1: Identify Issue Type
  2. Step 2: Check Emulator Logs and Emulator UI
  3. Step 3: Test/Adjust Rules or Functions; add debug logs if needed

Best Practices

  • Identify issue type first (emulator, rules, functions, auth, deployment)
  • Use Emulator UI and Rules Playground for diagnosis
  • Export emulator state before restarting
  • Document issues and solutions for future reference
  • Correlate logs from firebase-debug.log and terminal output

Example Use Cases

  • Emulator won't start due to port conflict; resolve by identifying and killing the conflicting process
  • Firestore rules violation detected as PERMISSION_DENIED in Rules Playground and emulator logs
  • Cloud Function shows 'function failed' or timeout during local testing and needs additional debug logs
  • Auth not working in the emulator; verify NEXT_PUBLIC_USE_EMULATORS flag and auth config
  • Deployment fails with 'deployment failed'; inspect firebase-debug.log, firebase.json, and .firebaserc

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers