flonat-research 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/.claude/agents/domain-reviewer.md +336 -0
  2. package/.claude/agents/fixer.md +226 -0
  3. package/.claude/agents/paper-critic.md +370 -0
  4. package/.claude/agents/peer-reviewer.md +289 -0
  5. package/.claude/agents/proposal-reviewer.md +215 -0
  6. package/.claude/agents/referee2-reviewer.md +367 -0
  7. package/.claude/agents/references/journal-referee-profiles.md +354 -0
  8. package/.claude/agents/references/paper-critic/council-personas.md +77 -0
  9. package/.claude/agents/references/paper-critic/council-prompts.md +198 -0
  10. package/.claude/agents/references/peer-reviewer/report-template.md +199 -0
  11. package/.claude/agents/references/peer-reviewer/sa-prompts.md +260 -0
  12. package/.claude/agents/references/peer-reviewer/security-scan.md +188 -0
  13. package/.claude/agents/references/proposal-reviewer/report-template.md +144 -0
  14. package/.claude/agents/references/proposal-reviewer/sa-prompts.md +149 -0
  15. package/.claude/agents/references/referee-config.md +114 -0
  16. package/.claude/agents/references/referee2-reviewer/audit-checklists.md +287 -0
  17. package/.claude/agents/references/referee2-reviewer/report-template.md +334 -0
  18. package/.claude/rules/design-before-results.md +52 -0
  19. package/.claude/rules/ignore-agents-md.md +17 -0
  20. package/.claude/rules/ignore-gemini-md.md +17 -0
  21. package/.claude/rules/lean-claude-md.md +45 -0
  22. package/.claude/rules/learn-tags.md +99 -0
  23. package/.claude/rules/overleaf-separation.md +67 -0
  24. package/.claude/rules/plan-first.md +175 -0
  25. package/.claude/rules/read-docs-first.md +50 -0
  26. package/.claude/rules/scope-discipline.md +28 -0
  27. package/.claude/settings.json +125 -0
  28. package/.context/current-focus.md +33 -0
  29. package/.context/preferences/priorities.md +36 -0
  30. package/.context/preferences/task-naming.md +28 -0
  31. package/.context/profile.md +29 -0
  32. package/.context/projects/_index.md +41 -0
  33. package/.context/projects/papers/nudge-exp.md +22 -0
  34. package/.context/projects/papers/uncertainty.md +31 -0
  35. package/.context/resources/claude-scientific-writer-review.md +48 -0
  36. package/.context/resources/cunningham-multi-analyst-agents.md +104 -0
  37. package/.context/resources/cunningham-multilang-code-audit.md +62 -0
  38. package/.context/resources/google-ai-co-scientist-review.md +72 -0
  39. package/.context/resources/karpathy-llm-council-review.md +58 -0
  40. package/.context/resources/multi-coder-reliability-protocol.md +175 -0
  41. package/.context/resources/pedro-santanna-takeaways.md +96 -0
  42. package/.context/resources/venue-rankings/abs_ajg_2024.csv +1823 -0
  43. package/.context/resources/venue-rankings/abs_ajg_2024_econ.csv +356 -0
  44. package/.context/resources/venue-rankings/cabs_4_4star_theory.csv +40 -0
  45. package/.context/resources/venue-rankings/core_2026.csv +801 -0
  46. package/.context/resources/venue-rankings.md +147 -0
  47. package/.context/workflows/README.md +69 -0
  48. package/.context/workflows/daily-review.md +91 -0
  49. package/.context/workflows/meeting-actions.md +108 -0
  50. package/.context/workflows/replication-protocol.md +155 -0
  51. package/.context/workflows/weekly-review.md +113 -0
  52. package/.mcp-server-biblio/formatters.py +158 -0
  53. package/.mcp-server-biblio/pyproject.toml +11 -0
  54. package/.mcp-server-biblio/server.py +678 -0
  55. package/.mcp-server-biblio/sources/__init__.py +14 -0
  56. package/.mcp-server-biblio/sources/base.py +73 -0
  57. package/.mcp-server-biblio/sources/formatters.py +83 -0
  58. package/.mcp-server-biblio/sources/models.py +22 -0
  59. package/.mcp-server-biblio/sources/multi_source.py +243 -0
  60. package/.mcp-server-biblio/sources/openalex_source.py +183 -0
  61. package/.mcp-server-biblio/sources/scopus_source.py +309 -0
  62. package/.mcp-server-biblio/sources/wos_source.py +508 -0
  63. package/.mcp-server-biblio/uv.lock +896 -0
  64. package/.scripts/README.md +161 -0
  65. package/.scripts/ai_pattern_density.py +446 -0
  66. package/.scripts/conf +445 -0
  67. package/.scripts/config.py +122 -0
  68. package/.scripts/count_inventory.py +275 -0
  69. package/.scripts/daily_digest.py +288 -0
  70. package/.scripts/done +177 -0
  71. package/.scripts/extract_meeting_actions.py +223 -0
  72. package/.scripts/focus +176 -0
  73. package/.scripts/generate-codex-agents-md.py +217 -0
  74. package/.scripts/inbox +194 -0
  75. package/.scripts/notion_helpers.py +325 -0
  76. package/.scripts/openalex/query_helpers.py +306 -0
  77. package/.scripts/papers +227 -0
  78. package/.scripts/query +223 -0
  79. package/.scripts/session-history.py +201 -0
  80. package/.scripts/skill-health.py +516 -0
  81. package/.scripts/skill-log-miner.py +273 -0
  82. package/.scripts/sync-to-codex.sh +252 -0
  83. package/.scripts/task +213 -0
  84. package/.scripts/tasks +190 -0
  85. package/.scripts/week +206 -0
  86. package/CLAUDE.md +197 -0
  87. package/LICENSE +21 -0
  88. package/MEMORY.md +38 -0
  89. package/README.md +269 -0
  90. package/docs/agents.md +44 -0
  91. package/docs/bibliography-setup.md +55 -0
  92. package/docs/council-mode.md +36 -0
  93. package/docs/getting-started.md +245 -0
  94. package/docs/hooks.md +38 -0
  95. package/docs/mcp-servers.md +82 -0
  96. package/docs/notion-setup.md +109 -0
  97. package/docs/rules.md +33 -0
  98. package/docs/scripts.md +303 -0
  99. package/docs/setup-overview/setup-overview.pdf +0 -0
  100. package/docs/skills.md +70 -0
  101. package/docs/system.md +159 -0
  102. package/hooks/block-destructive-git.sh +66 -0
  103. package/hooks/context-monitor.py +114 -0
  104. package/hooks/postcompact-restore.py +157 -0
  105. package/hooks/precompact-autosave.py +181 -0
  106. package/hooks/promise-checker.sh +124 -0
  107. package/hooks/protect-source-files.sh +81 -0
  108. package/hooks/resume-context-loader.sh +53 -0
  109. package/hooks/startup-context-loader.sh +102 -0
  110. package/package.json +51 -0
  111. package/packages/cli-council/.github/workflows/claude-code-review.yml +44 -0
  112. package/packages/cli-council/.github/workflows/claude.yml +50 -0
  113. package/packages/cli-council/README.md +100 -0
  114. package/packages/cli-council/pyproject.toml +43 -0
  115. package/packages/cli-council/src/cli_council/__init__.py +19 -0
  116. package/packages/cli-council/src/cli_council/__main__.py +185 -0
  117. package/packages/cli-council/src/cli_council/backends/__init__.py +8 -0
  118. package/packages/cli-council/src/cli_council/backends/base.py +81 -0
  119. package/packages/cli-council/src/cli_council/backends/claude.py +25 -0
  120. package/packages/cli-council/src/cli_council/backends/codex.py +27 -0
  121. package/packages/cli-council/src/cli_council/backends/gemini.py +26 -0
  122. package/packages/cli-council/src/cli_council/checkpoint.py +212 -0
  123. package/packages/cli-council/src/cli_council/config.py +51 -0
  124. package/packages/cli-council/src/cli_council/council.py +391 -0
  125. package/packages/cli-council/src/cli_council/models.py +46 -0
  126. package/packages/llm-council/.github/workflows/claude-code-review.yml +44 -0
  127. package/packages/llm-council/.github/workflows/claude.yml +50 -0
  128. package/packages/llm-council/README.md +453 -0
  129. package/packages/llm-council/pyproject.toml +42 -0
  130. package/packages/llm-council/src/llm_council/__init__.py +23 -0
  131. package/packages/llm-council/src/llm_council/__main__.py +259 -0
  132. package/packages/llm-council/src/llm_council/checkpoint.py +193 -0
  133. package/packages/llm-council/src/llm_council/client.py +253 -0
  134. package/packages/llm-council/src/llm_council/config.py +232 -0
  135. package/packages/llm-council/src/llm_council/council.py +482 -0
  136. package/packages/llm-council/src/llm_council/models.py +46 -0
  137. package/packages/mcp-bibliography/MEMORY.md +31 -0
  138. package/packages/mcp-bibliography/_app.py +226 -0
  139. package/packages/mcp-bibliography/formatters.py +158 -0
  140. package/packages/mcp-bibliography/log/2026-03-13-2100.md +35 -0
  141. package/packages/mcp-bibliography/pyproject.toml +15 -0
  142. package/packages/mcp-bibliography/run.sh +20 -0
  143. package/packages/mcp-bibliography/scholarly_formatters.py +83 -0
  144. package/packages/mcp-bibliography/server.py +1857 -0
  145. package/packages/mcp-bibliography/tools/__init__.py +28 -0
  146. package/packages/mcp-bibliography/tools/_registry.py +19 -0
  147. package/packages/mcp-bibliography/tools/altmetric.py +107 -0
  148. package/packages/mcp-bibliography/tools/core.py +92 -0
  149. package/packages/mcp-bibliography/tools/dblp.py +52 -0
  150. package/packages/mcp-bibliography/tools/openalex.py +296 -0
  151. package/packages/mcp-bibliography/tools/opencitations.py +102 -0
  152. package/packages/mcp-bibliography/tools/openreview.py +179 -0
  153. package/packages/mcp-bibliography/tools/orcid.py +131 -0
  154. package/packages/mcp-bibliography/tools/scholarly.py +575 -0
  155. package/packages/mcp-bibliography/tools/unpaywall.py +63 -0
  156. package/packages/mcp-bibliography/tools/zenodo.py +123 -0
  157. package/packages/mcp-bibliography/uv.lock +711 -0
  158. package/scripts/setup.sh +143 -0
  159. package/skills/beamer-deck/SKILL.md +199 -0
  160. package/skills/beamer-deck/references/quality-rubric.md +54 -0
  161. package/skills/beamer-deck/references/review-prompts.md +106 -0
  162. package/skills/bib-validate/SKILL.md +261 -0
  163. package/skills/bib-validate/references/council-mode.md +34 -0
  164. package/skills/bib-validate/references/deep-verify.md +79 -0
  165. package/skills/bib-validate/references/fix-mode.md +36 -0
  166. package/skills/bib-validate/references/openalex-verification.md +45 -0
  167. package/skills/bib-validate/references/preprint-check.md +31 -0
  168. package/skills/bib-validate/references/ref-manager-crossref.md +41 -0
  169. package/skills/bib-validate/references/report-template.md +82 -0
  170. package/skills/code-archaeology/SKILL.md +141 -0
  171. package/skills/code-review/SKILL.md +265 -0
  172. package/skills/code-review/references/quality-rubric.md +67 -0
  173. package/skills/consolidate-memory/SKILL.md +208 -0
  174. package/skills/context-status/SKILL.md +126 -0
  175. package/skills/creation-guard/SKILL.md +230 -0
  176. package/skills/devils-advocate/SKILL.md +130 -0
  177. package/skills/devils-advocate/references/competing-hypotheses.md +83 -0
  178. package/skills/init-project/SKILL.md +115 -0
  179. package/skills/init-project-course/references/memory-and-settings.md +92 -0
  180. package/skills/init-project-course/references/organise-templates.md +94 -0
  181. package/skills/init-project-course/skill.md +147 -0
  182. package/skills/init-project-light/skill.md +139 -0
  183. package/skills/init-project-research/SKILL.md +368 -0
  184. package/skills/init-project-research/references/atlas-pipeline-sync.md +70 -0
  185. package/skills/init-project-research/references/atlas-schema.md +81 -0
  186. package/skills/init-project-research/references/confirmation-report.md +39 -0
  187. package/skills/init-project-research/references/domain-profile-template.md +104 -0
  188. package/skills/init-project-research/references/interview-round3.md +34 -0
  189. package/skills/init-project-research/references/literature-discovery.md +43 -0
  190. package/skills/init-project-research/references/scaffold-details.md +197 -0
  191. package/skills/init-project-research/templates/field-calibration.md +60 -0
  192. package/skills/init-project-research/templates/pipeline-manifest.md +63 -0
  193. package/skills/init-project-research/templates/run-all.sh +116 -0
  194. package/skills/init-project-research/templates/seed-files.md +337 -0
  195. package/skills/insights-deck/SKILL.md +151 -0
  196. package/skills/interview-me/SKILL.md +157 -0
  197. package/skills/latex/SKILL.md +141 -0
  198. package/skills/latex/references/latex-configs.md +183 -0
  199. package/skills/latex-autofix/SKILL.md +230 -0
  200. package/skills/latex-autofix/references/known-errors.md +183 -0
  201. package/skills/latex-autofix/references/quality-rubric.md +50 -0
  202. package/skills/latex-health-check/SKILL.md +161 -0
  203. package/skills/learn/SKILL.md +220 -0
  204. package/skills/learn/scripts/validate_skill.py +265 -0
  205. package/skills/lessons-learned/SKILL.md +201 -0
  206. package/skills/literature/SKILL.md +335 -0
  207. package/skills/literature/references/agent-templates.md +393 -0
  208. package/skills/literature/references/bibliometric-apis.md +44 -0
  209. package/skills/literature/references/cli-council-search.md +79 -0
  210. package/skills/literature/references/openalex-api-guide.md +371 -0
  211. package/skills/literature/references/openalex-common-queries.md +381 -0
  212. package/skills/literature/references/openalex-workflows.md +248 -0
  213. package/skills/literature/references/reference-manager-sync.md +36 -0
  214. package/skills/literature/references/scopus-api-guide.md +208 -0
  215. package/skills/literature/references/wos-api-guide.md +308 -0
  216. package/skills/multi-perspective/SKILL.md +311 -0
  217. package/skills/multi-perspective/references/computational-many-analysts.md +77 -0
  218. package/skills/pipeline-manifest/SKILL.md +226 -0
  219. package/skills/pre-submission-report/SKILL.md +153 -0
  220. package/skills/process-reviews/SKILL.md +244 -0
  221. package/skills/process-reviews/references/rr-routing.md +101 -0
  222. package/skills/project-deck/SKILL.md +87 -0
  223. package/skills/project-safety/SKILL.md +135 -0
  224. package/skills/proofread/SKILL.md +254 -0
  225. package/skills/proofread/references/quality-rubric.md +104 -0
  226. package/skills/python-env/SKILL.md +57 -0
  227. package/skills/quarto-deck/SKILL.md +226 -0
  228. package/skills/quarto-deck/references/markdown-format.md +143 -0
  229. package/skills/quarto-deck/references/quality-rubric.md +54 -0
  230. package/skills/save-context/SKILL.md +174 -0
  231. package/skills/session-log/SKILL.md +98 -0
  232. package/skills/shared/concept-validation-gate.md +161 -0
  233. package/skills/shared/council-protocol.md +265 -0
  234. package/skills/shared/distribution-diagnostics.md +164 -0
  235. package/skills/shared/engagement-stratified-sampling.md +218 -0
  236. package/skills/shared/escalation-protocol.md +74 -0
  237. package/skills/shared/external-audit-protocol.md +205 -0
  238. package/skills/shared/intercoder-reliability.md +256 -0
  239. package/skills/shared/mcp-degradation.md +81 -0
  240. package/skills/shared/method-probing-questions.md +163 -0
  241. package/skills/shared/multi-language-conventions.md +143 -0
  242. package/skills/shared/paid-api-safety.md +174 -0
  243. package/skills/shared/palettes.md +90 -0
  244. package/skills/shared/progressive-disclosure.md +92 -0
  245. package/skills/shared/project-documentation-content.md +443 -0
  246. package/skills/shared/project-documentation-format.md +281 -0
  247. package/skills/shared/project-documentation.md +100 -0
  248. package/skills/shared/publication-output.md +138 -0
  249. package/skills/shared/quality-scoring.md +70 -0
  250. package/skills/shared/reference-resolution.md +77 -0
  251. package/skills/shared/research-quality-rubric.md +165 -0
  252. package/skills/shared/rhetoric-principles.md +54 -0
  253. package/skills/shared/skill-design-patterns.md +272 -0
  254. package/skills/shared/skill-index.md +240 -0
  255. package/skills/shared/system-documentation.md +334 -0
  256. package/skills/shared/tikz-rules.md +402 -0
  257. package/skills/shared/validation-tiers.md +121 -0
  258. package/skills/shared/venue-guides/README.md +46 -0
  259. package/skills/shared/venue-guides/cell_press_style.md +483 -0
  260. package/skills/shared/venue-guides/conferences_formatting.md +564 -0
  261. package/skills/shared/venue-guides/cs_conference_style.md +463 -0
  262. package/skills/shared/venue-guides/examples/cell_summary_example.md +247 -0
  263. package/skills/shared/venue-guides/examples/medical_structured_abstract.md +313 -0
  264. package/skills/shared/venue-guides/examples/nature_abstract_examples.md +213 -0
  265. package/skills/shared/venue-guides/examples/neurips_introduction_example.md +245 -0
  266. package/skills/shared/venue-guides/journals_formatting.md +486 -0
  267. package/skills/shared/venue-guides/medical_journal_styles.md +535 -0
  268. package/skills/shared/venue-guides/ml_conference_style.md +556 -0
  269. package/skills/shared/venue-guides/nature_science_style.md +405 -0
  270. package/skills/shared/venue-guides/reviewer_expectations.md +417 -0
  271. package/skills/shared/venue-guides/venue_writing_styles.md +321 -0
  272. package/skills/split-pdf/SKILL.md +172 -0
  273. package/skills/split-pdf/methodology.md +48 -0
  274. package/skills/sync-notion/SKILL.md +93 -0
  275. package/skills/system-audit/SKILL.md +157 -0
  276. package/skills/system-audit/references/sub-agent-prompts.md +294 -0
  277. package/skills/task-management/SKILL.md +131 -0
  278. package/skills/update-focus/SKILL.md +204 -0
  279. package/skills/update-project-doc/SKILL.md +194 -0
  280. package/skills/validate-bib/SKILL.md +242 -0
  281. package/skills/validate-bib/references/council-mode.md +34 -0
  282. package/skills/validate-bib/references/deep-verify.md +71 -0
  283. package/skills/validate-bib/references/openalex-verification.md +45 -0
  284. package/skills/validate-bib/references/preprint-check.md +31 -0
  285. package/skills/validate-bib/references/report-template.md +62 -0
