--- name: real_form_fill_td1_rungs description: "Fill out your employer's tax credit form so the right amount of tax gets taken off your paycheck. real_form_fill_td1_rungs: Fill the real CRA TD1 (Personal Tax Credits Return) from human labels: discovers each field from tooltips and widget geometry, writes values with appearances, leaves other fiel" --- # real_form_fill_td1_rungs (a Neruva verified skill for `pdf`) Fill out your employer's tax credit form so the right amount of tax gets taken off your paycheck. Verified helper code for `pdf`, python. Entry points: `list_form_fields`, `find_fields_by_tooltip`, `find_best_field`, `fill_pdf_form`. Code hash sha256 `47f211e87b3bc2c5e0118fcec88294b02cdd84b992cb23f13d2680a40d004e5c`, signed (ed25519). Banked by `legacy-dev`. ## One call Call `build(**args)` with an object matching this schema. You do not have to write code or match the helper signatures below. ```json { "type": "object", "properties": { "input_pdf": { "type": "string", "description": "Path to the blank source PDF form to fill (e.g. one of ds11.pdf, i9.pdf, td1.pdf, w9.pdf)." }, "output_pdf": { "type": "string", "description": "Path (including filename) where the filled PDF will be written. Any missing parent directories will be created automatically before writing." }, "labels": { "type": "object", "description": "Mapping of human-readable label(s) to the value to fill in. Each key is either a single substring (string) to search for in field tooltips/names, or a list of candidate substrings ordered from most specific to least specific (used with find_best_field). Each value is the string to write into that field. Use this when you don't know the exact internal PDF field name.", "additionalProperties": { "description": "Value to place into the matched field." } }, "field_values": { "type": "object", "description": "Mapping of exact internal PDF field name (as returned by list_form_fields' 'name' key) directly to the value to write. Use this when you already know the precise internal field name; bypasses label matching. For checkboxes/radio buttons use the on/off export value strings (e.g. '/Yes', '/Off').", "additionalProperties": { "description": "Value to place into the field with this exact internal name." } }, "case_sensitive": { "type": "boolean", "description": "Whether label matching against tooltips/names is case sensitive. Default false.", "default": false }, "generate_appearances": { "type": "boolean", "description": "If true (default), generate visual appearance streams for filled text fields so any viewer shows them immediately. If false, sets NeedAppearances instead and relies on the PDF viewer to render values.", "default": true } }, "required": [ "input_pdf", "output_pdf" ], "additionalProperties": false } ``` Example arguments: ```json { "input_pdf": "td1.pdf", "output_pdf": "employee_personnel_file/td1_filled.pdf", "labels": { "first name": "Nguyen", "last name": "Tran", "social insurance number": "123456789", "date of birth": "1990-05-14", "address": "123 Maple Street, Toronto, ON" }, "field_values": {}, "case_sensitive": false, "generate_appearances": true } ``` ```python def build(**kwargs): import os input_pdf = kwargs.get("input_pdf") output_pdf = kwargs.get("output_pdf") labels = kwargs.get("labels", {}) raw_field_values = kwargs.get("field_values", {}) case_sensitive = kwargs.get("case_sensitive", False) generate_appearances = kwargs.get("generate_appearances", True) if not input_pdf: raise ValueError("input_pdf is required") if not output_pdf: raise ValueError("output_pdf is required") out_dir = os.path.dirname(output_pdf) if out_dir: os.makedirs(out_dir, exist_ok=True) fields_info = list_form_fields(input_pdf) field_values = {} # Direct internal-name -> value mapping, passed straight through. for name, value in raw_field_values.items(): field_values[name] = value # Human-label -> value mapping, resolved via tooltip/name matching. for label, value in labels.items(): if isinstance(label, str): candidates = [label] else: candidates = list(label) best = find_best_field(fields_info, candidates, case_sensitive=case_sensitive) if best is not None: field_values[best["name"]] = value return fill_pdf_form(input_pdf, output_pdf, field_values, generate_appearances=generate_appearances) ``` ## How to use it list_form_fields(pdf_path) Returns a list of dicts describing every AcroForm field in the PDF: {"name": , "tooltip": , "type": , "value": }. Example: fields = list_form_fields("td1.pdf") find_fields_by_tooltip(fields_info, substring, case_sensitive=False, search_name_too=True) Filters fields_info (from list_form_fields) to those whose tooltip (or internal name, if search_name_too) contains `substring`. Returns a list of matching field dicts (possibly empty). Example: matches = find_fields_by_tooltip(fields, "date of birth") find_best_field(fields_info, candidates, case_sensitive=False) Tries each string in `candidates` (most specific first) against find_fields_by_tooltip and returns the single field dict it thinks is the best match, or None if nothing matched. Useful when the exact tooltip wording is uncertain. Example: f = find_best_field(fields, ["date of birth", "birth"]) fill_pdf_form(input_pdf, output_pdf, field_values, generate_appearances=True) Fills the named AcroForm fields (dict of internal field name -> value) in input_pdf, storing them in /V, generating appearance streams by default, keeping every other field's value untouched, keeping all pages, and writes the result to output_pdf. Returns output_pdf. Example: fill_pdf_form("td1.pdf", "out.pdf", {"topmostSubform[0].Page1[0].f1_02[0]": "Nguyen"}) ## Evidence (corpus named) - real CRA TD1 (canada.ca), 16 held-out fills, best-of-2: deepseek-chat cold 0.188 @0.47c -> 0.938 with rung @0.34c (CI +0.562..+0.938); Sonnet cold 1.000 @27.17c; 80x cheaper per success - forged by claude-sonnet-5, 2026-09-04 ## Files - `scripts/skill.py`: the verified code (GET /v1/commons/rungs/rec_fcffc2c5a47f48a7a41bd50c7338fc2a/code) - verify: POST /v1/commons/verify {"id": "rec_fcffc2c5a47f48a7a41bd50c7338fc2a"}