Agent skill

redaction-tool

Development skill for CaseMark's Smart Redaction Tool - an intelligent document redaction application with two-pass PII detection combining regex patterns and AI-powered semantic analysis. Built with Next.js 14, pdf.js/pdf-lib, and Case.dev LLMs. Use this skill when: (1) Working on the redaction-tool codebase, (2) Adding or modifying regex patterns, (3) Implementing AI detection features, (4) Building PDF export functionality, or (5) Adding new PII types.

Stars 0
Forks 0

Install this agent skill to your Project

npx add-skill https://github.com/CaseMark/redaction-tool/tree/main/.skill

SKILL.md

Redaction Tool Development Guide

An intelligent document redaction application with two-pass PII detection—regex patterns for standard formats plus AI semantic analysis for contextual data.

Live site: https://redaction-tool.casedev.app/

Architecture

src/
├── app/
│   ├── page.tsx                    # Main application UI
│   └── api/
│       ├── detect-pii/             # Two-pass PII detection
│       ├── export-pdf/             # PDF generation
│       ├── detect/                 # Database-backed detection
│       ├── export/                 # Database-backed export
│       ├── jobs/                   # Job management
│       └── upload/                 # File upload
├── components/
│   ├── redaction/
│   │   ├── PatternSelector.tsx     # Redaction type selection
│   │   ├── EntityList.tsx          # Detected entities
│   │   └── DocumentPreview.tsx     # Preview with highlights
│   ├── upload/
│   │   └── DropZone.tsx            # File upload
│   └── ui/                         # shadcn components
└── lib/
    ├── redaction/
    │   ├── detector.ts             # Two-pass detection logic
    │   └── patterns.ts             # Regex patterns & presets
    ├── case-dev/
    │   └── client.ts               # Case.dev API client
    ├── db.ts                       # Database connection
    └── utils.ts                    # Utilities

Core Workflow

Upload Doc → Extract Text → Pass 1: Regex → Pass 2: AI → Review → Export PDF
     ↓            ↓             ↓              ↓           ↓          ↓
  PDF/TXT      pdf.js       SSN, CC,       Names,      Toggle      Redacted
  images       extraction   phone, email   addresses   entities    document
                            patterns       context

Tech Stack

Layer Technology
Frontend Next.js 14, React, Tailwind CSS
UI shadcn/ui
PDF Processing pdf.js (extract), pdf-lib (generate)
AI Detection Case.dev LLM (GPT-4o)
Database PostgreSQL + Prisma (optional)

Key Features

Feature Description
Two-Pass Detection Regex + AI for comprehensive coverage
PII Types SSN, bank accounts, credit cards, names, addresses, phone, email, DOB
Presets Pre-configured redaction profiles
Entity Review Toggle, edit masked values
PDF Export Generate redacted documents
Audit Log Track what was redacted

Two-Pass Detection

See references/pii-detection.md for patterns and AI prompts.

Pass 1: Regex (Fast, High-Precision)

  • SSN: XXX-XX-XXXX with validation
  • Credit cards: Luhn-valid patterns
  • Phone: US formats
  • Email: Standard format
  • Dates: Common formats

Pass 2: AI/LLM (Semantic, Aggressive)

  • Non-standard formats ("SSN: one two three...")
  • Contextual references ("my social is...")
  • Names and addresses
  • OCR errors and typos
  • Obfuscated data

Redaction Presets

Preset Types Included
SSNs and Financial SSN, Account Numbers, Credit Cards
All Personal Information All PII types
Contact Information Only Phone, Email
Financial Only Account Numbers, Credit Cards

Case.dev Integration

See references/casedev-redaction-api.md for API patterns.

LLM Detection

typescript
const aiEntities = await detectWithLLM(text, piiTypes);

OCR for Images

typescript
const text = await extractTextFromImage(imageUrl);

Development

Setup

bash
npm install
cp .env.example .env
# Add CASEDEV_API_KEY
npm run dev

Environment

CASEDEV_API_KEY=sk_case_...               # Required
DATABASE_URL=postgresql://...             # Optional for job persistence

Database (Optional)

bash
npx prisma migrate dev

API Endpoints

Method Endpoint Description
POST /api/detect-pii Two-pass PII detection
POST /api/export-pdf Generate redacted PDF
POST /api/upload File upload
GET /api/jobs List jobs
GET /api/jobs/:id Get job status

Common Tasks

Adding a New PII Type

  1. Add regex pattern to lib/redaction/patterns.ts
  2. Add to AI prompt in lib/redaction/detector.ts
  3. Add UI toggle in PatternSelector.tsx
  4. Add masking function

Improving AI Detection

Modify the LLM prompt to be more/less aggressive or handle specific formats.

Adding Export Format

  1. Add generation function in lib/export/
  2. Add endpoint in api/export-[format]/
  3. Add UI option

Troubleshooting

Issue Solution
Regex missing PII Check pattern, add variations
AI too aggressive Adjust prompt confidence
PDF export fails Verify pdf-lib compatibility
OCR errors Use higher quality images

Expand your agent's capabilities with these related and highly-rated skills.

CaseMark/court-record-transcriber

court-record-transcriber

Development skill for CaseMark's Court Recording Transcriber - an AI-powered application for transcribing court recordings with speaker identification, synchronized playback, search, and legal document exports. Built with Next.js 16, PostgreSQL, Drizzle ORM, wavesurfer.js, and Case.dev APIs. Use this skill when: (1) Working on or extending the court-record-transcriber codebase, (2) Integrating with Case.dev transcription APIs, (3) Working with audio playback/waveforms, (4) Building transcript export features, or (5) Adding speaker identification logic.

0 0
Explore
mattpocock/skills

obsidian-vault

Search, create, and manage notes in the Obsidian vault with wikilinks and index notes. Use when user wants to find, create, or organize notes in Obsidian.

111,310 9,758
Explore
mattpocock/skills

scaffold-exercises

Create exercise directory structures with sections, problems, solutions, and explainers that pass linting. Use when user wants to scaffold exercises, create exercise stubs, or set up a new course section.

111,310 9,758
Explore
mattpocock/skills

setup-pre-commit

Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

111,310 9,758
Explore
mattpocock/skills

git-guardrails-claude-code

Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.

111,310 9,758
Explore
mattpocock/skills

handoff

Compact the current conversation into a handoff document for another agent to pick up.

111,310 9,758
Explore

Didn't find tool you were looking for?

Be as detailed as possible for better results