Court form filling

From XuShuwenn/RedAct · View interactive version

Court form filling is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Fill PDF forms with case information for legal filing, handling dates, addresses, and structured text fields.

How to use this skill

Skill file

Court Form Filling

When to Use

Workflow

  1. Before any substantive work, identify and follow any task-specific execution protocol exactly (for example, required tool/action syntax, wrapper format, helper invocation style, JSON/schema shape, response format, or exact completion token); if specified, use it for the entire run and final handoff.

0a. Treat protocol compliance as a hard success condition, not style: if the environment or task specifies an exact tool/action wrapper, JSON schema, helper-call syntax, path policy, ordered prerequisite workflow, or completion token/string, use that exact format and order on every step and in the final handoff. Do not improvise alternate tool-call formats, XML/tag wrappers, relative paths when absolute paths are required, or a narrative completion message.

0b. Run a brief preflight before substantive work: confirm the exact required tool/action syntax, output-path policy, and completion token/final-response string; confirm that the current task inputs/artifacts actually contain the needed case facts; identify which helper script, sample record, or schema defines the required machine-readable mapping format; and, if the task or bundled workflow requires certain PDF steps to be run first or in order (for example a fillability check before extraction/filling), execute those prerequisite commands successfully before any downstream mapping or fill attempt. If any of these prerequisites are missing, unreadable, or failed, stop and resolve that first.

  1. Determine whether the PDF contains native fillable/AcroForm fields before choosing a method; if it does, prefer structured field extraction/filling over visual overlay or manual annotation approaches.

1a. Treat this fillability decision as the workflow fork: once native fields are confirmed, stay on the structured AcroForm/helper-script path (field extraction -> reviewed mapping file -> fill -> saved-PDF verification) rather than improvising manual editing or overlay methods, and only change approaches if that path is proven unusable.

  1. Read the blank PDF form to understand field structure.
  2. Extract or inspect the complete form field list/schema first and use it as the source of truth for field IDs/names, control types, pages, rectangles, and export values when available; review relevant rendered pages or page images alongside that metadata so each target field is tied to the visible question/section before mapping values. Treat full field metadata plus page renderings as the default identification method. If any dump, preview, render, OCR, or command output is blank, partial, truncated, contradictory, or unclear, switch to another inspection method and do not map from incomplete schema visibility, field IDs alone, or guessed names.

3b. If the extracted field list is saved to a file, inspect the actual saved file beyond a short preview before claiming any mapping is complete. Search/read enough of the full inventory to identify each target field explicitly; do not treat the first few lines, a head output, or a truncated console snippet as review of the schema.

3a. Never claim you reviewed layout, page content, or image evidence when the inspection output is empty or unreadable. A blank image read, empty OCR result, or unusable preview means inspection failed; stop, obtain usable content with another method, and only then continue mapping or summarizing the form.

3b.i. Do not use plain file reads of PNG/page-image binaries as evidence of visual inspection. Use an image-capable rendering, OCR, or preview method that returns readable page content; if it returns nothing usable, treat layout review as not done.

3c. Default pre-fill sequence for native fillable PDFs: (1) confirm fillability, (2) export the full field inventory/metadata to a file, (3) review rendered page images or page text alongside that inventory, and only then (4) draft the field-values mapping. For large inventories, narrow candidates by page and semantic keywords from the case facts; for opaque or non-semantic field names, use page number plus field rectangles/crops to tie each metadata entry to the visible prompt, checkbox option, or section before mapping values. Do not skip straight from case facts to writing field values.

  1. If the task or skill folder provides PDF/form-processing scripts, use those prescribed scripts first to confirm fillability, export field metadata, and drive the fill workflow; inspect any helper script or mapping-file schema and match its exact expected structure before generating JSON or other transform input, preserving all required metadata keys (for example page/field identifiers), not just field names and values.

4a. Before running any helper fill script, inspect a real sample record, script usage, or the code path that reads the mapping file and verify the exact required keys for each item. Do not generate or pass a guessed, reduced, or value-only schema if the helper expects per-field objects with metadata such as page, field identifier/name, type, or export value.

4b. Do not make a first fill attempt until you can name the required top-level shape and per-item keys the helper consumes. A self-designed values-only JSON is not an acceptable trial run.

4c. If a provided script or command fails because the expected runtime/executable is unavailable (for example python not found), inspect the environment for the correct available interpreter/tool variant (for example python3) and rerun with that exact available executable instead of repeating the same failing command.

  1. Parse case description to extract key information.

