seanpedrick-case/doc_redaction/doc-redaction-modifications
Claude Code and agent skill by seanpedrick-case/doc_redaction
- community
Checking that the SKILL.md file is still in the repository.
Review and reapply: two-pass workflow — Pass 1 (OCR/CSV/text, default) then optional Pass 2 (VLM per page). Edit *_review_file.csv, preview, /review_apply, verify. Parallel page orchestration → doc-redact-page-review. Initial redaction → doc-redaction-app.
Install
npx vskill@latest install seanpedrick-case/doc_redaction/doc-redaction-modificationsSKILL.md
Goal
Repeatable review → edit CSV → preview → `/review_apply` → download → verify when you already have the original PDF and a matching *_review_file.csv.
Initial redaction only: `../doc-redaction-app/SKILL.md`.
Parallel page-range review (subagents): `../doc-redact-page-review/SKILL.md` — one child per page for Pass 1, parent merges and applies once; Pass 2 (optional VLM) runs after Pass 1 outputs exist.
Two-pass review model
Review is split into a fast, text-based first pass (default) and an optional visual second pass. Do not run VLM on every page unless the user explicitly requests Pass 2 or you are re-checking specific flagged pages.
| Pass 1 — OCR / CSV / text (default) | Pass 2 — Visual VLM (optional) | ||
|---|---|---|---|
| Inputs | *_review_file.csv, *_ocr_output_* (line), *_ocr_results_with_words_* (word), original PDF | Pass 1 outputs: merged CSV, *_redacted.pdf, preview/redaction overlay PNGs | |
| Methods | Row edits, word/line OCR alignment, regex/policy rules, overlap checks, PyMuPDF text extraction, local preview_redaction_boxes | OpenAI-compatible VLM (/v1/chat/completions + page PNG) | |
| Cost / time | Low — no image tokens | High — ~1–2 min/page on local VLMs; scales with page count | |
| When | Always — completes the first reviewed apply | User asks for visual QA; high-risk pages; Pass 1 text checks inconclusive | |
| Apply | One /review_apply after Pass 1 merge | Edit CSV from VLM findings → one more /review_apply if changes made |
Default workflow: Pass 1 only → deliver. Run Pass 2 only when needed.
Endpoint semantics (do not get this wrong)
| Endpoint | Applies redaction? | Text layer stripped? | Output to use | |
|---|---|---|---|---|
/doc_redact | Proposes boxes; may emit an early *_redacted.pdf | Run-dependent | Review CSV + OCR — treat as draft until Pass 1 review + apply | |
/preview_boxes | No — draws boxes on rendered page images only | N/A | Coordinate QA only | |
/review_apply | Yes — from original PDF + `*_review_file.csv` | Yes — PyMuPDF redaction + apply_redactions() | *_redacted.pdf |
Never implement a custom “true redaction” PyMuPDF script because text_layer_leaks appeared. Fix CSV coverage and coordinates first, then call /review_apply again. Exception: reading PyMuPDF word positions to add normalized CSV rows is allowed — writing the final PDF without /review_apply is not (see task template § Agent anti-confusion rules).
Never run post-apply text-layer checks on *_redactions_for_review.pdf — that file retains text for human review. /review_apply returns both files; only *_redacted.pdf is the deliverable.
Use `tools/verify_redaction_coverage.py` or POST /agent/verify_redaction_coverage — do not reimplement coverage logic ad hoc (pandas/regex scripts). On split-container Pi deployments, pre-apply checks use the CLI on downloaded artifacts (edited CSV is local); post-apply checks use the Agent API with server paths — see § Split-container verify below.
Text-layer leak troubleshooting
When text_layer_leaks appear on *_redacted.pdf:
- Confirm the PDF basename ends with
_redacted.pdf(not_redactions_for_review.pdf). - Pre-apply: all
xmin/ymin/xmax/ymaxmust be normalized 0–1 (df[bbox_cols].max().max() <= 1). Never paste PyMuPDF absolute points without dividing by page width/height. - Read
leak_likely_causeson each page in the coverage report:
| Cause | Meaning | Fix | |
|---|---|---|---|
missing_page_boxes | No review rows on that page | Add boxes from word/line OCR or PyMuPDF text positions (normalized) | |
missing_review_boxes | Word OCR hits not intersecting any box | Add/extend review rows | |
coord_not_normalized | CSV rows use pixel/point coords (>1) | Normalize to 0–1; re-apply (headless apply now rejects invalid coords) | |
coord_mismatch_or_image_text | Word OCR covered but text still extractable | Widen boxes, split multi-line blocks, or redact image areas (CUSTOM); image-baked text cannot be stripped by text redaction alone. If `pixel_failures` is empty after apply, stop adding full-span boxes — document limitation or use Pass 2 visual check on those pages. |
Word OCR can show 100% covered while the text layer still leaks — that is usually coordinates or image text, not a broken apply endpoint.
Pass 1 — OCR / CSV / text review
Use artefacts from the same redaction run. No VLM in this pass.
Inputs (discover in output folder)
| File | Use | |
|---|---|---|
*_review_file.csv | Master list of proposed boxes — add/remove/relabel rows | |
*_ocr_results_with_words_*.csv | Word boxes (word_x0…word_y1) for precise coordinates | |
*_ocr_output_*.csv | Line-level OCR — reading order, line text, line indices; use for context and same-line grouping | |
Original (unredacted) .pdf | Preview overlays; text extraction sanity checks | |
*_ocr_results_with_words_*.json | Optional — same word data as CSV when easier to parse |
Pass 1 loop (per page or whole document)
- Load
*_review_file.csv(encoding="utf-8-sig"). - Policy edits — remove false positives, add missing PII rows, relabel (programmatically, not Excel-only).
- Word OCR — match
page+word_text; merge words on the same line (|Δy0| < ~0.01); separate boxes across lines. - Line OCR — use line CSV for phrase context, line numbers, and confirming reading order when word boxes fragment a name or address.
- Coverage report (mandatory before apply) — run `tools/verify_redaction_coverage.py` or `POST /agent/verify_redaction_coverage` with
must_redact/must_not_redactregex lists. Fix policy flags (uncovered_terms,over_redacted,text_layer_leaks); re-run untilpass_strictis true. - Suspicious-row prune (standard Pass 1 cleanup) — remove short OCR-fragment boxes (
"-",".","Ho", etc.) that do not matchmust_redact. CLI:--prune-suspicious --pruned-output merged_pruned.csvor API:auto_prune_suspicious: true. Re-run coverage; targetpass_with_cleanup: true. - Preview —
preview_redaction_boxesor/preview_boxeson edited CSV (spot-check worst pages from the report). - Merge full-document CSV (all pages) if reviewing a subset — see page-review skill.
- One
/review_apply→ download newest*_redacted.pdf/*_review_file.csv(sort byst_mtime). - Coverage report (after apply) — re-run with
redacted_pdf_pathfor text-layer leak checks; optionalsample_pixels=true. - Term search (optional) —
POST /agent/word_level_ocr_text_searchorword_level_ocr_text_searchto find policy phrases in word OCR and whether each hit is boxed.
Pass 1 is complete when pass_strict is true (policy satisfied). `pass_with_cleanup` also requires no suspicious short rows. Run Pass 2 VLM only on `pages_flagged_for_vlm` (policy/visual risk — not pages_needing_csv_cleanup alone).
Automatic post-redaction QA (optional — main app)
When POST_REDACT_PASS1_QA=True (`tools/config.py`), initial redaction (Gradio / CLI / /doc_redact) runs `tools/post_redaction_pass1_qa.py` after writing *_review_file.csv:
- Emits
*_coverage_report.jsonnext to the review CSV - Optionally emits sibling
*_review_file_pruned.csvwhenPOST_REDACT_PASS1_AUTO_PRUNE=True(does not replace the original CSV) - Maps run deny list → must_redact, allow list → must_not_redact when
POST_REDACT_PASS1_USE_DENY_ALLOW_LISTS=True - Appends a one-line QA summary to the redaction status message
This is pre-review-apply deployment QA only. Agent Pass 1 (policy edits, merge, /review_apply, post-apply coverage) is still required for case-specific review workflows.
Coverage verification (Pass 1 — no VLM)
Programmatic QA replacing per-page visual review for most cases.
CLI:
Report fields:
| Field | Meaning | |
|---|---|---|
pass / pass_strict | Policy satisfied: no uncovered terms, over-redactions, text leaks, or pixel failures | |
pass_with_cleanup | Also no suspicious short OCR-fragment rows | |
pages_flagged_for_vlm | Policy/visual failures → optional Pass 2 | |
pages_needing_csv_cleanup | Suspicious rows only → run prune step, not VLM | |
leak_likely_causes (per page) | Why text_layer_leaks appeared — see troubleshooting table above |
Agent API: POST /agent/verify_redaction_coverage
Response includes coverage_pass_strict, coverage_pass_with_cleanup, pruned_csv_path, prune_log, per-page issues, and pages_flagged_for_vlm vs pages_needing_csv_cleanup.
Split-container verify (Pi agent + separate redaction service)
When the Pi agent and doc_redaction run in separate containers (e.g. http://redaction:7860), path validation in secure_path_utils runs on the redaction server. Agent API paths must resolve under repo root, INPUT_FOLDER, or OUTPUT_FOLDER on that server.
| Phase | Where files live | How to verify | |
|---|---|---|---|
| Pre-apply | Edited *_review_file.csv in Pi session workspace; OCR CSV downloaded locally | python tools/verify_redaction_coverage.py <local_review_csv> <local_ocr_words_csv> ... — official CLI on downloaded copies | |
| Post-apply | *_redacted.pdf and review CSV on redaction server from /review_apply | POST {gradio_url}/agent/verify_redaction_coverage with server paths from extract_server_paths(review_apply result) plus OCR words path from /doc_redact |
Rejected paths (common mistakes):
- Pi workspace paths (e.g.
/home/user/app/workspace/sess/...) /tmp/gradio_tmp/...from/gradio_api/upload(not underOUTPUT_FOLDER)- Calling
verify_redaction_coverage()from the Pi container with redaction-server path strings
Word search: POST /agent/word_level_ocr_text_search with ocr_words_csv_path, search_text, optional review_csv_path.
covered_by_review_box uses intersecting review boxes (not strict containment). A hit marked false may still be visually redacted if a larger box overlaps — inspect coordinates before adding rows.
Python:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/doc-redaction-modifications/SKILL.md
Popularity
- Repository stars
- 52
- Repository forks
- 12
- 7-day trend score
- 20
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/seanpedrick-case/doc_redaction/doc-redaction-modifications)