Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsCommunityBlog
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Bar Js

ASecurity

Framework-agnostic TypeScript API response builder (@vorlaxen-labs/bar-js). Standardizes JSON envelopes with semantic presets, request tracing, pagination, cookies, hooks, and security headers. Use when building REST API responses, Express middleware, res.builder patterns, or consistent error/success shapes.

6 stars
0 votes
0 copies
0 views
Added 9/28/2026
ai-agentstypescriptrustnodeexpressapisecuritydocumentation

Works with

api

Security Analysis

A100/100

Scanned 9/28/2026

Install to Claude Code

$npx -y skills add vorlaxen-labs/Agent-Skills --skill bar-js --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Bar Js?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Bar Js
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vorlaxen-labs-bar-js/badge)](https://www.skillsdirectory.com/skills/vorlaxen-labs-bar-js)

More formats (shields.io, HTML) on the badges page.

Files
SKILL.md
---
name: bar-js
npmPackage: "@vorlaxen-labs/bar-js"
npmVersion: "2.0.0"
description: >-
  Framework-agnostic TypeScript API response builder (@vorlaxen-labs/bar-js).
  Standardizes JSON envelopes with semantic presets, request tracing, pagination,
  cookies, hooks, and security headers. Use when building REST API responses,
  Express middleware, res.builder patterns, or consistent error/success shapes.
---
# BaR (Builder a Response)

**Package:** `@vorlaxen-labs/bar-js` v2.0.0 · **Zero runtime deps**

Framework-agnostic response builder that replaces ad-hoc `res.status().json()` with a fluent, typed API enforcing a single response contract.

---

## Critical Rules

1. **Register `bar.handler()` before route handlers** — injects `res.builder` and `req.bar.ctx`.
2. **Always call `.build()`** to dispatch — chaining alone does not send a response.
3. **Use semantic presets** (`.as.ok()`, `.as.created()`, etc.) instead of raw status codes.
4. **Use `.wrap(promise)`** for async routes — then call `.build()` or `.message()`. Do **not** call `.as.ok(undefined)` after `wrap()` — it overwrites resolved data with `null`.
5. **Set `environment: 'production'`** in prod — masks internal error details in `wrap()`.
6. **Never invent response fields** — follow the envelope schema below.

---

## Response Envelope

Every response follows this shape:

```typescript
interface IResponse<T = unknown, M = unknown> {
  success: boolean;
  timestamp: string;       // ISO 8601 at build time
  message?: string;
  data: T | null;
  metadata: {
    request_id: string;
    server_time: string;
    status_code: number;
  } & M;
}
```

- `success` is `true` for status `200–399` (unless `.forceSuccess()` overrides).
- `metadata.request_id` is auto-generated or read from `X-Request-Id` / `X-Correlation-Id` / `traceparent`.

---

## Quick Start

```typescript
import express from 'express';
import { BarExpressAdapter } from '@vorlaxen-labs/bar-js';

const app = express();
const bar = new BarExpressAdapter({
  environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',
  logger: console,
});

app.use(bar.handler());
app.use(express.json());

app.get('/api/users/:id', async (req, res) => {
  await res.builder.wrap(userService.findById(req.params.id));
  return res.builder.message('User retrieved').build();
});
```

---

## Semantic Presets (`.as.*`)

| Method | Status | Default Message |
|---|---|---|
| `ok(data?, message?)` | 200 | `"Success"` |
| `created(data?, message?)` | 201 | `"Resource created"` |
| `accepted(message?)` | 202 | `"Request accepted"` |
| `noContent()` | 204 | `""` |
| `badRequest(message?)` | 400 | `"Bad Request"` |
| `unauthorized(message?)` | 401 | `"Unauthorized access"` |
| `forbidden(message?)` | 403 | `"Access forbidden"` |
| `notFound(message?)` | 404 | `"Resource not found"` |
| `conflict(message?)` | 409 | `"Conflict detected"` |
| `unprocessable(message?)` | 422 | `"Unprocessable entity"` |
| `tooManyRequests(message?)` | 429 | `"Too many requests, please slow down"` |
| `internalServerError(message?)` | 500 | `"Internal server error"` |
| `serviceUnavailable(message?)` | 503 | `"Service temporarily unavailable"` |
| `gatewayTimeout(message?)` | 504 | `"Gateway timeout"` |

---

## Common Patterns

### Async with wrap

```typescript
app.post('/api/users', async (req, res) => {
  await res.builder.wrap(userService.create(req.body));
  return res.builder.message('User created').status(201).build();
});
```

### Pagination

```typescript
return res.builder
  .as.ok(users)
  .paginate(total, page, limit)
  .build();
```

### Conditional chaining

```typescript
return res.builder
  .as.ok(data)
  .when(includeMeta, b => b.setMeta({ version: '2.0' }))
  .build();
```

### Request tracing

```typescript
const { request_id, start_time } = req.bar.ctx;
// request_id appears in every response metadata
```

---

## Middleware Order

```
1. Trust proxy / CORS
2. bar.handler()          ← injects builder + context
3. express.json()
4. Route handlers
5. Not found middleware
6. Global exception filter
```

---

## Adapter Options

| Option | Default | Description |
|---|---|---|
| `withDefaultHeaders` | enabled | Security headers on every response |
| `environment` | `undefined` | `'production'` hides internal errors in `wrap()` |
| `includeStack` | `undefined` | Stack traces in dev error messages |
| `logger` | `undefined` | Logger for adapter and builder events |
| `hooks` | `undefined` | Lifecycle hooks (`before_build`, `after_build`, etc.) |

---

## When NOT to Use BaR

- GraphQL or gRPC exclusively
- Streaming/SSE responses (BaR is JSON-focused)
- API already has a mature, enforced response envelope that cannot change

---

## Reference Documentation

| Topic | File |
|---|---|
| Installation & setup | [reference/getting-started.md](reference/getting-started.md) |
| Full method listing | [reference/api-reference.md](reference/api-reference.md) |
| Envelope field details | [reference/response-schema.md](reference/response-schema.md) |
| All `.as.*` presets | [reference/semantic-presets.md](reference/semantic-presets.md) |
| `wrap()`, `transform()`, `when()` | [reference/advanced-chaining.md](reference/advanced-chaining.md) |
| List endpoints | [reference/pagination.md](reference/pagination.md) |
| Request ID & correlation | [reference/request-tracing.md](reference/request-tracing.md) |
| Error handling & masking | [reference/error-handling.md](reference/error-handling.md) |
| Cookies & headers | [reference/cookies-headers.md](reference/cookies-headers.md) |
| Lifecycle hooks | [reference/hooks.md](reference/hooks.md) |
| Security headers | [reference/security.md](reference/security.md) |
| Fastify / custom adapters | [reference/adapters.md](reference/adapters.md) |
| Production patterns | [reference/recipes.md](reference/recipes.md) |
| TypeScript generics | [reference/typescript.md](reference/typescript.md) |

Attribution

vorlaxen-labsvorlaxen-labs
View sourceMore from vorlaxen-labs →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Ultra-compressed communication mode that cuts output tokens while keeping technical accuracy. Levels: lite, full, ultra and the wenyan variants. Use for /caveman, "caveman mode", "talk like caveman", "be brief" or "less tokens".

1074701 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

695601 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3351 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

691 votes

math-skill

A comprehensive mathematical reasoning skill for AI assistants — handles arithmetic to research-level problems with rigorous step-by-step reasoning, systematic verification, and transparent uncertainty handling

381 votes
View all in ai-agents →