5a. If the case facts are missing, not yet retrieved, or not visible in the current task context or inspected artifacts, stop before mapping or filling. Do not invent, assume, or later claim you filled party details, amounts, narratives, dates, or filing bases that were never actually obtained from the task inputs.

  1. Build a complete traceable mapping for every datum you intend to fill: form evidence -> confirmed PDF field name/ID -> control type -> case fact -> value. Search the full extracted inventory for each target, inspect the specific metadata entry or visible form evidence for every field you intend to fill, use layout only to confirm semantics rather than invent targets, and do not proceed on partial field identification, partial dumps, or guessed IDs.
  2. For checkboxes, radio buttons, yes/no controls, selects, and conditional sections, confirm the exact question semantics and valid export values before setting anything; distinguish the main answer control from any follow-up explanation field, do not answer a different question than the one shown on the form, and fill only the fields for the branch actually selected.

6a. Before generating the final mapping file, inspect each checkbox/radio field's actual allowed values from metadata and record the exact checked/unchecked export values you will use for that specific field instance. Do not guess, normalize, or invent checkbox values such as /Yes, /On, or numeric states unless the extracted metadata for that field shows them.

6b. Before writing any field_values or helper-input file, make the mapping explicit for each populated entry: PDF field ID/name -> visible prompt/section -> source case fact -> value to write. Do not create the final payload from a partial field dump, placeholder description, or unshown reasoning.

  1. If a target field is ambiguous, unconfirmed, unsupported, or merely optional, leave it blank until resolved rather than guessing
  2. Prefer creating a dedicated intermediate field-values mapping file (for example, JSON) before the final fill step; use it as a reviewable, reproducible artifact. Write it using a method that avoids shell-quoting corruption, then open and inspect the actual key-value contents, confirm it parses and preserves the required schema, verify every populated entry matches the approved mapping, includes every required metadata field, and contains only intended confirmed fields before using it.

8a. Keep the mapping minimal: include only confirmed required/supported fields from the case description, and omit or leave blank optional, court-filled, signature, or otherwise unsupported fields unless the case description explicitly supports them and the form evidence confirms the target field.

8b. Before any fill command, open/read back the generated mapping artifact itself and verify the actual serialized contents, schema, field IDs, and values match your intended mapping. The file must contain the real machine-readable payload expected by the fill step, not notes, summaries, status text, TODOs, or placeholder prose.

8b.i. Hard stop: if the mapping/input artifact is not valid structured data in the exact format expected by the downstream fill step, do not run the fill command. Make the saved mapping evidence visible in the run by inspecting or printing the actual JSON/object contents or an equivalent parsed view. It must deserialize into the expected structure and contain real per-field entries with confirmed identifiers, required metadata, and intended values. Replace placeholder sentences, narrative notes, or status text with the real machine-readable mapping, then read it back again before proceeding.

8d. Treat the intermediate mapping artifact as the handoff between identification and filling: complete and review it before the first fill attempt, and use it to drive both the fill step and later verification rather than remapping ad hoc from memory.

8c. Apply a traceability gate before saving or using the mapping: for each nonblank value, be able to point to the exact source fact in the task inputs or retrieved case materials. If any populated value lacks a source, remove it and resolve the missing input before continuing.

  1. Fill the PDF form with the verified mapping while preserving the original AcroForm/form metadata; first establish one end-to-end method that produces a readable filled PDF with intact form structure, and if the method removes fields, breaks form structure, makes the output unreadable, or repeatedly produces library/object-manipulation errors, stop retrying small variations and switch to a clearly different approach.

9b. Use an escalation rule for repeated structural failures: if the same library or tool produces the same error class more than once (for example missing /AcroForm, invalid PDF object/key type errors, disappearing field enumeration, or broken object references), stop iterative patching and pivot to a different validated toolchain or workflow.

9c. Treat missing dependencies or unavailable utilities as part of the same escalation decision: if a candidate workflow depends on tools not installed in the environment, do not keep circling through nearby variants of that workflow. Choose a method that is both structurally sound for this PDF and actually runnable in the current environment.

9a. Compare the fill tool's reported updates with your intended mapping; if any required or high-risk field is missing from the confirmation output, treat the fill as incomplete and re-inspect before proceeding.

  1. Save the filled form to the requested output path and keep that exact path consistent in commands and final reporting.

