Skip to content
OpenSmartRoute
Skillv1.0.0

clade-data-handling

Handle sensitive data with Claude — PII redaction, conversation management, Use when working with data-handling patterns. context window optimization, and data retention policies. Trigger with "anthro

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (skills/.curated/clade-data-handling/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill clade-data-handling. Copyright stays with the author (MIT).

Anthropic Data Handling

Overview

Handle data responsibly when building with Claude — manage the 200K token context window efficiently, implement conversation trimming strategies, redact PII before sending to the API, and configure data retention settings.

Context Window Management

Claude models have a 200K token context window. Managing it efficiently is critical.

// Count tokens before sending
const count = await client.messages.countTokens({
  model: 'claude-sonnet-4-20250514',
  messages,
  system: systemPrompt,
});

// Budget: 200K total - max_tokens (output) = available input
const MAX_CONTEXT = 200_000;
const MAX_OUTPUT = 4096;
const inputBudget = MAX_CONTEXT - MAX_OUTPUT;

if (count.input_tokens > inputBudget) {
  // Trim oldest messages, keep system prompt + recent context
  messages = trimToFit(messages, inputBudget);
}

Instructions

Step 1: Conversation Trimming

function trimConversation(messages: MessageParam[], maxTokens: number): MessageParam[] {
  // Always keep the first message (often contains key context)
  // Keep the most recent messages
  // Drop middle turns first
  if (messages.length <= 4) return messages;

  const first = messages[0];
  const recent = messages.slice(-6); // Last 3 turns
  return [first, ...recent];
}

PII Handling

// Strip PII before sending to Claude (if not needed for the task)
function redactPII(text: string): string {
  return text
    .replace(/\b[\w._%+-]+@[\w.-]+\.\w{2,}\b/g, '[EMAIL]')
    .replace(/\b\d{3}[-.]?\d{3}[-.]?\d{4}\b/g, '[PHONE]')
    .replace(/\b\d{3}-\d{2}-\d{4}\b/g, '[SSN]')
    .replace(/\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g, '[CARD]');
}

Data Retention

  • Default: Anthropic does not use API data for training
  • Zero retention: Available on Enterprise plans
  • Your responsibility: Don't store Claude responses containing user PII longer than needed

Output

  • Token counting implemented before sending requests (prevents context overflow errors)
  • Conversation trimming preserving first message and recent turns
  • PII redaction applied for emails, phone numbers, SSNs, and card numbers
  • Data retention policy documented and configured

Error Handling

Error Cause Solution
API Error Check error type and status code See clade-common-errors

Examples

See Context Window Management (token counting + budget), Conversation Trimming function, and PII Handling regex patterns above.

Resources

Next Steps

See clade-enterprise-rbac for organization and access management.

Prerequisites

  • Completed clade-install-auth
  • Application handling user conversations or document processing
  • Understanding of token counting and context windows

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-clade-data-handling/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-clade-data-handling.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-clade-data-handling",
  "kind": "skill",
  "name": "clade-data-handling",
  "description": "Handle sensitive data with Claude — PII redaction, conversation management, Use when working with data-handling patterns. context window optimization, and data retention policies. Trigger with \"anthropic data privacy\", \"claude pii\", \"anthropic context window\", \"manage claude conversations\", \"anthropic data retention\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "saas",
      "anthropic",
      "claude",
      "data",
      "privacy",
      "context",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Handle sensitive data with Claude — PII redaction, conversation management, Use when working with data-handling patterns. context window optimization, and data retention policies. Trigger with \"anthropic data privacy\", \"claude pii\", \"anthropic context window\", \"manage claude conversations\", \"anthropic data retention\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "skills/.curated/clade-data-handling/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/skills/.curated/clade-data-handling/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/skills/.curated/clade-data-handling/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit"
    ],
    "license": "MIT"
  },
  "instructions": "# Anthropic Data Handling\n\n## Overview\n\nHandle data responsibly when building with Claude — manage the 200K token context window efficiently, implement conversation trimming strategies, redact PII before sending to the API, and configure data retention settings.\n\n## Context Window Management\n\nClaude models have a 200K token context window. Managing it efficiently is critical.\n\n```typescript\n// Count tokens before sending\nconst count = await client.messages.countTokens({\n  model: 'claude-sonnet-4-20250514',\n  messages,\n  system: systemPrompt,\n});\n\n// Budget: 200K total - max_tokens (output) = a",
  "cost": {
    "context_tokens": 743
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-clade-data-handling/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.