@@ -0,0 +1,141 @@
1
+ ---
2
+ name: latex
3
+ description: "Use when you need to compile a LaTeX document or manage LaTeX projects."
4
+ allowed-tools: Bash(latexmk*), Bash(xelatex*), Bash(pdflatex*), Bash(biber*), Bash(bibtex*), Bash(mkdir*), Bash(ls*), Read, Write, Edit
5
+ argument-hint: [tex-file-path]
6
+ ---
7
+
8
+ # LaTeX Document Compilation
9
+
10
+ ## Critical Rules
11
+
12
+ 1. **Build artifacts go to `out/`, but the PDF stays in the source directory.** Before compiling, check for `.latexmkrc` — if missing, create one with the standard config (see Output Directory section). The `.latexmkrc` uses a Perl `END {}` block to copy the PDF back to the source directory after each build.
13
+ 2. **NEVER write BibTeX entries from memory.** Always verify against web sources (CrossRef, Google Scholar, DOI lookup) before writing. See the `literature` skill.
14
+ 3. **Check document class before adding packages.** Some classes load packages internally (e.g., `elsarticle` loads `natbib` — adding `\usepackage{natbib}` causes errors).
15
+
16
+ ## Overleaf-Synced Projects
17
+
18
+ When a project is synced to Overleaf (via Dropbox or Git):
19
+ - The `out/` directory will sync to Overleaf but Overleaf ignores it — this is fine
20
+ - Always use `.latexmkrc` to enforce `out/` — Overleaf ignores this file too
21
+ - Overleaf compiles independently on its server; local compilation is for verification only
22
+ - The `.bst` file (e.g., `elsarticle-harv.bst`) lives in the source directory, not `out/`
23
+
24
+ ## When NOT to Use
25
+
26
+ - Markdown documents — use plain markdown, not LaTeX
27
+ - Quick notes or drafts — LaTeX overhead not worth it
28
+ - Documents that don't need citations, equations, or precise formatting
29
+
30
+ ## Local-Only Projects (No Overleaf)
31
+
32
+ Not all projects sync to Overleaf. For local-only projects:
33
+ - The same `out/` and `.latexmkrc` conventions apply — this keeps the working directory clean regardless of sync method
34
+ - There is no `paper/` symlink — `.tex` files live directly in the project root or a subdirectory
35
+ - Use `/latex-autofix` for compilation — it handles `.latexmkrc` creation if missing
36
+
37
+ ## Templates
38
+
39
+ ### Working Paper Template
40
+
41
+ When creating a **new working paper**, use the template. The canonical location is the local git repo:
42
+
43
+ 1. `templates/latex-wp/` (in Task Management — canonical source, git-tracked)
44
+
45
+ The template contains:
46
+
47
+ | File | Purpose |
48
+ |------|---------|
49
+ | `main.tex` | Document entry point with structure |
50
+ | `your-template.sty` | Packages, layout, formatting, math environments |
51
+ | `your-bib-template.sty` | Bibliography config (biblatex, source cleanup, Harvard style) |
52
+ | `references.bib` | Bibliography file (initially empty) |
53
+ | `out/` | Compilation output directory |
54
+
55
+ **To create a new working paper:**
56
+
57
+ 1. Copy the template files to your new project folder
58
+ 2. Rename as needed
59
+ 3. Update `main.tex` with your title, author, abstract
60
+ 4. Add references to `references.bib`
61
+ 5. Compile with `latexmk main.tex`
62
+
63
+ ### Citation Style Toggle
64
+
65
+ The template uses **biblatex/biber** with a toggle for Harvard vs generic authoryear style.
66
+
67
+ In `main.tex`, control the style via package option:
68
+
69
+ ```latex
70
+ \usepackage[harvard]{your-bib-template} % Harvard style (default)
71
+ \usepackage[noharvard]{your-bib-template} % Generic authoryear style
72
+ ```
73
+
74
+ **Harvard style features:**
75
+ - Author names: Family, G.
76
+ - Volume in bold, issue in parentheses
77
+ - DOI/URL shown as "Available at: ..."
78
+ - No dashes for repeated authors
79
+
80
+ ### Bibliography File Naming
81
+
82
+ **Always name the bibliography file `references.bib`** — for any paper, whether using the working paper template or not. This is the standard naming convention across all projects.
83
+
84
+ ### Bibliography Commands
85
+
86
+ The template uses biblatex. In `main.tex`:
87
+
88
+ ```latex
89
+ \printbibliography % (not \bibliography{references})
90
+ ```
91
+
92
+ If you need natbib instead, do not load `your-bib-template` and use:
93
+ ```latex
94
+ \bibliographystyle{agsm}
95
+ \bibliography{references}
96
+ ```
97
+
98
+ **Note:** This template is for working papers only. Other document types (presentations, theses, etc.) may require different templates.
99
+
100
+ ---
101
+
102
+ ## Output Directory
103
+
104
+ All LaTeX build artifacts (`.aux`, `.log`, `.bbl`, `.fls`, etc.) go to an `out/` subfolder relative to the source file. The **PDF is copied back** to the source directory after each successful build, so it lives alongside the `.tex` file for easy access. This keeps the working directory clean while keeping the deliverable visible.
105
+
106
+ ## Configuration
107
+
108
+ The PDF-copy convention is enforced in **two places** — keep them in sync when making changes:
109
+
110
+ 1. **`.latexmkrc`** (per-project) — Perl `END {}` block copies PDF after terminal/Claude Code builds
111
+ 2. **VS Code `.vscode/settings.json`** (per-workspace) — explicit latexmk args in LaTeX Workshop tool definition
112
+
113
+ Place a `.latexmkrc` in the project root to enforce output directory automatically.
114
+
115
+ VS Code integration, engine auto-detection (pdfLaTeX/XeLaTeX/LuaLaTeX), manual override configs, reference checking scripts, and manual compilation commands:
116
+
117
+ **[references/latex-configs.md](references/latex-configs.md)**
118
+
119
+ ---
120
+
121
+ ## LaTeX Skill Hierarchy
122
+
123
+ Three compilation skills exist for different scopes. Use this decision tree:
124
+
125
+ ```
126
+ Need to compile LaTeX?
127
+ ├── Single project, want auto error resolution?
128
+ │ └── /latex-autofix (default — 5 iterations, citation audit, quality score)
129
+ ├── Single project, need manual control or config reference?
130
+ │ └── /latex (this skill — .latexmkrc setup, engine selection, VS Code config)
131
+ └── Multiple projects / fleet-wide health check?
132
+ └── /latex-health-check (project discovery, 3 iterations per project, cross-project checks)
133
+ ```
134
+
135
+ | Skill | Scope | Iterations | Extra features |
136
+ |-------|-------|------------|----------------|
137
+ | `/latex` | Single project | Manual | Config reference, engine auto-detection, VS Code integration |
138
+ | `/latex-autofix` | Single project | Up to 5 | Auto error fix, citation audit, quality score |
139
+ | `/latex-health-check` | All projects | Up to 3 each | Project discovery, symlink integrity, Overleaf separation, template drift |
140
+
141
+ **Rule of thumb:** Use `/latex-autofix` by default. Use `/latex` when you need to understand or configure the build system. Use `/latex-health-check` for periodic maintenance.
@@ -0,0 +1,183 @@
1
+ # LaTeX Configuration Reference
2
+
3
+ > VS Code integration, engine auto-detection, manual overrides, and reference checking scripts.
4
+ > Referenced from `SKILL.md` — the parent file has a summary + pointer.
5
+
6
+ ## VS Code LaTeX Workshop Gotchas
7
+
8
+ 1. **`.latexmkrc` in subdirectories is NOT picked up.** LaTeX Workshop runs latexmk from the workspace root, not the `.tex` file's directory. Subdirectory `.latexmkrc` files are ignored. Fix: pass `-cd -lualatex -outdir=out` (or `-cd -pdf -outdir=out` for pdfLaTeX) explicitly in the VS Code tool args. The `-cd` flag makes latexmk change to the `.tex` file's directory before running.
9
+ 2. **`% !TEX program` magic comments override custom recipes.** LaTeX Workshop looks for a tool whose name matches the program (e.g., `lualatex`). If no match, it falls back to a default recipe that ignores `-outdir`. Fix: set `"latex-workshop.latex.build.forceRecipeUsage": true` in `.vscode/settings.json`.
10
+
11
+ ### Recommended `.vscode/settings.json` for LuaLaTeX projects
12
+
13
+ ```json
14
+ {
15
+ "latex-workshop.latex.tools": [
16
+ {
17
+ "name": "latexmk",
18
+ "command": "latexmk",
19
+ "args": [
20
+ "-cd",
21
+ "-lualatex",
22
+ "-outdir=out",
23
+ "-interaction=nonstopmode",
24
+ "-halt-on-error",
25
+ "-synctex=1",
26
+ "%DOC%"
27
+ ],
28
+ "env": {}
29
+ }
30
+ ],
31
+ "latex-workshop.latex.recipes": [
32
+ {
33
+ "name": "latexmk (LuaLaTeX → out/)",
34
+ "tools": ["latexmk"]
35
+ }
36
+ ],
37
+ "latex-workshop.latex.outDir": "%DIR%/out",
38
+ "latex-workshop.latex.build.forceRecipeUsage": true
39
+ }
40
+ ```
41
+
42
+ Swap `-lualatex` for `-pdf` (pdfLaTeX) or `-xelatex` as needed. The `.latexmkrc` remains the authority for terminal builds.
43
+
44
+ ---
45
+
46
+ ## Auto-detecting Engine
47
+
48
+ This config automatically uses XeLaTeX if the document or any `\input{}`/`\include{}` file contains `\usepackage{fontspec}`, otherwise falls back to pdfLaTeX:
49
+
50
+ ```perl
51
+ # .latexmkrc
52
+ $out_dir = 'out';
53
+
54
+ # Copy PDF back to source directory after build
55
+ END { system("cp $out_dir/*.pdf . 2>/dev/null") if defined $out_dir; }
56
+
57
+ # Recursively check for fontspec in main file and all \input{}/\include{} files
58
+ sub needs_xelatex {
59
+ my ($file, $seen) = @_;
60
+ $seen //= {};
61
+
62
+ # Normalize and check if already visited
63
+ return 0 if $seen->{$file};
64
+ $seen->{$file} = 1;
65
+
66
+ # Try with and without .tex extension
67
+ my $filepath = -e $file ? $file : -e "$file.tex" ? "$file.tex" : undef;
68
+ return 0 unless $filepath;
69
+
70
+ open(my $fh, '<', $filepath) or return 0;
71
+ my $dir = $filepath =~ s|/[^/]*$||r; # Directory of current file
72
+ $dir = '.' if $dir eq $filepath;
73
+
74
+ while (<$fh>) {
75
+ return 1 if /\\usepackage.*\{fontspec\}/;
76
+
77
+ # Recurse into \input{} and \include{} files
78
+ if (/\\(?:input|include)\{([^}]+)\}/) {
79
+ my $subfile = $1;
80
+ $subfile = "$dir/$subfile" unless $subfile =~ m|^/|;
81
+ return 1 if needs_xelatex($subfile, $seen);
82
+ }
83
+ }
84
+ close($fh);
85
+ return 0;
86
+ }
87
+
88
+ # Auto-detect engine
89
+ $pdf_mode = 1; # Default to pdflatex
90
+ foreach my $file (@ARGV) {
91
+ if (needs_xelatex($file)) {
92
+ $pdf_mode = 5; # Switch to xelatex
93
+ last;
94
+ }
95
+ }
96
+
97
+ $pdflatex = 'pdflatex -interaction=nonstopmode -halt-on-error %O %S';
98
+ $xelatex = 'xelatex -interaction=nonstopmode -halt-on-error %O %S';
99
+ ```
100
+
101
+ ---
102
+
103
+ ## Manual Override Configs
104
+
105
+ If auto-detection doesn't suit a project, use one of these explicit configs:
106
+
107
+ **pdfLaTeX** (standard LaTeX fonts):
108
+ ```perl
109
+ # .latexmkrc
110
+ $out_dir = 'out';
111
+ $pdf_mode = 1;
112
+ $pdflatex = 'pdflatex -interaction=nonstopmode -halt-on-error %O %S';
113
+ END { system("cp $out_dir/*.pdf . 2>/dev/null") if defined $out_dir; }
114
+ ```
115
+
116
+ **XeLaTeX** (system fonts, Unicode, OpenType features):
117
+ ```perl
118
+ # .latexmkrc
119
+ $out_dir = 'out';
120
+ $pdf_mode = 5;
121
+ $xelatex = 'xelatex -interaction=nonstopmode -halt-on-error %O %S';
122
+ END { system("cp $out_dir/*.pdf . 2>/dev/null") if defined $out_dir; }
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Reference Checking
128
+
129
+ Every compilation must verify that all references resolve correctly. After compilation, check the log and report any issues found.
130
+
131
+ ### Reference Check Script
132
+
133
+ After running latexmk, check for issues and display them as warnings:
134
+
135
+ ```bash
136
+ # Compile
137
+ latexmk document.tex
138
+
139
+ # Check for reference issues and report exact problems
140
+ LOGFILE="out/document.log"
141
+ ISSUES=$(grep -E "(Reference.*undefined|Citation.*undefined|multiply defined)" "$LOGFILE" 2>/dev/null)
142
+
143
+ if [ -n "$ISSUES" ]; then
144
+ echo ""
145
+ echo "⚠️ REFERENCE ISSUES DETECTED:"
146
+ echo "================================"
147
+ echo "$ISSUES" | while read -r line; do
148
+ echo " • $line"
149
+ done
150
+ echo "================================"
151
+ echo ""
152
+ fi
153
+ ```
154
+
155
+ ### What to Check For
156
+
157
+ | Pattern | Meaning |
158
+ |---------|---------|
159
+ | `Reference .* undefined` | `\ref{}` or `\autoref{}` pointing to non-existent label |
160
+ | `Citation .* undefined` | `\cite{}` referencing missing BibTeX entry |
161
+ | `Label .* multiply defined` | Same `\label{}` used more than once |
162
+
163
+ ### Manual Compilation (if not using latexmk)
164
+
165
+ For biblatex (default in working paper template):
166
+ ```bash
167
+ mkdir -p out
168
+ xelatex -output-directory=out document.tex
169
+ biber out/document
170
+ xelatex -output-directory=out document.tex
171
+ xelatex -output-directory=out document.tex
172
+ cp out/document.pdf ./document.pdf
173
+ ```
174
+
175
+ For natbib (if using that instead):
176
+ ```bash
177
+ mkdir -p out
178
+ pdflatex -output-directory=out document.tex
179
+ bibtex out/document
180
+ pdflatex -output-directory=out document.tex
181
+ pdflatex -output-directory=out document.tex
182
+ cp out/document.pdf ./document.pdf
183
+ ```
@@ -0,0 +1,230 @@
1
+ ---
2
+ name: latex-autofix
3
+ description: "Use when you need to compile LaTeX with autonomous error resolution and citation audit."
4
+ allowed-tools: Bash(latexmk*), Bash(xelatex*), Bash(pdflatex*), Bash(biber*), Bash(bibtex*), Bash(mkdir*), Bash(ls*), Bash(wc*), Bash(cp*), Read, Write, Edit, Grep, Glob
5
+ argument-hint: [tex-file-path]
6
+ ---
7
+
8
+ # LaTeX Auto-Fix Compilation
9
+
10
+ > Compile LaTeX documents with autonomous error detection and resolution. Wraps the standard `/latex` workflow with a fix-loop that handles the most common compilation failures without manual intervention.
11
+
12
+ ## When to Use
13
+
14
+ - **Default method** for all LaTeX compilation — use this instead of `/latex` unless you need manual control
15
+ - Any `.tex` file that should compile to PDF
16
+ - When compilation fails and you want automatic diagnosis and repair
17
+ - When you want a post-compilation citation audit
18
+
19
+ ## When NOT to Use
20
+
21
+ - Quick one-off compilations where you already know the document is clean — `/latex` is fine
22
+ - Documents with exotic custom classes that need manual debugging
23
+
24
+ ---
25
+
26
+ ## Quality Scoring
27
+
28
+ Apply numeric quality scoring using the shared framework and skill-specific rubric:
29
+
30
+ - **Framework:** [`../shared/quality-scoring.md`](../shared/quality-scoring.md) — severity tiers, thresholds, verdict rules
31
+ - **Rubric:** [`references/quality-rubric.md`](references/quality-rubric.md) — issue-to-deduction mappings for this skill
32
+
33
+ Start at 100, deduct per issue found, apply verdict. Include the Score Block in the Phase 5 report.
34
+
35
+ ## Critical Rules
36
+
37
+ 1. **Build artifacts go to `out/`, PDF stays in the source directory.** Ensure `.latexmkrc` exists with `$out_dir = 'out'` and an `END {}` block to copy the PDF back (see pre-flight below). For VS Code builds, `.latexmkrc` in subdirectories is **not picked up** — see `/latex` skill's "VS Code LaTeX Workshop Gotchas" section for the required `.vscode/settings.json` config (`-cd`, `-outdir=out`, `forceRecipeUsage: true`).
38
+ 2. **Maximum 5 fix iterations.** If the document still has errors after 5 auto-fix cycles, stop and report the unresolved errors to the user.
39
+ 3. **Never silently swallow errors.** Every fix must be reported: what was wrong, what was changed, and which file was edited.
40
+ 4. **Preserve user intent.** Auto-fixes should be minimal and conservative. Add packages or overrides — never remove user content.
41
+ 5. **Citation audit requires clean compilation.** Only run the `\cite{}` vs `.bib` cross-check after zero errors.
42
+ 6. **Run `/bib-validate` when new citations were added.** The Phase 4 citation audit only checks key cross-references. When `.bib` entries were added or modified since the last validation, also run `/bib-validate` for full metadata quality checks (preprint staleness, DOI presence, required fields, author formatting). This is mandatory — do not skip it.
43
+
44
+ ---
45
+
46
+ ## Protocol
47
+
48
+ ### Phase 1: Pre-flight
49
+
50
+ 1. **Locate the `.tex` file.** Resolve the path (absolute or relative to CWD).
51
+ 2. **Identify the project directory** — the folder containing the `.tex` file.
52
+ 3. **Ensure `.latexmkrc` exists** in the project directory with at minimum:
53
+ ```perl
54
+ $out_dir = 'out';
55
+ # Copy PDF back to source directory after build
56
+ END { system("cp $out_dir/*.pdf . 2>/dev/null") if defined $out_dir; }
57
+ ```
58
+ If a `.latexmkrc` already exists, verify it sets `$out_dir = 'out'` and has the `END {}` block. If either is missing, add it. Do not overwrite other settings.
59
+ 4. **Create `out/` directory** if it doesn't exist: `mkdir -p <project-dir>/out`.
60
+ 5. **Identify the `.bib` file(s)** referenced in the document (scan for `\bibliography{}`, `\addbibresource{}`, or `\bibinput{}`). Note their paths for Phase 3.
61
+
62
+ ### Phase 2: Compile–Fix Loop
63
+
64
+ Run up to **5 iterations**. Each iteration:
65
+
66
+ #### Step 2a — Compile
67
+
68
+ ```bash
69
+ cd <project-dir> && latexmk -interaction=nonstopmode <filename>.tex 2>&1
70
+ ```
71
+
72
+ Capture the full output. The log file will be at `out/<filename>.log`.
73
+
74
+ #### Step 2b — Read the log
75
+
76
+ Read `out/<filename>.log` in full. Parse for errors and warnings.
77
+
78
+ #### Step 2c — Classify errors
79
+
80
+ Check the log against the known error patterns below. If an error matches, apply the fix and go to Step 2a. If no known pattern matches, record the error as **unresolved** and stop the loop.
81
+
82
+ ---
83
+
84
+ ### Known Error Patterns & Auto-Fixes
85
+
86
+ Check the log against these patterns. Full fix instructions: [`references/known-errors.md`](references/known-errors.md)
87
+
88
+ | # | Pattern | Key log signature |
89
+ |---|---------|-------------------|
90
+ | 1 | Missing package | `File '<pkg>.sty' not found` or undefined command from known package |
91
+ | 2 | Font/symbol conflicts | `Command \<name> already defined` |
92
+ | 3 | Undefined citation | `Citation '<key>' ... undefined` or biblatex entry not found |
93
+ | 4 | Missing image/file | `File '<path>' not found` (pdftex.def or LaTeX) |
94
+ | 5 | Stale auxiliary files | Corrupted `.aux`/`.bbl`/`.bcf`, or `no \bibstyle command` |
95
+ | 6 | Beamer/enumitem clash | `Option clash for package enumitem` or `\item already defined` |
96
+ | 7 | xcolor option conflicts | `Option clash for package xcolor` or undefined `\rowcolor` |
97
+ | 8 | TikZ reserved keys | `I do not know the key '/tikz/<name>'` or pgfkeys error |
98
+
99
+ If an error matches, read the full fix from the reference and apply it. If no pattern matches, record as **unresolved** and stop the loop.
100
+
101
+ ---
102
+
103
+ ### Phase 2.5: PDF Backup (paper directories only)
104
+
105
+ **Only run if Phase 2 ended with a successful compilation (PDF exists).**
106
+
107
+ If the `.tex` file is inside a `paper-{venue}/paper/` structure (where `paper/` is a symlink to Overleaf):
108
+
109
+ 1. **Identify the paper wrapper** — the parent of the `paper/` symlink (e.g., `paper-jbdm/`).
110
+ 2. **Create the backup directory:** `mkdir -p <paper-wrapper>/backup`
111
+ 3. **Copy the PDF:**
112
+ ```bash
113
+ cp <paper-wrapper>/paper/<filename>.pdf <paper-wrapper>/backup/<wrapper-name>_vcurrent.pdf
114
+ ```
115
+ Example: `paper-jbdm/paper/main.pdf` → `paper-jbdm/backup/paper-jbdm_vcurrent.pdf`
116
+
117
+ **Detection logic:**
118
+ - The project directory containing the `.tex` file is a symlink named `paper`
119
+ - Its parent directory name starts with `paper-`
120
+ - If either condition is false, skip this phase silently
121
+
122
+ **Skip if:** compilation failed, or the `.tex` file is not inside a paper directory structure.
123
+
124
+ ---
125
+
126
+ ### Phase 3: Final Report
127
+
128
+ After the loop ends (either clean compilation or max iterations reached), report:
129
+
130
+ #### Compilation Status
131
+
132
+ | Field | Value |
133
+ |-------|-------|
134
+ | **Status** | Clean / Errors remaining |
135
+ | **Iterations** | N of 5 |
136
+ | **Pages** | (from log: `Output written on ... (N pages)`) |
137
+ | **Warnings** | Count of remaining warnings (overfull/underfull hbox, etc.) |
138
+ | **Fixes applied** | List each fix: what error, what was changed, which file |
139
+ | **Unresolved errors** | List any errors that couldn't be auto-fixed |
140
+
141
+ #### How to extract page count
142
+
143
+ ```bash
144
+ grep -o "Output written on .* ([0-9]* page" out/<filename>.log | grep -o "[0-9]* page"
145
+ ```
146
+
147
+ #### How to count warnings
148
+
149
+ ```bash
150
+ grep -c "Warning" out/<filename>.log
151
+ ```
152
+
153
+ ---
154
+
155
+ ### Phase 4: Citation Audit (clean builds only)
156
+
157
+ **Only run this phase if Phase 2 ended with zero errors.**
158
+
159
+ 1. **Extract all `\cite` keys** from the `.tex` file (and any `\input`/`\include` files):
160
+ - Match `\cite{...}`, `\citep{...}`, `\citet{...}`, `\textcite{...}`, `\parencite{...}`, `\autocite{...}`, and multi-key variants like `\cite{key1,key2}`.
161
+ 2. **Extract all bib entry keys** from the `.bib` file(s): match `@<type>{<key>,`.
162
+ 3. **Cross-reference:**
163
+
164
+ | Check | What it finds |
165
+ |-------|--------------|
166
+ | **Missing in .bib** | Keys cited in `.tex` but absent from `.bib` |
167
+ | **Unused in .tex** | Keys defined in `.bib` but never cited |
168
+ | **Possible typos** | Near-matches between missing cite keys and existing bib keys |
169
+
170
+ 4. **Report** the results as a table. Do not modify any files during the audit — report only.
171
+
172
+ ---
173
+
174
+ ### Phase 5: Quality Score
175
+
176
+ After all phases complete, compute the quality score:
177
+
178
+ 1. Read [`references/quality-rubric.md`](references/quality-rubric.md) for deduction mappings.
179
+ 2. Log every issue from Phases 2-4 (unresolved errors, remaining warnings, citation mismatches).
180
+ 3. Compute score (100 - total deductions), apply verdict per [`../shared/quality-scoring.md`](../shared/quality-scoring.md).
181
+ 4. Append the Score Block to the compilation report:
182
+
183
+ ```markdown
184
+ ## Quality Score
185
+
186
+ | Metric | Value |
187
+ |--------|-------|
188
+ | **Score** | XX / 100 |
189
+ | **Verdict** | Ship / Ship with notes / Revise / Revise (major) / Blocked |
190
+
191
+ ### Deductions
192
+
193
+ | # | Issue | Tier | Deduction | Category |
194
+ |---|-------|------|-----------|----------|
195
+ | 1 | [description] | [tier] | -X | [category] |
196
+ | | **Total deductions** | | **-XX** | |
197
+ ```
198
+
199
+ ---
200
+
201
+ ## Integration with Other Skills
202
+
203
+ | Situation | Delegate to |
204
+ |-----------|-------------|
205
+ | Need to find or verify a bibliography entry | `/literature` |
206
+ | Full academic proofreading after clean compilation | `/proofread` |
207
+ | Detailed `.bib` validation beyond cite-key matching | `/bib-validate` |
208
+ | Beamer presentations specifically | `/beamer-deck` (which uses this skill internally for compilation) |
209
+
210
+ ---
211
+
212
+ ## Examples
213
+
214
+ ### Basic usage
215
+
216
+ > "Compile my paper at `~/papers/mcdm-survey/main.tex`"
217
+
218
+ Runs the full protocol: pre-flight → compile–fix loop → report → citation audit.
219
+
220
+ ### After fixing a known issue
221
+
222
+ > "Recompile — I added the missing package manually"
223
+
224
+ Runs from Phase 2 directly (pre-flight can be skipped if `.latexmkrc` and `out/` already exist).
225
+
226
+ ### Targeted fix
227
+
228
+ > "My paper won't compile — something about Bbbk"
229
+
230
+ Identifies as Pattern 2 (font conflict), applies the `\let\Bbbk\relax` fix, recompiles.