# Prefer Standard Library Over Third-Party
## Rule
Always use `@std` packages from JSR for common functionality before reaching for third-party alternatives. The standard library is audited, maintained by the Deno team, and version-stable.
## Standard Library Coverage
| Need | Package | Example |
|------|---------|---------|
| HTTP server | `@std/http` | `Deno.serve(handler)` |
| Path ops | `@std/path` | `join(), resolve(), extname()` |
| File I/O | `@std/fs` | `ensureDir(), copy(), walk()` |
| Testing | `@std/assert` | `assertEquals(), assertThrows()` |
| Encoding | `@std/encoding` | `base64, hex, csv, toml` |
| Crypto | `@std/crypto` | `crypto.subtle + digest helpers` |
| CLI | `@std/cli` | `parseArgs(), promptSecret()` |
| Streams | `@std/streams` | `TextLineStream, toText()` |
## Good Examples
```typescript
import { join } from "@std/path";
import { ensureDir } from "@std/fs";
import { assertEquals } from "@std/assert";
import { parseArgs } from "@std/cli";
const args = parseArgs(Deno.args, {
string: ["output"],
boolean: ["verbose"],
default: { verbose: false },
});
await ensureDir(join(Deno.cwd(), "output"));
```
## Bad Examples
```typescript
// BAD: Third-party when std covers the use case
import path from "npm:path"; // Use @std/path
import fs from "npm:fs-extra"; // Use @std/fs
import { expect } from "npm:chai"; // Use @std/assert
import minimist from "npm:minimist"; // Use @std/cli
```
## Enforcement
- Lint rule to flag npm: imports when @std equivalent exists
- Code review checklist: verify std library was considered first
- Document exceptions where third-party is genuinely better