Skip to content

notque/vexjoy-agent / skills/programming/programming

programming

Flagged

Language rules, workflows, and tooling: Go, Python, Rust, Kotlin, Swift, PHP, TypeScript type checks and debugging, OpenStack Python, MCP local-docs servers, Node.js backend APIs.

FileKindSize
SKILL.mdskill md19.3 KB
references/go/code-review.mdmarkdown12.0 KB
references/go/code-review/common-review-comments.mdmarkdown6.6 KB
references/go/concurrency.mdmarkdown11.5 KB
references/go/concurrency/concurrency-patterns.mdmarkdown5.7 KB
references/go/error-handling.mdmarkdown10.8 KB
references/go/error-handling/patterns.mdmarkdown4.2 KB
references/go/google-style-guide/SHA256SUMSother313 B
references/go/google-style-guide/UPSTREAM_REVISIONother41 B
references/go/google-style-guide/best-practices/part-01.mdmarkdown10.0 KB
references/go/google-style-guide/best-practices/part-02.mdmarkdown15.0 KB
references/go/google-style-guide/best-practices/part-03.mdmarkdown14.1 KB
references/go/google-style-guide/best-practices/part-04.mdmarkdown13.5 KB
references/go/google-style-guide/best-practices/part-05.mdmarkdown10.5 KB
references/go/google-style-guide/best-practices/part-06.mdmarkdown14.4 KB
references/go/google-style-guide/best-practices/part-07.mdmarkdown16.1 KB
references/go/google-style-guide/best-practices/part-08.mdmarkdown11.4 KB
references/go/google-style-guide/best-practices/part-09.mdmarkdown13.7 KB
references/go/google-style-guide/best-practices/part-10.mdmarkdown16.9 KB
references/go/google-style-guide/decisions/part-01.mdmarkdown15.0 KB
references/go/google-style-guide/decisions/part-02.mdmarkdown12.5 KB
references/go/google-style-guide/decisions/part-03.mdmarkdown11.5 KB
references/go/google-style-guide/decisions/part-04.mdmarkdown8.4 KB
references/go/google-style-guide/decisions/part-05.mdmarkdown9.8 KB
references/go/google-style-guide/decisions/part-06.mdmarkdown14.7 KB
references/go/google-style-guide/decisions/part-07.mdmarkdown13.3 KB
references/go/google-style-guide/decisions/part-08.mdmarkdown14.3 KB
references/go/google-style-guide/decisions/part-09.mdmarkdown15.3 KB
references/go/google-style-guide/decisions/part-10.mdmarkdown8.3 KB
references/go/google-style-guide/guide/part-01.mdmarkdown16.3 KB
references/go/google-style-guide/guide/part-02.mdmarkdown3.0 KB
references/go/google-style-guide/index.mdmarkdown8.4 KB
references/go/preferred-patterns.mdmarkdown12.5 KB
references/go/preferred-patterns/code-examples.mdmarkdown11.6 KB
references/go/quality-gate.mdmarkdown7.3 KB
references/go/quality-gate/common-lint-errors.jsonconfig7.6 KB
references/go/quality-gate/examples.mdmarkdown11.0 KB
references/go/quality-gate/makefile-targets.jsonconfig5.1 KB
references/go/sapcc-conventions.mdmarkdown34.6 KB
references/go/sapcc-conventions/api-design-detailed.mdmarkdown22.7 KB
references/go/sapcc-conventions/architecture-patterns.mdmarkdown18.6 KB
references/go/sapcc-conventions/build-ci-detailed.mdmarkdown18.7 KB
references/go/sapcc-conventions/error-handling-detailed.mdmarkdown20.1 KB
references/go/sapcc-conventions/extended-patterns.mdmarkdown7.1 KB
references/go/sapcc-conventions/go-bits-philosophy-detailed.mdmarkdown24.5 KB
references/go/sapcc-conventions/library-reference.mdmarkdown14.0 KB
references/go/sapcc-conventions/pr-mining-insights.mdmarkdown17.5 KB
references/go/sapcc-conventions/review-standards.mdmarkdown10.5 KB
references/go/sapcc-conventions/sapcc-code-patterns.mdmarkdown46.2 KB
references/go/testing.mdmarkdown9.7 KB
references/go/testing/go-benchmark-and-concurrency.mdmarkdown5.6 KB
references/go/testing/go-test-patterns.mdmarkdown9.0 KB
references/golang-general.mdmarkdown8.9 KB
references/golang-general/go-modern-code.mdmarkdown17.2 KB
references/golang-general/go-verification-workflow.mdmarkdown5.0 KB
references/golang-general/go-version-idioms.mdmarkdown6.8 KB
references/kotlin-general.mdmarkdown7.5 KB
references/kotlin-general/kotlin-patterns.mdmarkdown7.9 KB
references/kotlin-general/kotlin-security-testing.mdmarkdown4.4 KB
references/kotlin-general/kotlin-security.mdmarkdown11.1 KB
references/kotlin/concurrency-patterns.mdmarkdown5.4 KB
references/kotlin/kotlin-testing.mdmarkdown7.9 KB
references/mcp-local-docs.mdmarkdown6.9 KB
references/mcp-local-docs/mcp-patterns.mdmarkdown9.6 KB
references/mcp-local-docs/mcp-preferred-patterns.mdmarkdown6.9 KB
references/mcp-local-docs/server-templates.mdmarkdown4.4 KB
references/mcp-local-docs/typescript-async-patterns.mdmarkdown8.9 KB
references/nodejs-api.mdmarkdown7.3 KB
references/nodejs-api/auth-patterns.mdmarkdown10.0 KB
references/nodejs-api/middleware-patterns.mdmarkdown10.5 KB
references/nodejs-api/nodejs-security.mdmarkdown12.3 KB
references/nodejs-api/webhook-patterns.mdmarkdown9.9 KB
references/php-general.mdmarkdown4.7 KB
references/php-general/php-behaviors.mdmarkdown5.2 KB
references/php-general/php-conventions.mdmarkdown5.8 KB
references/php/modern-php-features.mdmarkdown4.4 KB
references/php/testing-patterns.mdmarkdown7.5 KB
references/python-general.mdmarkdown7.7 KB
references/python-general/flask-jinja-webapp.mdmarkdown5.7 KB
references/python-general/python-local-gates.mdmarkdown4.4 KB
references/python-general/python-modern-code.mdmarkdown23.1 KB
references/python-openstack.mdmarkdown5.2 KB
references/python-openstack/error-handling.mdmarkdown658 B
references/python-openstack/hacking-rules.mdmarkdown4.1 KB
references/python-openstack/openstack-patterns.mdmarkdown1.2 KB
references/python-openstack/oslo-patterns.mdmarkdown6.4 KB
references/python-openstack/output-format.mdmarkdown2.4 KB
references/python-openstack/preferred-patterns.mdmarkdown1.9 KB
references/python-openstack/rpc-versioning.mdmarkdown5.3 KB
references/rust-general.mdmarkdown8.2 KB
references/rust-general/rust-modern-code.mdmarkdown13.4 KB
references/rust-general/rust-verification-workflow.mdmarkdown5.5 KB
references/rust-general/rust-version-idioms.mdmarkdown7.0 KB
references/swift-general.mdmarkdown5.7 KB
references/swift-general/swift-patterns.mdmarkdown6.7 KB
references/swift-general/swift-security-testing.mdmarkdown6.6 KB
references/swift-general/swift-security.mdmarkdown13.3 KB
references/swift/preferred-patterns.mdmarkdown2.4 KB
references/swift/swift-testing.mdmarkdown6.6 KB
references/swift/task-patterns.mdmarkdown3.6 KB
references/typescript-debugging.mdmarkdown9.3 KB
references/typescript-debugging/debugging-workflows-async-memory.mdmarkdown5.8 KB
references/typescript-debugging/debugging-workflows.mdmarkdown5.6 KB
scripts/bench-compare.shscript7.1 KB
scripts/check-errors.shscript7.1 KB
scripts/check-interface-compliance.shscript6.4 KB
scripts/check-sapcc-auth-ordering.shscript5.5 KB
scripts/check-sapcc-httptest.shscript4.4 KB
scripts/check-sapcc-identify-endpoint.shscript5.8 KB
scripts/check-sapcc-json-strict.shscript4.9 KB
scripts/check-sapcc-time-now.shscript4.2 KB
scripts/check-sapcc-todo-format.shscript4.1 KB
scripts/gen-table-test.shscript4.2 KB
scripts/quality_checker.pyscript16.2 KB
scripts/sync-google-style-guide.pyscript2.5 KB
scripts/validate.pyscript6.3 KB

