algolia-multi-env-setup
Configure Algolia across dev/staging/production: index prefixing, per-environment API keys, settings-as-code, and environment isolation guards. Trigger: "algolia environments", "algolia staging", "algolia dev prod", "algolia environment setup", "algolia config by env".
What this skill does
# Algolia Multi-Environment Setup
## Overview
Algolia doesn't have built-in environment separation. You either use **separate Algolia applications** (strongest isolation) or **index prefixing** within one application (simpler). This skill covers both approaches.
## Environment Strategies
| Strategy | Isolation | Cost | Complexity |
|----------|-----------|------|------------|
| Index prefixing | Shared app, prefixed names | Lowest | Low |
| Separate API keys | Shared app, scoped keys | Low | Medium |
| Separate applications | Full isolation | Highest | High |
## Instructions
### Step 1: Index Prefixing (Recommended for Most Teams)
```typescript
// src/algolia/config.ts
import { algoliasearch, type Algoliasearch } from 'algoliasearch';
type Environment = 'development' | 'staging' | 'production';
interface AlgoliaConfig {
appId: string;
apiKey: string;
searchKey: string;
environment: Environment;
}
function getConfig(): AlgoliaConfig {
const env = (process.env.NODE_ENV || 'development') as Environment;
return {
appId: process.env.ALGOLIA_APP_ID!,
apiKey: process.env.ALGOLIA_ADMIN_KEY!,
searchKey: process.env.ALGOLIA_SEARCH_KEY!,
environment: env,
};
}
// Prefix index names with environment
export function indexName(base: string): string {
const { environment } = getConfig();
if (environment === 'production') return base; // No prefix in prod
return `${environment}_${base}`;
// development_products, staging_products, products
}
let _client: Algoliasearch | null = null;
export function getClient(): Algoliasearch {
if (!_client) {
const config = getConfig();
_client = algoliasearch(config.appId, config.apiKey);
}
return _client;
}
```
### Step 2: Scoped API Keys Per Environment
```typescript
import { algoliasearch } from 'algoliasearch';
const adminClient = algoliasearch(process.env.ALGOLIA_APP_ID!, process.env.ALGOLIA_ADMIN_KEY!);
// Create environment-scoped keys that can ONLY access their own indices
async function createEnvironmentKeys() {
// Staging key: can only access staging_* indices
const { key: stagingKey } = await adminClient.addApiKey({
apiKey: {
acl: ['search', 'addObject', 'deleteObject', 'editSettings', 'browse'],
description: 'Staging environment — full access to staging indices only',
indexes: ['staging_*'],
maxQueriesPerIPPerHour: 10000,
},
});
console.log(`Staging key: ${stagingKey}`);
// Dev key: can only access development_* indices
const { key: devKey } = await adminClient.addApiKey({
apiKey: {
acl: ['search', 'addObject', 'deleteObject', 'editSettings', 'browse'],
description: 'Development environment — full access to dev indices only',
indexes: ['development_*'],
maxQueriesPerIPPerHour: 5000,
},
});
console.log(`Dev key: ${devKey}`);
// Production search key: search only, restricted
const { key: prodSearchKey } = await adminClient.addApiKey({
apiKey: {
acl: ['search'],
description: 'Production search — read only',
indexes: ['products', 'articles', 'faq'],
maxQueriesPerIPPerHour: 50000,
maxHitsPerQuery: 100,
},
});
console.log(`Prod search key: ${prodSearchKey}`);
}
```
### Step 3: Environment Variables Per Platform
```bash
# .env.development
ALGOLIA_APP_ID=YourAppID
ALGOLIA_ADMIN_KEY=dev_scoped_key_here
ALGOLIA_SEARCH_KEY=dev_search_key_here
NODE_ENV=development
# .env.staging
ALGOLIA_APP_ID=YourAppID
ALGOLIA_ADMIN_KEY=staging_scoped_key_here
ALGOLIA_SEARCH_KEY=staging_search_key_here
NODE_ENV=staging
# Production: use secret manager, not env files
# GitHub Actions:
# ALGOLIA_ADMIN_KEY: ${{ secrets.ALGOLIA_ADMIN_KEY_PROD }}
# GCP Secret Manager:
# gcloud secrets versions access latest --secret=algolia-admin-key
# Vercel:
# vercel env add ALGOLIA_ADMIN_KEY production
```
### Step 4: Settings-as-Code with Environment Overrides
```typescript
// config/algolia-settings.ts
import type { IndexSettings } from 'algoliasearch';
const baseSettings: IndexSettings = {
searchableAttributes: ['name', 'brand', 'category', 'unordered(description)'],
attributesForFaceting: ['searchable(brand)', 'category', 'filterOnly(price)'],
customRanking: ['desc(review_count)', 'desc(rating)'],
};
const envOverrides: Partial<Record<string, Partial<IndexSettings>>> = {
development: {
// Faster iteration: no replicas in dev
replicas: [],
},
staging: {
// Mirror prod replicas for testing
replicas: ['virtual(staging_products_price_asc)'],
},
production: {
replicas: [
'virtual(products_price_asc)',
'virtual(products_price_desc)',
'virtual(products_newest)',
],
},
};
export function getSettings(env: string): IndexSettings {
return { ...baseSettings, ...envOverrides[env] };
}
```
### Step 5: Environment Isolation Guard
```typescript
// Prevent accidental cross-environment operations
export function guardEnvironment(operation: string, targetIndex: string) {
const env = process.env.NODE_ENV || 'development';
if (env === 'production') {
// In production, block access to dev/staging indices
if (targetIndex.startsWith('development_') || targetIndex.startsWith('staging_')) {
throw new Error(`Blocked: ${operation} on ${targetIndex} from production`);
}
} else {
// In dev/staging, block access to production indices (no prefix = production)
if (!targetIndex.startsWith(`${env}_`)) {
throw new Error(`Blocked: ${operation} on ${targetIndex} from ${env}. Use prefixed index.`);
}
}
}
// Usage in service layer
async function deleteIndex(name: string) {
guardEnvironment('deleteIndex', name);
await getClient().deleteIndex({ indexName: name });
}
```
### Step 6: Seed Script Per Environment
```typescript
// scripts/seed-environment.ts
import { getClient, indexName } from '../src/algolia/config';
import { getSettings } from '../config/algolia-settings';
async function seedEnvironment() {
const env = process.env.NODE_ENV || 'development';
const client = getClient();
const idx = indexName('products');
console.log(`Seeding ${env} environment → index: ${idx}`);
// Apply settings
await client.setSettings({ indexName: idx, indexSettings: getSettings(env) });
// Seed data (dev/staging only)
if (env !== 'production') {
const testData = await import('../fixtures/products.json');
const { taskID } = await client.replaceAllObjects({
indexName: idx,
objects: testData.default,
});
await client.waitForTask({ indexName: idx, taskID });
console.log(`Seeded ${testData.default.length} records`);
}
}
seedEnvironment().catch(console.error);
```
## Error Handling
| Issue | Cause | Solution |
|-------|-------|----------|
| Wrong index in production | Missing prefix logic | Use `indexName()` helper everywhere |
| Staging data leaking to prod | Shared API key | Use scoped keys restricted to index patterns |
| Settings drift between envs | Manual dashboard changes | Apply settings from code in CI |
| Dev index polluting record count | Old test indices | Scheduled cleanup job for `development_*` indices |
## Resources
- [API Key Index Restrictions](https://www.algolia.com/doc/guides/security/api-keys/in-depth/api-key-restrictions/)
- [Settings API](https://www.algolia.com/doc/api-reference/api-methods/set-settings/)
- [12-Factor App Config](https://12factor.net/config)
## Next Steps
For observability setup, see `algolia-observability`.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.