本文へ移動
cccskills
無料GitHub で公開

gcp-firestore-deep

Use when working with Gcp Firestore Deep — google Cloud Firestore document and collection analysis, index management, security rules review, usage monitoring, and performance diagnostics via gcloud CLI.

インストール方法を見る

含まれるファイル(1)

  • SKILL.md7.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Firestore Skill

Manage and analyze Google Cloud Firestore using gcloud firestore commands.

Discovery-First Rule

ALWAYS discover before acting. Never assume database names, collection names, or index configurations.

# Discover Firestore databases
gcloud firestore databases list --format=json \
  | jq '[.[] | {name: .name, type: .type, locationId: .locationId, concurrencyMode: .concurrencyMode, appEngineIntegrationMode: .appEngineIntegrationMode, deleteProtectionState: .deleteProtectionState}]'

Parallel Execution Requirement

ALL independent operations MUST run in parallel using background jobs (&) and wait.

for db in $(gcloud firestore databases list --format="value(name)" | xargs -I{} basename {}); do
  {
    gcloud firestore indexes composite list --database="$db" --format=json
  } &
done
wait

Helper Functions

# List composite indexes
list_composite_indexes() {
  local db="${1:-(default)}"
  gcloud firestore indexes composite list --database="$db" --format=json \
    | jq '[.[] | {name: .name | split("/") | last, collection: .collectionGroup, state: .state, fields: [.fields[] | {path: .fieldPath, order: .order // .arrayConfig}]}]'
}

# List field indexes (overrides)
list_field_overrides() {
  local db="${1:-(default)}"
  gcloud firestore indexes fields list --database="$db" --format=json \
    | jq '[.[] | select(.indexConfig.indexes) | {field: .name, indexes: .indexConfig.indexes}]'
}

# Export database
export_database() {
  local db="$1" bucket="$2"
  gcloud firestore export "gs://$bucket" --database="$db" --format=json
}

# Get database usage metrics
get_firestore_metrics() {
  local project="$1"
  gcloud monitoring time-series list \
    --filter="metric.type=starts_with(\"firestore.googleapis.com/\")" \
    --interval-start-time="$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
    --format=json --limit=100
}

Common Operations

1. Database Overview

# List databases and their configuration
gcloud firestore databases list --format=json \
  | jq '[.[] | {name: .name | split("/") | last, type: .type, location: .locationId, concurrencyMode: .concurrencyMode, pointInTimeRecovery: .pointInTimeRecoveryEnablement, deleteProtection: .deleteProtectionState}]'

2. Index Management

# Composite indexes with build status
list_composite_indexes "(default)"

# Find indexes that are still building
gcloud firestore indexes composite list --database="(default)" --format=json \
  | jq '[.[] | select(.state != "READY") | {collection: .collectionGroup, state: .state, fields: [.fields[] | .fieldPath]}]'

# Field-level index overrides
list_field_overrides "(default)"

3. Collection Analysis

# Document count and storage metrics
gcloud monitoring time-series list \
  --filter="metric.type=\"firestore.googleapis.com/document/count\"" \
  --interval-start-time="$(date -u -v-24H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '24 hours ago' +%Y-%m-%dT%H:%M:%SZ)" \
  --format=json

# Read/write operation metrics
gcloud monitoring time-series list \
  --filter="metric.type=\"firestore.googleapis.com/api/request_count\"" \
  --interval-start-time="$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
  --format=json

4. Security Rules Review

# Get current security rules (requires Firebase CLI or REST API)
# Using REST API via gcloud
PROJECT=$(gcloud config get-value project)
gcloud rest firestore.projects.databases.documents --method=GET \
  "https://firestore.googleapis.com/v1/projects/$PROJECT/databases/(default)/documents" 2>/dev/null

# Check rules release history
gcloud firestore databases describe --database="(default)" --format=json

5. Usage and Performance Monitoring

# Active connections
gcloud monitoring time-series list \
  --filter="metric.type=\"firestore.googleapis.com/network/active_connections\"" \
  --interval-start-time="$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
  --format=json