references/nodejs-api/nodejs-security.md

View on GitHub
# Node.js Secure Implementation Patterns

Secure-by-default patterns for Node.js backend applications. Each section shows what correct code looks like and why it matters. Load this reference when the task involves security, auth, injection, XSS, CSRF, SSRF, prototype pollution, or any vulnerability-related code.

---

## Use execFile Instead of exec for Process Spawning

Use `execFile` or `spawn` (with `shell: false`, the default) for subprocess calls. These pass arguments as separate argv entries without invoking a shell.

```ts
import { execFile, execFileSync, spawn } from 'child_process';

// Correct: execFile passes args directly to the binary
execFile('git', ['clone', '--', userUrl], (err, stdout) => {
    if (err) console.error('clone failed:', err.message);
});

// Correct: spawn with default shell: false
const child = spawn('convert', [userInput, 'output.png']);

// Correct: execFileSync for synchronous operations
const output = execFileSync('git', ['log', '--oneline', '-5']);
```

**Why this matters**: `exec` and `execSync` always invoke a shell, where metacharacters (`;`, `|`, `&`, `$()`) are interpreted. On Windows, `spawn`/`execFile` targeting `.bat`/`.cmd` files implicitly route through `cmd.exe` regardless of the `shell` option (CVE-2024-27980, fixed in Node 18.20.0 / 20.12.0 / 21.7.0).

