| 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".
|
| allowed-tools | Read, Write, Edit |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
| tags | ["saas","anthropic","claude","data","privacy","context"] |
| compatibility | Designed for Claude Code |
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.
const count = await client.messages.countTokens({
model: 'claude-sonnet-4-20250514',
messages,
system: systemPrompt,
});
const MAX_CONTEXT = 200_000;
const MAX_OUTPUT = 4096;
const inputBudget = MAX_CONTEXT - MAX_OUTPUT;
if (count.input_tokens > inputBudget) {
messages = trimToFit(messages, inputBudget);
}
Instructions
Step 1: Conversation Trimming
function trimConversation(messages: MessageParam[], maxTokens: number): MessageParam[] {
if (messages.length <= 4) return messages;
first = messages[];
recent = messages.(-);
[first, ...recent];
}