stacks-config

$npx mdskill add stacksjs/stacks/stacks-config

Manage Stacks configuration files, helpers, and builder functions.

  • Access and modify 44 config files and environment-specific overrides.
  • Depends on @stacksjs/config package and config/ directory.
  • Uses config builder functions like defineApp and defineDatabase.
  • Returns full config object or individual config exports.

SKILL.md

.github/skills/stacks-configView on GitHub ↗
---
name: stacks-config
description: Use when working with Stacks configuration — the 44 config files, config helper functions, default values, environment-specific overrides, or the defineApp/defineDatabase/etc builder functions. Covers @stacksjs/config and the config/ directory.
license: MIT
compatibility: Bun >= 1.3.0, TypeScript
allowed-tools: Read Edit Write Bash Grep Glob
---

# Stacks Configuration

## Key Paths
- Core package: `storage/framework/core/config/src/`
- Configuration directory: `config/`
- Defaults: `storage/framework/core/config/src/defaults.ts`
- Overrides: `storage/framework/core/config/src/overrides.ts`

## Config API

```typescript
import { config, getConfig } from '@stacksjs/config'

config.app.name       // 'Stacks'
config.database       // full database config
config.auth           // auth config
getConfig()           // returns full StacksOptions
```

## Individual Config Exports

```typescript
import { ai, analytics, app, auth, cache, cloud, cli, database, dns, docs, email, errors, git, hashing, library, logging, notification, payment, ports, queue, realtime, security, saas, searchEngine, services, filesystems, team, ui } from '@stacksjs/config'
```

## Config Builder Functions

```typescript
import { defineApp, defineDatabase, defineCache, defineEmail } from '@stacksjs/config'

// Used in config files:
export default defineApp({
  name: 'My App',
  env: 'production',
  url: 'https://myapp.com'
}) satisfies AppConfig
```

All builders: `defineApp`, `defineCache`, `defineCdn`, `defineChat`, `defineCli`, `defineDatabase`, `defineDependencies`, `defineDns`, `defineEmailConfig`, `defineEmail`, `defineGit`, `defineHashing`, `defineLibrary`, `defineNotification`, `definePayment`, `defineQueue`, `defineSearchEngine`, `defineSecurity`, `defineServices`, `defineSms`, `defineFilesystems`, `defineUi`, `defineModel`, `defineEvents`

## Helper Functions
- `determineAppEnv(): 'dev' | 'stage' | 'prod' | string`
- `localUrl(): string` — local development URL

## All 44 Config Files

### Core App
| File | Type | Key Settings |
|------|------|-------------|
| `app.ts` | AppConfig | name, env, url, debug, key, timezone, locale |
| `auth.ts` | AuthConfig | guards, providers, tokenExpiry(30d), tokenRotation(7d), passwordReset |
| `database.ts` | DatabaseConfig | default driver, connections (sqlite/mysql/postgres/dynamodb), queryLogging |
| `cache.ts` | CacheConfig | driver('memory'), ttl(3600), maxKeys(-1), redis config |
| `env.ts` | EnvConfig | validation schemas for env vars |
| `stacks.ts` | StackExtensionRegistry | extension definitions |

### Services
| File | Type | Key Settings |
|------|------|-------------|
| `email.ts` | EmailConfig | from, domain, mailboxes, server config, ports, categorization, default('ses') |
| `sms.ts` | SmsConfig | enabled(false), provider('twilio'), drivers (twilio/vonage/pinpoint) |
| `notification.ts` | NotificationConfig | default('email') |
| `payment.ts` | PaymentConfig | driver('stripe'), stripe keys |
| `ai.ts` | AiConfig | default model, AWS Bedrock models |
| `analytics.ts` | AnalyticsConfig | driver('fathom'), tracking settings |

### Infrastructure
| File | Type | Key Settings |
|------|------|-------------|
| `cloud.ts` | CloudConfig | project, mode(server/serverless), environments, infrastructure |
| `dns.ts` | DnsConfig | a, aaaa, cname, mx, txt records, nameservers |
| `queue.ts` | QueueConfig | default('sync'), connections (sync/database/redis/sqs/memory) |
| `realtime.ts` | RealtimeConfig | enabled(true), mode, driver, channels, WebSocket config |
| `search-engine.ts` | SearchEngineConfig | driver('opensearch') |

### Development
| File | Type | Key Settings |
|------|------|-------------|
| `ports.ts` | Ports | frontend:3000, backend:3001, admin:3002, ... api:3008 |
| `lint.ts` | PickierOptions | format rules, indent, quotes, semi |
| `git.ts` | GitConfig | hooks, scopes, commit types |
| `commit.ts` | UserConfig | cz-git conventional commit config |
| `logging.ts` | LoggingConfig | logsPath, deploymentsPath |
| `docs.ts` | BunPressOptions | docsDir, outDir, nav, sitemap |

### Security
| File | Type | Key Settings |
|------|------|-------------|
| `security.ts` | SecurityConfig | firewall (enabled, countryCodes, rateLimitPerMinute:500) |
| `hashing.ts` | HashingConfig | driver('bcrypt'), bcrypt.rounds(12), argon2 config |

