Backward Traceability

作者 lingzhi2279e6c085d65e3无许可证386 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7个月前更新

Make every number in the final PDF traceable to the exact code line that produced it. Uses \hypertarget/\hyperlink LaTeX commands and \num{formula} evaluated at compile time. Use for reproducibility and data integrity verification.

AI 生成的概览

为代码中的数值结果打标签,并与 LaTeX 论文中的数字建立可追溯链接。

功能
该技能让编译后 PDF 中的数值可以回溯到产生它们的代码行。它指导在实验输出中添加 hypertarget 标签、在 LaTeX 中用 hyperlink 命令引用这些标签,并对派生值使用编译期求值的公式。它还附带一个 Python 脚本,可扫描 LaTeX 文件中的 hypertarget 与 hyperlink,报告孤立或未被引用的数值,并将论文中的数值与代码输出进行交叉核对。
适用场景
适用于撰写需要让数字可对照生成代码进行核验的研究论文。适合可复现性与数据完整性检查,以及验证每个报告数值都能链接到具体代码行。
运行要求
需要带 hyperref 和 listings 宏包的 LaTeX 工具链,以及运行随附脚本 scripts/ref_numeric_values.py 的 Python 环境。它作用于包含代码和 LaTeX 文件的论文项目目录;未说明需要凭据或网络访问。

Backward Traceability

Make every number in the final PDF hyperlink back to the exact code line that produced it.

Input

  • $0 — Paper project directory containing code and LaTeX files

References

  • Traceability patterns and LaTeX commands: ~/.claude/skills/backward-traceability/references/traceability-patterns.md

Scripts

Scan hypertarget/hyperlink references

bash
python ~/.claude/skills/backward-traceability/scripts/ref_numeric_values.py \  --scan paper/main.tex --output report.json

Reports: all hypertargets, hyperlinks, orphan references, unreferenced numeric values.

Verify cross-reference integrity

bash
python ~/.claude/skills/backward-traceability/scripts/ref_numeric_values.py \  --verify paper/main.tex --code-output results.txt

Cross-checks values between paper text and code output. Reports mismatches.

Workflow

Step 1: Tag Code Outputs

For every numeric value produced by experiment code, add hypertarget tags:

python
# In experiment code output:print(f"\\hypertarget{{R1a}}{{45.3}}")  # Mean accuracyprint(f"\\hypertarget{{R1b}}{{2.1}}")   # Std deviation

Label format: {prefix}{line_number}{letter} where letter = a, b, c... for multiple values on same line.

Step 2: Reference in Paper Text

Use \hyperlink to create clickable references in the paper:

latex
Our method achieves \hyperlink{R1a}{45.3}\% accuracy($\pm$\hyperlink{R1b}{2.1}).

Step 3: Use \num for Computed Values

For values derived from other values, use \num{} for compile-time evaluation:

latex
% \num{formula, "explanation"} → evaluated at compile timeThe improvement is \num{45.3 - 38.7, "accuracy gain"}\%.

Step 4: Generate Appendix Code Listing

Create an appendix with the full code listing, with \hypertarget anchors at relevant lines:

latex
\section*{Appendix: Code Listing}\begin{lstlisting}[escapechar=@]@\hypertarget{code1}{}@result = model.evaluate(test_data)@\hypertarget{code2}{}@accuracy = result['accuracy']\end{lstlisting}

Step 5: Verify Traceability

  • Every number in the paper text must have a corresponding \hypertarget in the code
  • Every \num{} formula must evaluate correctly
  • Click-test: every hyperlink in the PDF must jump to the correct code line

LaTeX Setup

Required packages:

latex
\usepackage{hyperref}\usepackage{listings}

Rules

  • Every numeric result in the paper MUST trace to code output
  • Never manually type numbers — always reference tagged outputs
  • Use \num{} for any derived/computed values
  • Code listing in appendix must match actual executed code
  • Verify all hyperlinks resolve correctly after compilation

Related Skills

  • Upstream: experiment-code, data-analysis
  • Downstream: paper-compilation
  • See also: paper-assembly

来源与署名

来源:lingzhi227/agent-research-skills位于skills/backward-traceability提交9e6c085

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架