# Snapshot listeners
gcloud monitoring time-series list \
  --filter="metric.type=\"firestore.googleapis.com/network/snapshot_listeners\"" \
  --interval-start-time="$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
  --format=json

# Rule evaluation metrics
gcloud monitoring time-series list \
  --filter="metric.type=\"firestore.googleapis.com/rules/evaluation_count\"" \
  --interval-start-time="$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" \
  --format=json

Output Format

Present results as a structured report:

Gcp Firestore Deep Report
═════════════════════════
Resources discovered: [count]

Resource       Status    Key Metric    Issues
──────────────────────────────────────────────
[name]         [ok/warn] [value]       [findings]

Summary: [total] resources | [ok] healthy | [warn] warnings | [crit] critical
Action Items: [list of prioritized findings]

Target ≤50 lines of output. Use tables for multi-resource comparisons.

Anti-Hallucination Rules

  1. NEVER assume resource names — always discover via CLI/API in Phase 1 before referencing in Phase 2.
  2. NEVER fabricate metric names or dimensions — verify against the service documentation or --help output.
  3. NEVER mix CLI commands between service versions — confirm which version/API you are targeting.
  4. ALWAYS use the discovery → verify → analyze chain — every resource referenced must have been discovered first.
  5. ALWAYS handle empty results gracefully — an empty response is valid data, not an error to retry.

Counter-Rationalizations

ShortcutCounterWhy
"I'll skip discovery and check known resources"Always run Phase 1 discovery firstResource names change, new resources appear — assumed names cause errors
"The user only asked for a quick check"Follow the full discovery → analysis flowQuick checks miss critical issues; structured analysis catches silent failures
"Default configuration is probably fine"Audit configuration explicitlyDefaults often leave logging, security, and optimization features disabled
"Metrics aren't needed for this"Always check relevant metrics when availableAPI/CLI responses show current state; metrics reveal trends and intermittent issues
"I don't have access to that"Try the command and report the actual errorAssumed permission failures prevent useful investigation; actual errors are informative

Common Pitfalls

  1. Database naming: The default database is named (default) with parentheses. Always quote it in commands to avoid shell interpretation.
  2. Index build time: Composite index creation can take minutes to hours depending on data volume. Check state field before querying with new indexes.
  3. Hot spots: Sequential document IDs (timestamps, auto-increment) cause write hot spots. Check for monotonically increasing key patterns.
  4. Read-after-write: In multi-region databases, strong consistency is only guaranteed within a single document. Cross-document reads may see stale data.
  5. Cost model: Firestore charges per document read/write/delete, not per query. A query returning 1000 documents costs 1000 read operations.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Cloudflare GraphQL Analytics for zone traffic, firewall events, Workers metrics, and schema exploration. Use when querying Cloudflare analytics data or exploring the GraphQL API.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Alloydb — google AlloyDB instance analysis, query insights, columnar engine optimization, maintenance windows, and cluster health.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Aqua — aqua Security platform analysis. Covers container runtime protection, image assurance policies, compliance frameworks, vulnerability management, workload protection, and registry scanning. Use when analyzing container security posture, reviewing image compliance, investigating runtime alerts, or auditing security policies.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Bigquery — google BigQuery job analysis, slot utilization, cost analysis, dataset management, and query optimization.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Cassandra — apache Cassandra keyspace analysis, compaction strategies, repair status, nodetool operations, and cluster health monitoring.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

Use when working with Checkov — checkov infrastructure-as-code security scanning. Covers Terraform, CloudFormation, Kubernetes, and Dockerfile scanning, policy management, custom checks, compliance frameworks, and suppression management. Use when scanning IaC for security misconfigurations, evaluating compliance, managing custom policies, or reviewing scan results.

日本語の概要は準備中です。原文の説明を表示しています。

cloudthinker-ai/CloudSkills62026年4月5日 更新

cloudthinker-ai のスキルをすべて見る

このスキルの問題を報告する