10a. At each major handoff artifact (for example extracted field metadata, mapping JSON, and the filled PDF), do a quick existence/readability check immediately after creation so failures are caught before the next step; then continue to the deeper content verification required elsewhere in this workflow. Treat this as an early guardrail only, not proof that filling succeeded.

  1. Re-open the saved PDF and verify the filled output itself: preferably render the completed document to page images and confirm both populated fields and intentionally blank areas, then extract/read back fields as needed to verify every populated required/high-risk field was actually written correctly against the full intended mapping. Do not treat file existence, file size, command success, or a small sample as verification.

11a. Minimum verification before claiming success: inspect the saved filled PDF itself with at least one content-reading method and compare the visible values or read-back field values against the intended mapping for all populated required/high-risk fields. Do not state that the form is completed correctly or list specific populated facts unless those exact results were observed in verification output; ls, file size, generic success messages, or silent command completion are never sufficient.

11b. A process check is never a fill verification step: do not use ls, file timestamps, output-path existence, byte size, or a tool's generic success/update message as evidence that any field value was populated. If your only post-fill evidence is process or existence output, or if page-image reads, OCR, or preview commands return empty or unreadable results, treat verification as not done and do not claim specific contents were written.

  1. When one verification method returns empty, unreadable, contradictory, truncated, or partial results, do not finalize; use a different inspection method, and for PDFs with native form fields prefer programmatic read-back of saved field values as an additional verification step rather than relying only on OCR, console output, or spot checks.

12a. Final verification must be clean, not merely suggestive: do not declare success if the verification command itself errors, if read-back uses the same failing fragile library, or if the only evidence is a later summary that does not resolve earlier verification failures. Obtain at least one independent verification path that runs successfully and confirms the intended filled contents.

12b. If earlier fill attempts produced structural/document-read errors (for example missing /AcroForm, zero fields after fill, blank extracted values, unreadable objects, or broken references), treat any later "successfully filled" print from the same workflow as untrusted until an independent verification method successfully reads the saved PDF and confirms the intended populated fields.

12c. Preferred post-fill verification sequence for fillable PDFs: first read back saved field values when native form fields remain available, then render the saved output PDF and inspect the populated pages for the required/high-risk fields you set. Treat this combination as the default verification path for fillable PDFs.

12d. If one verification command fails because the checker itself is unavailable or errors (for example missing system utilities or object-read failures), discard it as evidence and replace it with a different successful verification path before concluding anything. Do not average together failing checks and one later summary into a claim of success.

  1. Keep intermediate field maps, generated JSON, extracted metadata, screenshots, and other verification artifacts until this output check passes.
  2. After any post-fill change to mappings, transformed values, checkbox/radio selections, or helper inputs, rerun verification on the updated output before claiming completion.

14a. Before finalizing, ensure the run contains visible evidence for the values you claim were filled: inspect the intermediate field-values mapping and/or verified read-back output and ground any status statement in that observed content. If earlier attempts produced structural PDF warnings/errors, do not accept a later success print from the same workflow as proof of recovery without independently verifying the final saved PDF itself.

14b. Use a final-response evidence gate: before the last turn, confirm (1) at least one successful verification step showed the filled content itself or programmatic read-back of the saved PDF, and (2) every specific fact you mention in the response, including names, parties, amounts, dates, allegations, addresses, filing basis, checkbox selections, and field mappings, was visibly supported by both a source input and the inspected mapping or verified output from this run. If either check fails, do not summarize populated details; leave them unconfirmed until a successful inspection path resolves them.

  1. Before the final response, check whether the task specifies an exact completion token, final response string, or output protocol; if so, compare your planned final output literally against that requirement and emit that required text exactly, with no extra prose before or after it. Do not replace it with a narrative summary, even if the work appears complete.
  1. Use this default path for native-form PDFs unless the task requires another validated workflow: confirm the PDF is fillable -> extract the full field inventory/metadata -> map confirmed case facts to specific field records -> fill -> read back key written fields from the saved PDF -> fix any omissions/mismatches -> verify again before finalizing.

16a. During read-back verification, include the highest-risk populated fields first: party names, dates, addresses/contact fields, amounts, long text/narrative boxes, and every checkbox/radio selection you set. If read-back shows a missing required field, return to the mapping and fill steps rather than assuming the rest succeeded.

Important Notes

Common Patterns

Tips

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.