nostics
Structured diagnostic code library for JavaScript/TypeScript.
Skill by jd-solanki
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/jd-solanki-nostics
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: backend
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/nostics
What's inside
- Skill name
nostics- Description
- Structured diagnostic code library for JavaScript/TypeScript. Turns errors and other conditions into typed, machine-readable `Diagnostic` instances with stable codes, docs URLs, and actionable fields. Use this skill whenever the project imports `nostics`, or works with `defineDiagnostics`/`defineProdDiagnostics`, the `Diagnostic` class, diagnostic code registries, or structured error handling. Also covers reporters (`createConsoleReporter`, `createFetchReporter` from nostics/reporters/fetch, `createFileReporter` from nostics/reporters/node, `createDevReporter` from nostics/reporters/dev), formatters (`formatDiagnostic`, `ansiFormatter`, `jsonFormatter`), and Vite plugins (`nosticsStrip` from @nostics/unplugin/strip-transform, `nosticsCollector` from @nostics/unplugin/dev-server-collector). Also use when migrating a library's existing `console.warn`/`console.error`/`warn()` helpers or thrown `Error`s to diagnostics: follow `references/migration.md`.
- License
- MIT
- Instructions
- 151 lines in SKILL.md · view on GitHub
Files (3)
- SKILL.md
- documentation-site.md · references/
- migration.md · references/
SKILL.md (first lines)
# nostics
Every error condition becomes a typed `Diagnostic` (extends `Error`) with a stable code, docs URL, and actionable `fix`. Serializable via `toJSON()`.
`Diagnostic`: `name` (the code), `message`/`why` (interpolated text), `fix?`, `docs?`, `sources?` (`'file:line:column'`), `cause?`, `toJSON()`. Throw it, catch it with `instanceof Diagnostic`, send `toJSON()` across process boundaries.
## defineDiagnostics
Returns one callable handle per code. Calling a handle builds a fresh `Diagnostic`, fires every reporter in order, and returns it. `throw` the return value to raise (reporters still run, so a thrown diagnostic also reports).
```ts
import { createConsoleReporter, defineDiagnostics } from 'nostics'
const diagnostics = /*#__PURE__*/ defineDiagnostics({
docsBase: (code) => `https://nuxt.com/e/${code.replace('NUXT_', '').toLowerCase()}`,
reporters: [/*#__PURE__*/ createConsoleReporter()],
codes: {
NUXT_B1001: {
why: 'Could not compile template.',
fix: 'Check the template for syntax errors.',
},
NUXT_B2011: {
why: (p: { src: string }) => `Invalid plugin "${p.src}". src option is required.`,
fix: 'Pass a string path or an object with a `src` to `addPlugin()`.',
},
NUXT_W9001: { why: 'message', docs: false }, // per-code: string overrides docsBase, false opts out
},
})
```
- **`docsBase`** `string | (code) => string | undefined`: string appends `/${code.toLowerCase()}`; function returns the full URL (or `undefined` to omit).
- **`codes`**: each definition needs `why` (`string | (params) => string`, the only required field, becomes `Error.message`); optional `fix` (`string | (params) => string`), `docs` (`string | false`), and `data` (`object | (params) => object`). Each code's resolved `data` is typed and included in `toJSON()`.
- **`reporters`**: fired on every call; optional. Their `options` types are intersected; required reporter options become required at the call site. Omit it (or pass `[]`) for a catalog whose codes are only ever `throw`n: the thrown `Diagnostic` already carries the message, so a console reporter would print it once and surface it again from the uncaught error, a visible duplicate. Keep report-only warnings and fatal throws in separate catalogs when one needs a reporter and the other does not.
- **Param inference**: params from `why`, `fix`, and `data` are intersected and required at the call site. If `why` needs `{ src }` and `fix` needs `{ date }`, the call requires `{ src, date }`.
## Call sites
```ts
diagnostics.NUXT_B1001() // no params: report only
diagnostics.NUXT_B2011({ src: '/plugins/bad.ts' }) // params first
diagnostics.NUXT_B2011({
src,
cause: originalError,
sources: ['nuxt.config.ts:42:3'],
}) // runtime fields merge in
diagnostics.NUXT_B2011({ src }, { method: 'error' }) // reporter options second
throw diagnostics.NUXT_B2011({ src }) // raise
```
`cause`/`sources` go in the params object; `sources` matters most for build/config diagnostics where the JS stack points inside the library. Catch with `if (err instanceof Diagnostic)` then read `.name`, `.message`, `.fix`, `.docs`, and `.data`.
Definition data is not present in `defineProdDiagnostics()`. Its `.data` is `undefined`. A dev/prod ternary therefore types `.data` as the code's data type or `undefined`.
## Reporters
`(diagnostic: Diagnostic, options?: Opts) => void`. Declaring a required `options` type makes the second call-site argument required and typed.
| Reporter | Import | Description |
| --------------------------------- | ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `createConsoleReporter(options?)` | `nostics` | `console[method](formatter(d))`. `method` defaults `'warn'` (`'log'\|'warn'\|'error'`), `formatter` defaults `formatDiagnostic`; both via options, `method` also overridable per call. |
| `createFetchReporter(url)` | `nostics/reporters/fetch` | POSTs diagnostic JSON to the URL; failures swallowed. |
| `createFileReporter(options?)` | `nostics/reporters/node` | Appends NDJSON to a local file (default `.nostics.log`). |
| `createDevReporter()` | `nostics/reporters/dev` | Sends `toJSON()` to the Vite dev server via `import.meta.hot.send()`. |
```ts
import type { DiagnosticReporter } from 'nostics'
const sentryReporter: DiagnosticReporter = (d) =>
sentry.captureMessage(d.message, { tags: { code: d.name } })
const audited: DiagnosticReporter<{ priority: number }> = (d, o) =>
audit.log({ name: d.name, priority: o.priority })
// → audited makes diagnostics.X({...}, { priority: 1 }) required and type-checked.
```
## Formatters
| Formatter | Import | Description |
| ----------------------- | ------------------------- | ---------------------------------------------------------------------------------------------------------- |
| `formatDiagnostic` | `nostics` | Plain unicode-decorated string (built-in reporters use it). |
| `ansiFormatter(colors)` | `nostics/formatters/ansi` | Colorized; accepts a `Colors` interface (`red`/`yellow`/`cyan`/`gray`/`bold`/`dim`, each `(s) => string`). |
| `jsonFormatter` | `nostics/formatters/json` | `JSON.stringify(diagnostic)` via `toJSON()`. |
`formatDiagnostic` output, detail order fixed `fix` → `sources` → `see`, missing fields omitted:
```
[NUXT_B2011] Invalid plugin `/plugins/bad.ts`. src option is required.
├▶ fix: Pass a string path or an object with a `src` to `addPlugin()`.
├▶ sources: nuxt.config.ts:42:3
╰▶ see: https://nuxt.com/e/b2011
```
## Vite plugins (`@nostics/unplugin`, dev dependency)
`@nostics/unplugin/strip-transform` (library authors, build optimization) and `@nostics/unplugin/dev-server-collector` (app developers, dev-time collection). Both unplugin-based: `.vite()`, `.webpack()`, `.rollup()`, etc.
- **`nosticsStrip`** marks `defineDiagnostics()` `/*#__PURE__*/` and wraps bare diagnostic expression statements with a `NODE_ENV` guard so they tree-shake out of production. Option `packageName?` (default `'nostics'`). Throws/returns/assignments stay (they are behavior). For tracking: relative imports, export the catalog directly, no factory wrappers or deep barrels.
- The plugin is optional. The same production output happens with no build transform if the catalog is annotated by hand: put `/*#__PURE__*/` before `defineDiagnostics(` and before each reporter factory call inside it (as in every example here), and dev-guard each report-only call site (`process.env.NODE_ENV !== 'production' && diagnostics.CODE(p)`). Always write the annotations in source; reach for the plugin when report-only call sites are unguarded and you want stripping without touching them.
- **`nosticsCollector`** listens for `createDevReporter()` diagnostics over the Vite WebSocket and writes them as NDJSON via `createFileReporter`. Vite-only. Options `logFile?` (default `.nostics.log`), `debug?` (default `!!process.env.DEBUG`).
```ts
// vite.config.ts
import { nosticsStrip } from '@nostics/unplugin/strip-transform'
import { nosticsCollector } from '@nostics/unplugin/dev-server-collector'
export default defineConfig({
plugins: [nosticsStrip.vite(), nosticsCollector.vite()],
})
// src/diagnostics.ts — pair the collector with createDevReporter()
import { createConsoleReporter, defineDiagnostics } from 'nostics'
import { createDevReporter } from 'nostics/reporters/dev'
export const diagnostics = /*#__PURE__*/ defineDiagnostics({
reporters: [/*#__PURE__*/ createConsoleReporter(), /*#__PURE__*/ createDevReporter()],
codes: {/* ... */},
})
```
## Production builds
- **Report-only** diagnostics (bare `diagnostics.X()`) should disappear: `nosticsStrip` or hand annotations drop them, then the unused catalog tree-shakes.
- **Surviving** diagnostics (`throw`/`return`/assigned/argument) stay, and each keeps the _whole_ catalog reachable, so every `why`/`fix` ships. Not every library throws in production: if yours only reports, stripping is enough, stop here.From jd-solanki/ai, MIT.
More from jd-solanki/ai
- 0.629score
clean-code
jd-solanki
Write readable, maintainable code through disciplined naming, focused functions, and clean error handling.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
ponytail
jd-solanki
Lazy senior dev mode: the smallest change that fully solves the task, and a reply a busy human understands in one read.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
context7-cli
jd-solanki
Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-audit
jd-solanki
Quality audit of a whole repo: bugs, security holes, what breaks under real load, risky code without tests, slow paths, and what to delete, merge or split.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-commit-based-gh-release-changelog
jd-solanki
Automate GitHub release creation and changelog generation from Conventional Commits using changelogithub — includes GitHub release mechanics, tag-based…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-npm-release
jd-solanki
Automate npm package publishing via GitHub Actions for single-package repos and independent monorepo packages, including bumpp version tags, GitHub release…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-review
jd-solanki
Quality review of a change: is the logic right, is it safe, does it hold under real load, is risky code tested, is it fast enough, and is every line needed.
SkillAFreshness: A★ 7Claude Code +9 - 0.618score
add-diagnostic
jd-solanki
Add a new diagnostic code following the defineDiagnostics() conventions from nostics
SkillAFreshness: A★ 7Claude Code +9 - 0.594score
codebase-design
jd-solanki
Shared vocabulary for designing deep modules.
SkillAFreshness: A★ 7Claude Code +9 - 0.583score
implement
jd-solanki
Implement a piece of work based on a spec or set of tickets.
SkillAFreshness: A★ 7Claude Code +9 - 0.576score
bruno
jd-solanki
Create and manage Bruno API collections in the Bru Lang (.bru) format - adding a request, creating an environment, writing pre/post scripts, or scaffolding a…
SkillBFreshness: B★ 7Claude Code +9 - 0.574score
aws-best-practices
jd-solanki
AWS service-specific best practices and configuration rules.
SkillBFreshness: B★ 7Claude Code +9
Signals
- Stars
- 7
- Forks
- 2
- Open issues
- 9
- Last commit (this folder)
- Oct 4, 2026 (24 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/jd-solanki/ai
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from jd-solanki
- 0.629score
clean-code
jd-solanki
Write readable, maintainable code through disciplined naming, focused functions, and clean error handling.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
context7-cli
jd-solanki
Use the ctx7 CLI to fetch library documentation, manage AI coding skills, and configure Context7 MCP.
SkillAFreshness: A★ 7Claude Code +9 - 0.624score
ponytail
jd-solanki
Lazy senior dev mode: the smallest change that fully solves the task, and a reply a busy human understands in one read.
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-npm-release
jd-solanki
Automate npm package publishing via GitHub Actions for single-package repos and independent monorepo packages, including bumpp version tags, GitHub release…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
automate-commit-based-gh-release-changelog
jd-solanki
Automate GitHub release creation and changelog generation from Conventional Commits using changelogithub — includes GitHub release mechanics, tag-based…
SkillAFreshness: A★ 7Claude Code +9 - 0.619score
ponytail-review
jd-solanki
Quality review of a change: is the logic right, is it safe, does it hold under real load, is risky code tested, is it fast enough, and is every line needed.
SkillAFreshness: A★ 7Claude Code +9
Cite this page
nostics skill. Agent Mart. https://agentmart.dev/skills/jd-solanki-nostics (last updated 2026-10-24)