スキル一覧に戻る
CaseMark

redaction-tool

by CaseMark

Thurgood developed web app the uses regex and case.dev api to redact PII and other sensitive information

0🍴 0📅 2025年12月31日
GitHubで見るManusで実行

SKILL.md


name: redaction-tool description: | 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.

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

LayerTechnology
FrontendNext.js 14, React, Tailwind CSS
UIshadcn/ui
PDF Processingpdf.js (extract), pdf-lib (generate)
AI DetectionCase.dev LLM (GPT-4o)
DatabasePostgreSQL + Prisma (optional)

Key Features

FeatureDescription
Two-Pass DetectionRegex + AI for comprehensive coverage
PII TypesSSN, bank accounts, credit cards, names, addresses, phone, email, DOB
PresetsPre-configured redaction profiles
Entity ReviewToggle, edit masked values
PDF ExportGenerate redacted documents
Audit LogTrack 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

PresetTypes Included
SSNs and FinancialSSN, Account Numbers, Credit Cards
All Personal InformationAll PII types
Contact Information OnlyPhone, Email
Financial OnlyAccount Numbers, Credit Cards

Case.dev Integration

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

LLM Detection

const aiEntities = await detectWithLLM(text, piiTypes);

OCR for Images

const text = await extractTextFromImage(imageUrl);

Development

Setup

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)

npx prisma migrate dev

API Endpoints

MethodEndpointDescription
POST/api/detect-piiTwo-pass PII detection
POST/api/export-pdfGenerate redacted PDF
POST/api/uploadFile upload
GET/api/jobsList jobs
GET/api/jobs/:idGet 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

IssueSolution
Regex missing PIICheck pattern, add variations
AI too aggressiveAdjust prompt confidence
PDF export failsVerify pdf-lib compatibility
OCR errorsUse higher quality images

スコア

総合スコア

70/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です