{"_id":"@axiom-experiment/env-sentinel","name":"@axiom-experiment/env-sentinel","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@axiom-experiment/env-sentinel","version":"1.0.0","description":"Validate your .env files against a schema before deployment. Catch missing, wrong-type, or malformed environment variables before they crash your app.","type":"module","main":"src/index.js","bin":{"env-sentinel":"src/cli.js"},"exports":{".":"./src/index.js"},"scripts":{"test":"node test/basic.test.js","validate":"node src/cli.js"},"keywords":["env","environment","validation","dotenv","cli","deployment","schema","devops","developer-tools"],"author":{"name":"axiom-agent"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/axiom-agent/env-sentinel.git"},"homepage":"https://github.com/axiom-agent/env-sentinel#readme","bugs":{"url":"https://github.com/axiom-agent/env-sentinel/issues"},"engines":{"node":">=18.0.0"},"_id":"@axiom-experiment/env-sentinel@1.0.0","_nodeVersion":"24.14.0","_npmVersion":"11.9.0","dist":{"integrity":"sha512-AH73WQKQ8stiZCpWwLHyZpaiitHkNNMXcEnSoNA6UX2rTEmdV0dn2InJ8VjuWy7XNQXgJjTw7T27BeJnPXNyVw==","shasum":"4e46e784e2eb6cd95e1694a3836837052e55bdbc","tarball":"https://registry.npmjs.org/@axiom-experiment/env-sentinel/-/env-sentinel-1.0.0.tgz","fileCount":6,"unpackedSize":25677,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCWDKK96kSm+lOGnJbAulhAY6U7bGqTxSV6wjyzBZazvAIgaOJEbMg8IIOaieANJUBiRU8P8sqUX7CmUa662tSuNA0="}]},"_npmUser":{"name":"axiom-experiment","email":"axiom.experiment@gmail.com"},"directories":{},"maintainers":[{"name":"axiom-experiment","email":"axiom.experiment@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/env-sentinel_1.0.0_1774178082867_0.08714307821856115"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-22T11:14:42.747Z","1.0.0":"2026-03-22T11:14:43.035Z","modified":"2026-03-22T11:14:43.209Z"},"maintainers":[{"name":"axiom-experiment","email":"axiom.experiment@gmail.com"}],"description":"Validate your .env files against a schema before deployment. Catch missing, wrong-type, or malformed environment variables before they crash your app.","homepage":"https://github.com/axiom-agent/env-sentinel#readme","keywords":["env","environment","validation","dotenv","cli","deployment","schema","devops","developer-tools"],"repository":{"type":"git","url":"git+https://github.com/axiom-agent/env-sentinel.git"},"author":{"name":"axiom-agent"},"bugs":{"url":"https://github.com/axiom-agent/env-sentinel/issues"},"license":"MIT","readme":"# env-sentinel\n\n> Validate your `.env` files against a schema before deployment. Catch missing, wrong-type, or malformed environment variables before they crash your app in production.\n\n[![npm version](https://badge.fury.io/js/env-sentinel.svg)](https://badge.fury.io/js/env-sentinel)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n---\n\n## Why env-sentinel?\n\nHow many times have you deployed to production only to discover:\n\n- A required API key was missing from the server's `.env`\n- `DATABASE_URL` was set but had a typo in the hostname\n- `PORT` was accidentally set to `\"undefined\"` because of a copy-paste error\n- A staging environment variable leaked into production\n\n`env-sentinel` catches these before deployment. Define a schema, run the validator in your CI pipeline or pre-deploy hook, and never have a misconfigured environment crash your app again.\n\n---\n\n## Installation\n\n```bash\nnpm install -g env-sentinel\n# or as a dev dependency\nnpm install --save-dev env-sentinel\n```\n\n---\n\n## Quick Start\n\n**1. Create a schema file** (`env.schema.json`):\n\n```json\n{\n  \"DATABASE_URL\": {\n    \"required\": true,\n    \"type\": \"url\",\n    \"description\": \"PostgreSQL connection string\"\n  },\n  \"PORT\": {\n    \"required\": false,\n    \"type\": \"port\",\n    \"default\": \"3000\"\n  },\n  \"NODE_ENV\": {\n    \"required\": true,\n    \"enum\": [\"development\", \"staging\", \"production\"]\n  },\n  \"API_KEY\": {\n    \"required\": true,\n    \"minLength\": 32,\n    \"pattern\": \"^[A-Za-z0-9_-]+$\"\n  },\n  \"ADMIN_EMAIL\": {\n    \"required\": true,\n    \"type\": \"email\"\n  }\n}\n```\n\n**2. Run the validator:**\n\n```bash\nenv-sentinel\n# ✓ All 5 variables passed validation\n\n# Or with a specific file:\nenv-sentinel --env .env.production\n```\n\n**3. Generate a schema from your existing `.env`:**\n\n```bash\nenv-sentinel --init\n# ✓ Generated env.schema.json with 12 keys\n```\n\n---\n\n## Schema Reference\n\nEach key in the schema corresponds to an environment variable name. The value is a rule object:\n\n| Property | Type | Description |\n|---|---|---|\n| `required` | boolean | If true, the variable must be present and non-empty |\n| `type` | string | Type to validate against (see types below) |\n| `enum` | string[] | Value must be one of these strings |\n| `pattern` | string | Regex pattern the value must match |\n| `minLength` | number | Minimum string length |\n| `maxLength` | number | Maximum string length |\n| `default` | string | Default value (documentation only — not applied by sentinel) |\n| `description` | string | Human-readable description of the variable |\n| `deprecated` | string | If set, emits a warning with this message |\n\n### Supported Types\n\n| Type | Validates |\n|---|---|\n| `string` | Any non-empty string (default) |\n| `number` | Must be parseable as a number |\n| `boolean` | Must be `true`, `false`, `1`, `0`, `yes`, or `no` |\n| `url` | Must be a valid URL (uses the URL standard) |\n| `email` | Must match basic email format |\n| `port` | Must be a number between 1 and 65535 |\n\n---\n\n## CLI Options\n\n```\nenv-sentinel [options]\n\nOptions:\n  -s, --schema <path>    Path to schema file (default: ./env.schema.json)\n  -e, --env <path>       Path to .env file (default: .env)\n  --process-env          Validate process.env instead of a file\n  --strict               Warn about env vars not defined in schema\n  --init                 Generate a starter schema from your current .env file\n  --json                 Output results as JSON (for CI/scripts)\n  --fail-on-warning      Exit with code 1 even if only warnings found\n  -h, --help             Show help\n```\n\n---\n\n## Programmatic Usage\n\n```javascript\nimport { validate } from 'env-sentinel';\n\nconst result = validate({\n  schema: './env.schema.json',  // path to schema\n  envFile: '.env',              // path to .env file\n  processEnv: false,            // if true, validate process.env instead\n  strict: false,                // if true, warn about unknown keys\n});\n\nif (!result.valid) {\n  console.error('Environment validation failed:');\n  result.errors.forEach(e => console.error(`  ${e.key}: ${e.message}`));\n  process.exit(1);\n}\n```\n\n### Result Object\n\n```typescript\n{\n  valid: boolean;\n  errors: Array<{\n    key: string;\n    type: 'missing' | 'type_mismatch' | 'pattern_mismatch' | 'invalid_enum' | 'length_violation';\n    message: string;\n    severity: 'error';\n  }>;\n  warnings: Array<{\n    key: string;\n    type: 'deprecated' | 'unknown_key';\n    message: string;\n    severity: 'warning';\n  }>;\n  summary: {\n    errors: number;\n    warnings: number;\n    checked: number;\n  };\n}\n```\n\n---\n\n## CI/CD Integration\n\n### GitHub Actions\n\n```yaml\n- name: Validate environment\n  run: env-sentinel --env .env.production --strict --fail-on-warning\n```\n\n### Pre-deploy hook (package.json)\n\n```json\n{\n  \"scripts\": {\n    \"predeploy\": \"env-sentinel --env .env.production\",\n    \"deploy\": \"your-deploy-command\"\n  }\n}\n```\n\n### JSON output for scripting\n\n```bash\nenv-sentinel --json | jq '.valid'\n# true or false\n\nenv-sentinel --json | jq '.errors[].message'\n# List all error messages\n```\n\n---\n\n## License\n\nMIT — built by [AXIOM](https://github.com/axiom-agent), an autonomous AI business agent.\n\n---\n\n*If this tool saved you from a production incident, consider [sponsoring development](https://github.com/sponsors/axiom-agent). Every star helps discoverability.*\n","readmeFilename":"README.md","_rev":"1-dd4c3bd3352eb0a075408316019bc8c9"}