**Detection**:
```bash
rg -n '\bexec\(|\bexecSync\(' . --type ts --type js
rg -n 'shell:\s*true' . --type ts --type js
```

---

## Prevent Prototype Pollution With Safe Object Handling

Use Zod or similar schema validation before merging user input into objects. For key-value stores with user-controlled keys, use `Map` or `Object.create(null)`.

```ts
import { z } from 'zod';

// Correct: validate shape with Zod before any merge
const ConfigSchema = z.object({
    theme: z.enum(['light', 'dark']).optional(),
    language: z.string().max(5).optional(),
});
const validated = ConfigSchema.parse(req.body);
const merged = { ...defaultConfig, ...validated };

// Correct: use Map for user-controlled keys
const userSettings = new Map<string, unknown>();
for (const [key, value] of Object.entries(validatedInput)) {
    userSettings.set(key, value);
}

// Correct: prototype-free object for lookups
const lookup = Object.create(null) as Record<string, string>;
```

**Why this matters**: Deep-merging `req.body` into objects without filtering `__proto__`, `constructor`, or `prototype` keys pollutes `Object.prototype`. Downstream code that reads properties from shared objects (template engines, HTTP clients, auth checks) picks up attacker-injected values. CVE-2019-10744 (lodash `defaultsDeep`), CVE-2019-19919 (Handlebars compile-time RCE), and CVE-2026-40175 (axios header injection bypassing IMDSv2) demonstrate the full attack chain.

**Detection**:
```bash
rg -n '_\.(merge|defaultsDeep|set|setWith)\(.*req\.' . --type ts --type js
rg -n 'Object\.assign\(.*req\.' . --type ts --type js
rg -n 'for\s*\(.*Object\.keys\(.*req\.' . --type ts --type js
```

---

## Order Express Middleware for Auth Before Routes

Mount authentication middleware before route handlers. Middleware executes in registration order; auth mounted after a route leaves that route unprotected.

```ts
import express from 'express';
import helmet from 'helmet';
import rateLimit from 'express-rate-limit';

const app = express();

// 1. Security headers first
app.use(helmet());

// 2. Body parsing
app.use(express.json({ strict: true }));

// 3. Rate limiting
app.use('/api/', rateLimit({
    windowMs: 60_000,
    max: 100,
    standardHeaders: true,
}));

// 4. Auth middleware BEFORE routes
app.use('/api/', authMiddleware);

// 5. Routes come last
app.use('/api/users', userRouter);
app.use('/api/invoices', invoiceRouter);

// 6. Error handler at the end
app.use(errorHandler);
```

**Why this matters**: Express processes middleware in the order registered. If a route is mounted before auth middleware, requests to that route bypass authentication entirely. This is the Express-equivalent of "forced browsing."

**Detection**:
```bash
rg -n 'app\.use\(' . --type ts --type js | head -30
```

---

## Pin JWT Algorithms and Verify Claims

Always pass an explicit `algorithms` allowlist when verifying JWTs. Verify `exp`, `aud`, and `iss` claims. Use short-lived access tokens with refresh tokens for revocability.

```ts
import jwt from 'jsonwebtoken';

// Correct: pin algorithm, verify standard claims
const payload = jwt.verify(token, publicKey, {
    algorithms: ['RS256'],        // Pin to a single algorithm family
    audience: 'api.example.com',  // Verify audience
    issuer: 'auth.example.com',   // Verify issuer
});

// Correct: sign with explicit algorithm and short expiry
const token = jwt.sign(
    { sub: user.id, role: user.role },
    privateKey,
    {
        algorithm: 'RS256',
        expiresIn: '15m',         // Short-lived access token
        audience: 'api.example.com',
        issuer: 'auth.example.com',
    },
);
```

**Why this matters**: `jwt.verify(token, key)` without `algorithms` allows the attacker to choose the algorithm. CVE-2022-23540 and CVE-2022-23541 (jsonwebtoken < 9.0.0) allowed `alg: none` verification and RS-to-HS key confusion. CVE-2022-29217 (PyJWT) had the same class of bug. Never include `"none"` in the algorithms list. Never mix HS and RS algorithms with a single key.

**Detection**:
```bash
rg -n 'jwt\.verify\(' . --type ts --type js | rg -v 'algorithms'
rg -n 'jwt\.decode\(' . --type ts --type js
rg -n "algorithms.*none" . --type ts --type js
```

---

## Validate Outbound URLs to Prevent SSRF

Resolve hostnames to IPs and validate against private/internal ranges before making outbound requests. Disable redirect following or re-validate on each hop.

```ts
import { lookup } from 'dns/promises';
import ipaddr from 'ipaddr.js';

const DISALLOWED_RANGES = ['private', 'linkLocal', 'loopback', 'uniqueLocal', 'unspecified'];

async function safeFetch(userUrl: string): Promise<Response> {
    const url = new URL(userUrl);
    if (url.protocol !== 'https:' && url.protocol !== 'http:') {
        throw new Error('disallowed scheme');
    }
    const { address } = await lookup(url.hostname);
    const ip = ipaddr.parse(address);
    if (DISALLOWED_RANGES.includes(ip.range())) {
        throw new Error('disallowed IP range');
    }
    return fetch(url, { redirect: 'manual' });
}
```

**Why this matters**: User-controlled URLs reach internal services including cloud metadata endpoints (`169.254.169.254`). The Capital One breach (2019) stole IAM credentials via SSRF. String-based blocklists fail against DNS rebinding, IP encoding tricks, and redirects. CVE-2020-28168 (axios redirect bypass) and CVE-2026-40175 (axios header pollution to IMDS bypass) are Node-specific examples.

**Detection**:
```bash
rg -n 'fetch\(.*req\.|axios\.\w+\(.*req\.|got\(.*req\.' . --type ts --type js
rg -n "redirect.*'follow'|redirect.*'manual'" . --type ts --type js
```

---

## Validate All Input With Zod Schemas

Validate request body, query parameters, and path parameters with Zod schemas before processing. Treat all client data as untrusted.

```ts
import { z } from 'zod';

const CreateUserSchema = z.object({
    email: z.string().email(),
    displayName: z.string().min(1).max(100),
    role: z.enum(['user', 'editor']),  // Allowlist, not arbitrary string
});

app.post('/api/users', async (req, res) => {
    const result = CreateUserSchema.safeParse(req.body);
    if (!result.success) {
        return res.status(422).json({
            errors: result.error.flatten().fieldErrors,
        });
    }
    const { email, displayName, role } = result.data;
    // ...proceed with validated data
});
```

**Why this matters**: `req.body` without validation enables type confusion (string where number expected), mass assignment (extra fields like `isAdmin: true`), and prototype pollution (nested `__proto__` keys). Zod schemas reject unexpected fields by default and coerce types safely.

**Detection**:
```bash
rg -n 'req\.body\b' . --type ts --type js | rg -v 'parse\|safeParse\|validate'
rg -n 'req\.query\b|req\.params\b' . --type ts --type js | rg -v 'parse\|safeParse'
```

---

## Configure Security Headers With Helmet

Use Helmet middleware for security headers. Configure Content Security Policy explicitly for your application.

```ts
import helmet from 'helmet';

app.use(helmet({
    contentSecurityPolicy: {
        directives: {
            defaultSrc: ["'self'"],
            scriptSrc: ["'self'"],
            styleSrc: ["'self'", "'unsafe-inline'"],  // Only if CSS-in-JS requires it
            imgSrc: ["'self'", "https://cdn.example.com"],
            connectSrc: ["'self'", "https://api.example.com"],
        },
    },
    crossOriginEmbedderPolicy: true,
    crossOriginOpenerPolicy: true,
    crossOriginResourcePolicy: { policy: "same-site" },
    hsts: { maxAge: 31536000, includeSubDomains: true },
}));
```

