environment-setup-guide
Guide developers through setting up development environments with proper tools, dependencies, and configurations
openevidence-multi-env-setup
Configure OpenEvidence across development, staging, and production environments. Use when setting up multiple environments, managing environment-specific configurations, or implementing environment promotion strategies for clinical AI applications. Trigger with phrases like "openevidence environm...
Full skill instructions
Configure and manage OpenEvidence integrations across development, staging, and production environments with proper isolation and promotion strategies.
| Environment | API Endpoint | Purpose | Data |
|---|---|---|---|
| Development | sandbox.openevidence.com | Local development | Synthetic |
| Staging | sandbox.openevidence.com | Integration testing | Synthetic |
| Production | api.openevidence.com | Live clinical use | Real (PHI) |
// config/environments/development.ts
export const developmentConfig = {
env: 'development',
openevidence: {
baseUrl: 'https://api.sandbox.openevidence.com',
timeout: 60000, // Longer timeout for debugging
retries: 1,
rateLimit: {
enabled: false, // No rate limiting in dev
},
},
cache: {
enabled: false, // Disable cache for fresh responses
ttlSeconds: 0,
},
logging: {
level: 'debug',
prettyPrint: true,
},
features: {
deepConsult: true,
webhooks: false, // No webhooks in local dev
auditLogging: false,
},
};
// config/environments/staging.ts
export const stagingConfig = {
env: 'staging',
openevidence: {
baseUrl: 'https://api.sandbox.openevidence.com',
timeout: 45000,
retries: 2,
rateLimit: {
enabled: true,
requestsPerMinute: 60,
},
},
cache: {
enabled: true,
ttlSeconds: 1800, // 30 min cache
},
logging: {
level: 'info',
prettyPrint: false,
},
features: {
deepConsult: true,
webhooks: true,
auditLogging: true,
},
};
// config/environments/production.ts
export const productionConfig = {
env: 'production',
openevidence: {
baseUrl: 'https://api.openevidence.com',
timeout: 30000,
retries: 3,
rateLimit: {
enabled: true,
requestsPerMinute: 300, // Higher limit in prod
},
},
cache: {
enabled: true,
ttlSeconds: 3600, // 1 hour cache
},
logging: {
level: 'warn',
prettyPrint: false,
},
features: {
deepConsult: true,
webhooks: true,
auditLogging: true,
},
};
// src/config/index.ts
import { developmentConfig } from './environments/development';
import { stagingConfig } from './environments/staging';
import { productionConfig } from './environments/production';
type Environment = 'development' | 'staging' | 'production';
const configs = {
development: developmentConfig,
staging: stagingConfig,
production: productionConfig,
};
export function loadConfig(env?: Environment) {
const environment = env || (process.env.NODE_ENV as Environment) || 'development';
if (!configs[environment]) {
throw new Error(`Unknown environment: ${environment}`);
}
const baseConfig = configs[environment];
// Override with environment variables
return {
...baseConfig,
openevidence: {
...baseConfig.openevidence,
apiKey: process.env.OPENEVIDENCE_API_KEY,
orgId: process.env.OPENEVIDENCE_ORG_ID,
...(process.env.OPENEVIDENCE_BASE_URL && {
baseUrl: process.env.OPENEVIDENCE_BASE_URL,
}),
...(process.env.OPENEVIDENCE_TIMEOUT && {
timeout: parseInt(process.env.OPENEVIDENCE_TIMEOUT),
}),
},
};
}
// Singleton config instance
let configInstance: ReturnType<typeof loadConfig> | null = null;
export function getConfig() {
if (!configInstance) {
configInstance = loadConfig();
}
return configInstance;
}
// For testing - reset config
export function resetConfig() {
configInstance = null;
}
// src/openevidence/client-factory.ts
import { OpenEvidenceClient } from '@openevidence/sdk';
import { getConfig } from '../config';
import { ClinicalQueryCache } from './cache';
import { MetricsCollector } from '../monitoring/metrics';
export class OpenEvidenceClientFactory {
private static instances: Map<string, OpenEvidenceClient> = new Map();
static getClient(environment?: string): OpenEvidenceClient {
const config = getConfig();
const env = environment || config.env;
if (!this.instances.has(env)) {
const client = new OpenEvidenceClient({
apiKey: config.openevidence.apiKey,
orgId: config.openevidence.orgId,
baseUrl: config.openevidence.baseUrl,
timeout: config.openevidence.timeout,
});
this.instances.set(env, client);
}
return this.instances.get(env)!;
}
// For testing - inject mock client
static setClient(env: string, client: OpenEvidenceClient): void {
this.instances.set(env, client);
}
static clearClients(): void {
this.instances.clear();
}
}
// src/secrets/manager.ts
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
interface SecretPaths {
apiKey: string;
orgId: string;
webhookSecret?: string;
}
const SECRET_PATHS: Record<string, SecretPaths> = {
development: {
apiKey: 'local', // Use .env in development
orgId: 'local',
},
staging: {
apiKey: 'projects/staging-project/secrets/openevidence-api-key/versions/latest',
orgId: 'projects/staging-project/secrets/openevidence-org-id/versions/latest',
webhookSecret: 'projects/staging-project/secrets/openevidence-webhook-secret/versions/latest',
},
production: {
apiKey: 'projects/prod-project/secrets/openevidence-api-key/versions/latest',
orgId: 'projects/prod-project/secrets/openevidence-org-id/versions/latest',
webhookSecret: 'projects/prod-project/secrets/openevidence-webhook-secret/versions/latest',
},
};
export class SecretManager {
private client: SecretManagerServiceClient;
constructor() {
this.client = new SecretManagerServiceClient();
}
async getSecrets(env: string): Promise<{
apiKey: string;
orgId: string;
webhookSecret?: string;
}> {
const paths = SECRET_PATHS[env];
if (!paths) {
throw new Error(`Unknown environment: ${env}`);
}
// Development uses environment variables
if (paths.apiKey === 'local') {
return {
apiKey: process.env.OPENEVIDENCE_API_KEY!,
orgId: process.env.OPENEVIDENCE_ORG_ID!,
webhookSecret: process.env.OPENEVIDENCE_WEBHOOK_SECRET,
};
}
// Staging/Production use Secret Manager
const [apiKeyVersion] = await this.client.accessSecretVersion({ name: paths.apiKey });
const [orgIdVersion] = await this.client.accessSecretVersion({ name: paths.orgId });
const secrets: any = {
apiKey: apiKeyVersion.payload?.data?.toString(),
orgId: orgIdVersion.payload?.data?.toString(),
};
if (paths.webhookSecret) {
const [webhookVersion] = await this.client.accessSecretVersion({ name: paths.webhookSecret });
secrets.webhookSecret = webhookVersion.payload?.data?.toString();
}
return secrets;
}
}
# .github/workflows/promotion.yml
name: Environment Promotion
on:
workflow_dispatch:
inputs:
source_env:
description: 'Source environment'
required: true
type: choice
options:
- staging
target_env:
description: 'Target environment'
required: true
type: choice
options:
- production
version:
description: 'Version to promote (e.g., v1.2.3)'
required: true
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate version exists in source
run: |
# Check that the version exists and is deployed in source
SOURCE_VERSION=$(curl -sf "${{ secrets.STAGING_URL }}/health" | jq -r '.version')
if [ "$SOURCE_VERSION" != "${{ inputs.version }}" ]; then
echo "Version mismatch: staging has $SOURCE_VERSION, expected ${{ inputs.version }}"
exit 1
fi
- name: Validate staging tests passed
run: |
# Check that all tests passed for this version
gh run list --workflow=openevidence-ci.yml \
--branch=main --status=success \
--json conclusion,headBranch | jq -e '.[0]'
promote:
needs: validate
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Setup Cloud SDK
uses: google-github-actions/setup-gcloud@v2
with:
project_id: ${{ secrets.PROD_PROJECT_ID }}
- name: Deploy to Production
run: |
gcloud run deploy clinical-evidence-api \
--image gcr.io/${{ secrets.STAGING_PROJECT_ID }}/clinical-evidence-api:${{ inputs.version }} \
--region us-central1 \
--set-env-vars NODE_ENV=production \
--no-traffic
- name: Run smoke tests
run: |
REVISION=$(gcloud run revisions list --service clinical-evidence-api \
--region us-central1 --format 'value(metadata.name)' --limit 1)
# Test the new revision directly
./scripts/smoke-test.sh "$REVISION"
- name: Gradual traffic shift
run: |
# 10% -> 50% -> 100%
for percent in 10 50 100; do
gcloud run services update-traffic clinical-evidence-api \
--region us-central1 \
--to-latest=$percent
sleep 300 # Wait 5 minutes between shifts
done
- name: Create production release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ inputs.version }}-production
name: Production Release ${{ inputs.version }}
body: |
Promoted to production from staging.
Original version: ${{ inputs.version }}
// src/health/environment-health.ts
import { OpenEvidenceClientFactory } from '../openevidence/client-factory';
import { getConfig } from '../config';
interface EnvironmentHealth {
environment: string;
status: 'healthy' | 'degraded' | 'unhealthy';
checks: {
openevidence: { status: string; latencyMs?: number };
cache: { status: string; hitRate?: number };
database: { status: string };
};
version: string;
timestamp: string;
}
export async function checkEnvironmentHealth(): Promise<EnvironmentHealth> {
const config = getConfig();
const checks: EnvironmentHealth['checks'] = {
openevidence: { status: 'unknown' },
cache: { status: 'unknown' },
database: { status: 'unknown' },
};
// Check OpenEvidence connectivity
try {
const client = OpenEvidenceClientFactory.getClient();
const start = Date.now();
await client.health.check();
checks.openevidence = {
status: 'healthy',
latencyMs: Date.now() - start,
};
} catch (error: any) {
checks.openevidence = { status: 'unhealthy' };
}
// Check cache
try {
if (config.cache.enabled) {
const stats = await cache.getStats();
checks.cache = {
status: 'healthy',
hitRate: stats.hitRate,
};
} else {
checks.cache = { status: 'disabled' };
}
} catch {
checks.cache = { status: 'unhealthy' };
}
// Check database
try {
await db.$queryRaw`SELECT 1`;
checks.database = { status: 'healthy' };
} catch {
checks.database = { status: 'unhealthy' };
}
// Determine overall status
const unhealthyCount = Object.values(checks).filter(
c => c.status === 'unhealthy'
).length;
let status: EnvironmentHealth['status'] = 'healthy';
if (unhealthyCount > 0) status = 'degraded';
if (checks.openevidence.status === 'unhealthy') status = 'unhealthy';
return {
environment: config.env,
status,
checks,
version: process.env.npm_package_version || 'unknown',
timestamp: new Date().toISOString(),
};
}
| Environment Issue | Detection | Resolution |
|---|---|---|
| Wrong API endpoint | Health check fails | Verify baseUrl in config |
| Secret not found | Startup failure | Check Secret Manager permissions |
| Config mismatch | Unexpected behavior | Validate config loading |
| Promotion failure | CI/CD error | Check version tagging |
For observability setup, see openevidence-observability.
Guide developers through setting up development environments with proper tools, dependencies, and configurations
Implement Exa lint rules, policy enforcement, and automated guardrails. Use when setting up code quality rules for Exa integrations, implementing pre-commit hooks, or configuring CI policy checks for Exa best practices. Trigger with phrases like "exa policy", "exa lint", "exa guardrails", "exa be...
Configure CI/CD pipelines for Documenso integrations. Use when setting up automated testing, deployment pipelines, or continuous integration for Documenso projects. Trigger with phrases like "documenso CI", "documenso GitHub Actions", "documenso pipeline", "documenso automated testing".
Build check model availability and implement fallback chains. Use when building resilient systems or handling model outages. Trigger with phrases like 'openrouter availability', 'openrouter fallback', 'openrouter model down', 'openrouter health check'.
Configure Langfuse enterprise organization management and access control. Use when implementing team access controls, configuring organization settings, or setting up role-based permissions for Langfuse projects. Trigger with phrases like "langfuse RBAC", "langfuse teams", "langfuse organization"...
Execute compliance and security auditing for Cursor usage. Triggers on "cursor compliance", "cursor audit", "cursor security review", "cursor soc2", "cursor gdpr". Use when analyzing or auditing cursor compliance audit. Trigger with phrases like "cursor compliance audit", "cursor audit", "cursor".
Configure Apollo.io CI/CD integration. Use when setting up automated testing, continuous integration, or deployment pipelines for Apollo integrations. Trigger with phrases like "apollo ci", "apollo github actions", "apollo pipeline", "apollo ci/cd", "apollo automated tests".
Create robust Python automation with full logging and safety checks. Use when tasks need complex data processing, authenticated API work, conditional file operations, or error handling beyond simple shell commands.
Configure PostHog across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific PostHog configurations. Trigger with phrases like "posthog environments", "posthog staging", "po...
Expert in designing and building autonomous AI agents. Masters tool use, memory systems, planning strategies, and multi-agent orchestration. Use when: build agent, AI agent, autonomous agent, tool use, function calling.
Validate insecure deserialization checker operations. Auto-activating skill for Security Fundamentals. Triggers on: insecure deserialization checker, insecure deserialization checker Part of the Security Fundamentals skill category. Use when working with insecure deserialization checker functiona...
Manage path traversal finder operations. Auto-activating skill for Security Fundamentals. Triggers on: path traversal finder, path traversal finder Part of the Security Fundamentals skill category. Use when working with path traversal finder functionality. Trigger with phrases like "path traversa...
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience