errors

Rules requiring the project to use its own named error classes for failures. These errors carry a readable message, a code for programs, and a suggested solution.

In plain words
What is it for?
Use it when adding or handling failures involving missing files, Git, configuration, permissions, manifests, backups, or GitHub command-line operations.
Why use it?
It keeps error handling consistent and helps both people and software understand what went wrong and how to address it.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/pranav-karra-3301/tuck/errors
Clone the repo
git clone --depth 1 https://github.com/Pranav-Karra-3301/tuck

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 560 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00560
Opus 5 $0.00000 $0.00280
Sonnet 5 $0.00000 $0.00112
Haiku 4.5 $0.00000 $0.00056

Measured yesterday against content hash d16729fb88f9, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

errors scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/errors.mdc · 118 lines

How it starts

The opening of the file, as written. The whole thing — 118 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Error Handling Rules

Custom Error Classes

ALWAYS use custom errors from src/errors.ts:

import {
  TuckError,                // Base error class
  NotInitializedError,      // Tuck not set up
  AlreadyInitializedError,  // Already initialized
  FileNotFoundError,        // File doesn't exist
  FileNotTrackedError,      // File not in manifest
  FileAlreadyTrackedError,  // Already tracked
  GitError,                 // Git operation failed
  ConfigError,              // Configuration issue
  ManifestError,            // Manifest corruption
  PermissionError,          // Can't read/write
  GitHubCliError,           // GitHub CLI issues
  BackupError,              // Backup/snapshot issues
} from '../errors.js';

Error Structure

All custom errors include:

  • Human-readable message
  • Error code for programmatic handling
  • Suggestions for resolution
throw new FileNotFoundError(path, {
  suggestion: "Run 'tuck add' to track this file first"
});

Error Handling Patterns

Catching Errors

// Good - handle specific error
try {
  await loadManifest(tuckDir);
} catch (error) {
  if (error instanceof ManifestError) {
    throw new NotInitializedError();
  }
  throw error; // Re-throw unknown errors
}

NEVER Do

// Bad - silent failure
await operation().catch(() => {});

// Bad - generic error
throw new Error('Something went wrong');

// Bad - swallowing errors
try {
  await operation();
} catch {
  // Do nothing
}

User-Facing Errors

Errors shown to users should:

  1. Explain what happened
  2. Suggest how to fix it
  3. Be actionable
// Good
throw new ConfigError(
  'Configuration file is corrupted',
  {
    code: 'CONFIG_CORRUPT',
    suggestion: "Run 'tuck config reset' to restore defaults"
  }
);

Logging Errors

Use the logger for debug info, not console:

import { logger } from '../ui/index.js';

logger.debug('Processing file:', filePath);
logger.error('Failed to read file:', error.message);

Read the full file on GitHub · 118 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 118 lines · 0 tokens per session scan A d16729fb88f9

Subscribe to this mod's changes

errors is a cursor rule published in the GitHub repository Pranav-Karra-3301/tuck (14 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 560 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.