**Why this matters**: Security headers prevent entire vulnerability classes: CSP blocks inline script injection (XSS), `X-Frame-Options`/`frame-ancestors` prevents clickjacking, HSTS forces HTTPS, and CORP/COEP prevent speculative execution side-channel attacks.

**Detection**:
```bash
rg -n 'helmet|Content-Security-Policy|X-Frame-Options' . --type ts --type js
```

---

## Serve Files With Path Containment

When serving user-requested files, resolve the path and verify it stays within the intended base directory.

```ts
import path from 'path';
import fs from 'fs';

const BASE = path.resolve('/var/app/exports');

app.get('/download', (req, res) => {
    const name = String(req.query.name);
    const target = path.resolve(BASE, name);

    // Containment check: resolved path must start with base directory
    if (!target.startsWith(BASE + path.sep)) {
        return res.sendStatus(403);
    }

    res.sendFile(target);
});

// Alternative: use Express root option (has built-in traversal rejection)
app.get('/download/:name', (req, res) => {
    res.sendFile(req.params.name, { root: '/var/app/exports' });
});
```

**Why this matters**: `path.join('/base', userInput)` returns `/etc/passwd` if `userInput` is `/etc/passwd` (absolute path replaces base). `../` sequences escape the directory. CVE-2023-26111 (node-static) leaked `/etc/passwd` and `.env` files through path traversal.

**Detection**:
```bash
rg -n 'res\.sendFile|fs\.(readFile|createReadStream).*req\.' . --type ts --type js
rg -n "express\.static\(\s*['\"]\.['\"]\s*\)" . --type ts --type js
```

---

## Return Generic Error Messages in Production

Return generic error messages to clients. Log detailed errors server-side with structured logging.

```ts
// Correct: global error handler with production/dev split
const errorHandler: ErrorRequestHandler = (err, req, res, _next) => {
    // Log full details server-side
    logger.error('request failed', {
        error: err.message,
        stack: err.stack,
        method: req.method,
        path: req.path,
        requestId: req.headers['x-request-id'],
    });

    // Return generic message to client
    const statusCode = err.statusCode ?? 500;
    res.status(statusCode).json({
        error: statusCode === 500 ? 'internal server error' : err.message,
    });
};
```

**Why this matters**: `res.json({ error: err.message, stack: err.stack })` leaks SQL fragments, internal paths, dependency versions, and configuration details. These help attackers map application internals and craft targeted exploits.

**Detection**:
```bash
rg -n 'err\.stack|e\.stack' . --type ts --type js | rg 'res\.\|json\.\|send'
rg -n 'err\.message' . --type ts --type js | rg 'res\.json\|res\.send'
```

---

## Use Select Clauses When Returning ORM Data

Always specify which columns to return from the database. Never send raw ORM rows to the client.

```ts
// Correct: Prisma select
const user = await prisma.user.findUnique({
    where: { id: userId },
    select: { id: true, displayName: true, avatarUrl: true },
});
return res.json(user);

// Correct: Sequelize attributes
const user = await User.findByPk(userId, {
    attributes: ['id', 'displayName', 'avatarUrl'],
});

// Correct: Drizzle select
const users = await db.select({
    id: usersTable.id,
    displayName: usersTable.displayName,
}).from(usersTable);
```

**Why this matters**: ORMs default to `SELECT *`. A raw row includes password hashes, API tokens, internal flags, and any column added by future migrations. Explicit select clauses act as a data-boundary filter.

**Detection**:
```bash
rg -n 'findUnique\(|findFirst\(|findMany\(' . --type ts | rg -v 'select'
rg -n 'res\.json\(.*await' . --type ts --type js
```
rea-changelog-updatemorluto/reaPrepare or rewrite REA release changelogs and GitHub release notes from pinned Git history, with verified contributor thanks and Release Please synchronization.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
academy-guideanthropics/skillsStop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
claude-apianthropics/skillsReference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIRST if no provider named — don't Read the file).Stars: 197kUpdated Claude CodeCodexUnverifiedInstall
doc-coauthoringanthropics/skillsGuide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.Stars: 197kUpdated Claude CodeCodexVerifiedInstall