
Backward Traceability
Wire code-generated LaTeX metrics to clickable PDF references so solo researchers can prove every reported number traces back to the exact script line.
Overview
Backward Traceability Patterns is an agent skill most often used in Build (also Ship review, Validate scope) that documents LaTeX hypertarget and hyperlink conventions so paper numbers trace to labeled code output.
Install
npx skills add https://github.com/lingzhi227/agent-research-skills --skill backward-traceabilityWhat is this skill?
- Documents \hypertarget, \hyperlink, and \num patterns extracted from data-to-paper workflows
- Defines prefix–line–letter label convention (e.g. code1a, R3c) for values in generated output
- Includes _num_to_letters mapping (1→a through multi-letter aa, ab) matching referencable_text.py
- Covers HypertargetPosition modes for placing anchors on numeric values in LaTeX
- Supports backward traceability from prose claims to reproducible code blocks
- Label format uses prefix, line number, and letter suffix (e.g. code12a)
- Letter mapping supports 1→a through 27→aa per _num_to_letters
Adoption & trust: 653 installs on skills.sh; 114 GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You publish tables and percentages in LaTeX but cannot prove which script line produced each value when a reviewer or future you asks.
Who is it for?
Solo researchers or indie builders generating LaTeX from Python who need audit-ready numeric traceability in papers and supplements.
Skip if: Teams that only ship Markdown blogs or apps with no LaTeX pipeline and no reproducibility requirement for printed numbers.
When should I use this skill?
You generate LaTeX or PDF from code and need every numeric claim in the paper to reference a labeled value in script output.
What do I get? / Deliverables
After applying the patterns, generated TeX carries stable labels and clickable PDF links from prose to code output, ready for compile checks and submission packaging.
- Labeled hypertarget markers in generated TeX aligned to code lines
- Manuscript hyperlinks from prose to source values
- Documented label naming convention for the project
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Canonical shelf is build/docs because reproducible paper artifacts are produced while drafting methods, results, and supplementary outputs—not during initial ideation. Subphase docs fits LaTeX paper bodies, hypertarget labels in generated TeX, and compile-time \num evaluation that must stay synchronized with analysis scripts.
Where it fits
Scope which experiment metrics get stable R-labels before running the full training grid.
Embed hypertargets in generated results TeX while drafting the methods section.
Click every hyperlink in the PDF to verify claims still match the latest code run before upload.
How it compares
Use instead of hand-maintained figure tables copied from notebook cells without hypertarget wiring.
Common Questions / FAQ
Who is backward-traceability for?
It is for solo and indie builders writing reproducible research papers or technical reports who compile LaTeX from code-generated outputs and must defend every reported statistic.
When should I use backward-traceability?
Use it during build/docs while wiring ref_numeric_values-style pipelines, during ship/review before submission when validating claims, and during validate/scope when locking which metrics are in scope for a preprint.
Is backward-traceability safe to install?
Review the Security Audits panel on this Prism page for install risk and file integrity; the skill is documentation-only and does not request shell or network by itself.
SKILL.md
READMESKILL.md - Backward Traceability
# Backward Traceability Patterns Extracted from data-to-paper (ref_numeric_values.py, referencable_text.py, latex_to_pdf.py). ## Core LaTeX Commands ### \hypertarget — Mark a Value in Code Output ```latex % In code-generated output: \hypertarget{R1a}{45.3} % R1a = reference label, 45.3 = the value ``` ### \hyperlink — Reference a Value in Paper Text ```latex % In paper body: Our method achieves \hyperlink{R1a}{45.3}\% accuracy. % Clicking 45.3 in PDF jumps to the code output ``` ### \num — Compile-Time Evaluated Formula ```latex % Compute derived values at compile time: \num{45.3 - 38.7, "accuracy improvement over baseline"} % Evaluates to 6.6 and stores explanation ``` ## Label Format Convention (data-to-paper) ``` Label = {prefix}{line_number}{letter} prefix: identifies the code block (e.g., "code", "R") line_number: line in the code that produces the value letter: a, b, c... for multiple values on same line Examples: code1a → code block, line 1, 1st value code1b → code block, line 1, 2nd value code12a → code block, line 12, 1st value R3c → results block, line 3, 3rd value ``` Letter conversion (data-to-paper referencable_text.py): ```python def _num_to_letters(num): """1→a, 2→b, ... 26→z, 27→aa, 28→ab, ...""" letters = '' while num > 0: num -= 1 letters = chr(ord('a') + num % 26) + letters num //= 26 return letters ``` ## HypertargetPosition Modes (data-to-paper) ```python class HypertargetPosition(Enum): WRAP = "wrap" # \hypertarget{label}{value} ADJACENT = "adjacent" # \hypertarget{label}{}value HEADER = "header" # \hypertarget{label}{} (value elsewhere) NONE = "none" # No hypertargets ``` ## \num Implementation (data-to-paper latex_to_pdf.py) ```python def evaluate_latex_num_command(latex_str, ref_prefix='', enforce_explanation=True): r""" Evaluates \num{formula} or \num{formula, "explanation"} in latex. If ref_prefix provided, adds \hyperlink{ref_prefix?}{result} where ? is the index. Returns: - new_latex_str: with \num{} replaced by computed values - labels_to_notes: dict mapping labels to "formula = result" """ # Available math functions for eval(): namespace = { 'exp': np.exp, 'log': np.log, 'sin': np.sin, 'cos': np.cos, 'tan': np.tan, 'pi': np.pi, 'e': np.e, 'sqrt': np.sqrt, 'log2': np.log2, 'log10': np.log10, 'abs': np.abs, } result = eval(formula_without_hyperlinks, namespace) # Create hyperlink: label = f'{ref_prefix}{index}' replace_with = f'\\hyperlink{{{label}}}{{{result}}}' # Store note: labels_to_notes[label] = f"{formula} = {result}" if explanation: labels_to_notes[label] += f" ({explanation})" ``` ## Code Output Tagging Pattern ### Python Code (Experiment Script) ```python # Tag every numeric output with hypertarget def save_results_with_targets(results, prefix="R"): """Save results with LaTeX hypertarget tags.""" lines = [] line_no = 1 for key, value in results.items(): letter = 'a' if isinstance(value, dict): for subkey, subval in value.items(): label = f"{prefix}{line_no}{letter}" lines.append(f"\\hypertarget{{{label}}}{{{subval:.4f}}}") letter = chr(ord(letter) + 1) else: label = f"{prefix}{line_no}a" lines.append(f"\\hypertarget{{{label}}}{{{value:.4f}}}") line_no += 1 return lines ``` ### Usage in Experiment ```python results = { "accuracy": 0.453, "precision": 0.421, "recall": 0.487, "f1": 0.452, } tagged = save_results_with_targets(results) # Output: # \hypertarget{R1a}{0.4530} # \hypertarget{R2a}{0.4210} # \hypertarget{R3a}{0.4870} # \hypertarget{R4a}{0.4520} ``` ## Appendix Code Listing Template ```latex \section*{Appendix A: Experiment Code} \begin{lstlisting}[ langu