### Features
| File | Type | Key Settings |
|------|------|-------------|
| `blog.ts` | BlogConfig | subdomain, postsPerPage, enableComments/RSS/sitemap |
| `cms.ts` | CmsConfig | content management settings |
| `saas.ts` | SaasConfig | plans (Hobby/Pro/Lifetime with pricing), webhook, currencies |
| `ui.ts` | HeadwindOptions | content, output, minify |
| `stx.ts` | StxOptions | componentsDir, layoutsDir, partialsDir |

### Data & Storage
| File | Type | Key Settings |
|------|------|-------------|
| `filesystems.ts` | FilesystemsConfig | driver('bun'), root, s3 config, defaultVisibility('private') |
| `file-systems.ts` | — | re-exports from filesystems.ts |
| `query-builder.ts` | — | re-exports from qb.ts |
| `qb.ts` | QueryBuilderConfig | dialect, timestamps, pagination, softDeletes, transactions |

### Other
| File | Type | Key Settings |
|------|------|-------------|
| `buddy-bot.ts` | BuddyBotConfig | repository, dashboard, workflows |
| `cli.ts` | BinaryConfig | name, command, description |
| `deps.ts` | PantryConfig | system dependencies (bun, sqlite, redis, etc.) |
| `errors.ts` | ErrorConfig | comprehensive validation error messages |
| `library.ts` | LibraryConfig | name, owner, webComponents, functions |
| `phone.ts` | PhoneConfig | enabled, provider, businessHours |
| `services.ts` | ServicesConfig | API keys for 20+ services |
| `team.ts` | Team | name, members |

## Default Values (from defaults.ts)
- App name: `'Stacks'`
- Cache driver: `'memory'`
- Database: SQLite at `database/stacks.sqlite`
- Hashing: bcrypt, 12 rounds
- Auth token expiry: 30 days
- Ports: frontend 3000, backend 3001, admin 3002, api 3008

## Gotchas
- Config files are TypeScript with `satisfies` for type checking
- All configs support environment variable overrides via `env.*`
- Framework provides defaults — user overrides in `~/config/*.ts`
- Two duplicate file pairs: `file-systems.ts`/`filesystems.ts` and `query-builder.ts`/`qb.ts`
- Config changes may require dev server restart
- The `services.ts` file contains API keys for AWS, Stripe, Slack, Discord, OpenAI, Anthropic, etc.
- Lazy loading is used in config to avoid circular dependencies

More from stacksjs/stacks

SkillDescription
stacks-actionsUse when working with Stacks server actions — creating actions in app/Actions/, auto-generated API actions from the useApi model trait, the 80+ default framework actions (auth, dashboard, commerce, content, deployment, jobs), action request/response handling, or action registration. Covers @stacksjs/actions and storage/framework/defaults/actions/.
stacks-aiUse when integrating AI capabilities into a Stacks application — using Anthropic/OpenAI/Ollama/AWS Bedrock drivers, image generation (DALL-E), vision analysis, RAG/vector search, embeddings, MCP (Model Context Protocol) clients, text summarization, sentiment analysis, content classification, personalization, or the buddy AI assistant. Covers @stacksjs/ai and config/ai.ts.
stacks-aliasUse when working with path aliases in a Stacks project — import resolution, module aliasing, or debugging import paths. Covers @stacksjs/alias which defines 260+ path mappings for the entire framework.
stacks-analyticsUse when adding analytics to a Stacks application — configuring Fathom or self-hosted analytics, generating tracking scripts, privacy-friendly analytics setup, or the analytics configuration. Covers @stacksjs/analytics and config/analytics.ts.
stacks-apiUse when building, modifying, or debugging API endpoints in a Stacks application — defining routes, handling requests, API middleware, working with the API server, HTTP client (fetcher), API resources, or OpenAPI generation. Covers both @stacksjs/api utilities and the stacks-api server implementation.
stacks-arraysUse when working with array utilities in Stacks — statistical operations (average, median, mode, standard deviation, z-score, percentile, covariance), array manipulation (unique, flatten, partition, shuffle, sample, move), containment checks, or the Arr facade. Covers @stacksjs/arrays.
stacks-authUse when implementing authentication, authorization, passkeys, TOTP/2FA, RBAC, gates, policies, session auth, token management, email verification, password resets, or rate limiting in a Stacks application. Covers the @stacksjs/auth package, config/auth.ts, app/Gates.ts, and app/Middleware/.
stacks-auto-importsUse when working with the Stacks auto-import system — understanding how browser and server auto-imports work, configuring auto-imported functions/models/composables, the auto-import manifests, type generation, or how globals are injected. Covers the auto-import pipeline at storage/framework/auto-imports/.
stacks-brandkitUse when defining or exploring a brand identity for a Stacks project and you want premium brand-kit REFERENCE IMAGES first - logo directions, palettes, typography specimens, identity boards, and application/mockup decks. Generates IMAGES ONLY, never code. Trained for minimalist, cinematic, editorial, dark-tech, luxury, cultural, security, gaming, developer-tool, and consumer-app brand systems with intentional logo concepting, sparse type, strong symbolic meaning, and disciplined palettes a coding step can build against.
stacks-browseUse for headless browser QA on Stacks applications — navigation, screenshots, responsive testing, console/network monitoring, and accessibility snapshots. Dependency-free: drives a system browser over the Chrome DevTools Protocol using only Bun (no Playwright/Puppeteer). Invoke with /stacks-browse.