config-management
Validate config at startup, secrets in memory only. Never read config during requests, never store secrets in env vars. Use node-env-resolver for multi-source config.
What this skill does
# Config Management
Validate once at startup, fail fast, never leak secrets.
## Core Principle
Configuration is a potential source of runtime errors. Validate at startup so failures happen immediately, not at 3 AM when a code path finally executes.
## Required Behaviors
### 1. Validate Config at Startup
Use [node-env-resolver](https://github.com/jagreehal/node-env-resolver) for multi-source configuration with validation:
```typescript
import { resolveAsync } from 'node-env-resolver';
import { processEnv } from 'node-env-resolver/resolvers';
import { postgres, string, number } from 'node-env-resolver/validators';
import { awsSecrets } from 'node-env-resolver-aws';
const config = await resolveAsync({
resolvers: [
// Non-sensitive config from process.env (safe)
[processEnv(), {
PORT: number({ default: 3000 }),
NODE_ENV: ['development', 'production'] as const,
}],
// Secrets loaded directly into memory from AWS (never touch process.env)
[awsSecrets({ secretId: 'my-app' }), {
DATABASE_URL: postgres(),
API_KEY: string(),
}],
],
options: {
preventProcessEnvWrite: true, // Secrets never touch process.env
},
});
```
**Alternative:** Use Zod directly for simpler setups:
```typescript
// config/schema.ts
import { z } from 'zod';
const ConfigSchema = z.object({
port: z.coerce.number().min(1).max(65535),
database: z.object({
host: z.string().min(1),
port: z.coerce.number(),
name: z.string().min(1),
}),
redis: z.object({
url: z.string().url(),
}),
logLevel: z.enum(['debug', 'info', 'warn', 'error']),
});
export type Config = z.infer<typeof ConfigSchema>;
// main.ts - Validate immediately on startup
const config = ConfigSchema.parse({
port: process.env.PORT,
database: {
host: process.env.DB_HOST,
port: process.env.DB_PORT,
name: process.env.DB_NAME,
},
redis: {
url: process.env.REDIS_URL,
},
logLevel: process.env.LOG_LEVEL,
});
// If we get here, config is valid and typed
```
### 2. Never Read Config During Requests
Config should be resolved ONCE at startup, then injected:
```typescript
// WRONG - Reading env vars during request
async function getUser(args: { userId: string }, deps: GetUserDeps) {
const timeout = parseInt(process.env.DB_TIMEOUT || '5000'); // Reads every call!
return deps.db.findUser(args.userId, { timeout });
}
// CORRECT - Config injected via deps
type GetUserDeps = {
db: Database;
config: { dbTimeout: number };
};
async function getUser(args: { userId: string }, deps: GetUserDeps) {
return deps.db.findUser(args.userId, { timeout: deps.config.dbTimeout });
}
```
### 3. Secrets in Memory Only
Never store secrets in environment variables. Load directly from secret managers into memory:
```typescript
// WRONG - Secret in env, visible in process dumps, /proc/self/environ, child processes
const apiKey = process.env.API_KEY;
// CORRECT - Fetch from secret manager at startup, loaded into memory only
const config = await resolveAsync({
resolvers: [
[awsSecrets({ secretId: 'my-app' }), {
API_KEY: string(),
DATABASE_PASSWORD: string(),
}],
],
options: {
preventProcessEnvWrite: true, // Secrets never touch process.env
},
});
// Secrets are in config object in memory, never in process.env
const deps = { db: createDb(config.DATABASE_PASSWORD), apiKey: config.API_KEY };
```
**Why memory is safer:**
- `process.env` is accessible to child processes
- On Linux, `/proc/self/environ` exposes all environment variables
- Error messages and logs may accidentally include environment variables
- Secrets in memory are isolated to your application process
### 3a. Ephemeral Credentials
Prefer short-lived, auto-rotating credentials over long-lived secrets:
```typescript
const config = await resolveAsync({
resolvers: [
[awsSecrets({
secretId: 'prod/db-creds',
refreshInterval: 3600000, // Refresh every hour
}), {
DB_USERNAME: string(),
DB_PASSWORD: string(), // Short-lived, auto-rotated
}],
],
});
```
If a credential leaks, automatic expiration limits the blast radius.
### 3b. Secret Scanning in CI
Runtime policies protect production, but what about the `.env` file that should never exist? Run secret scanning in CI:
```yaml
# .github/workflows/security.yml
name: Security Checks
on: [push, pull_request]
jobs:
secret-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for thorough scanning
- name: TruffleHog Secret Scan
uses: trufflesecurity/trufflehog@main
with:
extra_args: --only-verified
```
Tools like **TruffleHog** and **Gitleaks** scan commit history, catching secrets that were committed and then "deleted" (but still exist in git history).
### 4. Fail Fast on Missing Config
```typescript
// WRONG - Default values hide misconfiguration
const port = process.env.PORT || 3000;
const dbHost = process.env.DB_HOST || 'localhost';
// CORRECT - Fail immediately if missing
const ConfigSchema = z.object({
port: z.coerce.number(), // No default - must be provided
dbHost: z.string().min(1), // No default - must be provided
});
// Throws ZodError at startup if missing
const config = ConfigSchema.parse(process.env);
```
### 5. Type-Safe Config Access
Use Zod inference to ensure type safety:
```typescript
// Config type is inferred from schema
export type Config = z.infer<typeof ConfigSchema>;
// Deps include typed config
type GetUserDeps = {
db: Database;
config: Pick<Config, 'dbTimeout' | 'maxRetries'>;
};
```
## Environment-Specific Config
```typescript
const EnvSchema = z.enum(['development', 'staging', 'production']);
const BaseConfigSchema = z.object({
env: EnvSchema,
port: z.coerce.number(),
});
// Environment-specific overrides
const ProductionConfigSchema = BaseConfigSchema.extend({
env: z.literal('production'),
sslEnabled: z.literal(true),
});
const DevelopmentConfigSchema = BaseConfigSchema.extend({
env: z.literal('development'),
sslEnabled: z.literal(false).default(false),
});
const ConfigSchema = z.discriminatedUnion('env', [
ProductionConfigSchema,
DevelopmentConfigSchema,
]);
```
## Dependency Injection for Testability
Configuration resolution should accept resolvers as parameters:
```typescript
// config.ts
import { resolveAsync, type Resolver } from 'node-env-resolver';
import { processEnv } from 'node-env-resolver/resolvers';
import { awsSecrets } from 'node-env-resolver-aws';
import { postgres, string, number } from 'node-env-resolver/validators';
const schema = {
PORT: number({ default: 3000 }),
DATABASE_URL: postgres(),
API_KEY: string(),
};
export async function getConfig(
resolvers: Resolver[] = [
processEnv(),
awsSecrets({ secretId: 'my-app' }),
]
) {
return resolveAsync({
resolvers: resolvers.map(r => [r, schema]),
});
}
```
Now your tests can inject mock resolvers:
```typescript
// config.test.ts
import { getConfig } from './config';
it('should resolve configuration', async () => {
const mockResolver = {
name: 'test-env',
load: async () => ({
DATABASE_URL: 'postgres://test:5432/testdb',
API_KEY: 'test-key',
}),
loadSync: () => ({
DATABASE_URL: 'postgres://test:5432/testdb',
API_KEY: 'test-key',
}),
};
const config = await getConfig([mockResolver]);
expect(config.DATABASE_URL).toBe('postgres://test:5432/testdb');
expect(config.API_KEY).toBe('test-key');
expect(config.PORT).toBe(3000); // default value
});
```
No `vi.mock()` needed. Just pass a resolver object. This is the same dependency injection pattern we've been using throughout.
## Config in Tests
```typescript
import { mock } from 'vitest-mock-extended';
const testConfig: Pick<Config, 'dbTimeout'> = {
dbTimeout: 100, // Fast for tests
};
const deps = {
db: mock<Database>(),
config: testConfig,
};
const result = awaitRelated 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.