infrastructure-llm
Skill for the LLM infrastructure module providing local Large Language Model integration via Ollama. Covers client initialization, prompt templates, output validation, manuscript review generation, conversation context, and CLI usage. Use when querying LLMs, generating manuscript reviews, validating LLM outputs, or managing Ollama models.
Best use case
infrastructure-llm is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Skill for the LLM infrastructure module providing local Large Language Model integration via Ollama. Covers client initialization, prompt templates, output validation, manuscript review generation, conversation context, and CLI usage. Use when querying LLMs, generating manuscript reviews, validating LLM outputs, or managing Ollama models.
Teams using infrastructure-llm should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/llm/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How infrastructure-llm Compares
| Feature / Agent | infrastructure-llm | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Skill for the LLM infrastructure module providing local Large Language Model integration via Ollama. Covers client initialization, prompt templates, output validation, manuscript review generation, conversation context, and CLI usage. Use when querying LLMs, generating manuscript reviews, validating LLM outputs, or managing Ollama models.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# LLM Module
Local Large Language Model integration for research assistance via Ollama.
## Module Structure
```mermaid
flowchart LR
LLM[/llm//]
LLM --> CORE[/core<br/>client · config · context/]
LLM --> TPL[/templates<br/>prompt templates for research/]
LLM --> VAL[/validation<br/>output quality validation/]
LLM --> RV[/review<br/>manuscript review generation/]
LLM --> PR[/prompts<br/>fragment composition system/]
LLM --> UT[/utils<br/>Ollama server management/]
LLM --> CLI[/cli<br/>command-line interface/]
classDef d fill:#0f172a,stroke:#0f172a,color:#fff
classDef pkg fill:#1e3a8a,stroke:#0f172a,color:#fff
class LLM d
class CORE,TPL,VAL,RV,PR,UT,CLI pkg
```
## LLM Client (`core/client.py`)
```python
from infrastructure.llm import LLMClient, OllamaClientConfig, GenerationOptions
# Initialize with defaults
client = LLMClient()
# Custom configuration
config = OllamaClientConfig(default_model="gemma3:4b", temperature=0.7)
client = LLMClient(config)
# Generate a response
response = client.query("Summarize this paper...", options=GenerationOptions(
max_tokens=2000,
temperature=0.3,
))
```
## Conversation Context (`core/context.py`)
```python
from infrastructure.llm.core import ConversationContext, Message
context = ConversationContext()
context.add(Message(role="user", content="What is active inference?"))
context.add(Message(role="assistant", content="Active inference is..."))
```
## Prompt Templates (`templates/`)
Pre-built research task templates:
```python
from infrastructure.llm import get_template
from infrastructure.llm.templates import (
ResearchTemplate, PaperSummarization,
ManuscriptExecutiveSummary, ManuscriptQualityReview,
ManuscriptMethodologyReview, ManuscriptImprovementSuggestions,
ManuscriptTranslationAbstract,
)
# Get a template by name
template = get_template("paper_summarization")
# Use specific template classes
summary_template = ManuscriptExecutiveSummary()
prompt = summary_template.format(manuscript_text=text)
```
## Output Validation (`validation/`)
Validation was decomposed into module-level functions in v0.6.0 — the
previous `OutputValidator` class is gone; call the individual checks
directly.
```python
from infrastructure.llm import is_off_topic
from infrastructure.llm.validation import (
detect_repetition,
check_format_compliance, validate_section_completeness,
calculate_unique_content_ratio, deduplicate_sections,
)
# Individual checks
if is_off_topic(response_text):
logger.warning("Response appears off-topic")
if detect_repetition(response_text):
logger.warning("Response contains repeated content")
ratio = calculate_unique_content_ratio(response_text)
```
## Manuscript Review Generation (`review/`)
```python
from infrastructure.llm.review import (
create_review_client, select_and_start_ollama_model, warmup_model,
extract_manuscript_text, generate_review_with_metrics,
generate_llm_executive_summary, generate_improvement_suggestions,
generate_translation, save_review_outputs,
)
from infrastructure.llm.review.generator import (
generate_quality_review, generate_methodology_review,
)
# Full review workflow
client = create_review_client()
warmup_model(client)
text = extract_manuscript_text(manuscript_dir)
executive = generate_llm_executive_summary(client, text)
quality = generate_quality_review(client, text)
methodology = generate_methodology_review(client, text)
suggestions = generate_improvement_suggestions(client, text)
save_review_outputs(output_dir, executive=executive, quality=quality,
methodology=methodology, suggestions=suggestions)
```
## Ollama Utilities (`utils/`)
```python
from infrastructure.llm.utils import (
is_ollama_running, start_ollama_server, ensure_ollama_ready,
get_model_names, select_best_model,
select_small_fast_model, preload_model, check_model_loaded,
)
# Check and start Ollama
if not is_ollama_running():
start_ollama_server()
ensure_ollama_ready()
models = get_model_names()
best = select_best_model()
```
## Prompt Composition (`prompts/`)
```python
from infrastructure.llm.prompts import PromptFragmentLoader, PromptComposer
loader = PromptFragmentLoader()
composer = PromptComposer(loader)
prompt = composer.compose(task="review", context=manuscript_text)
```
## CLI Usage
```bash
# Query the LLM
uv run python -m infrastructure.llm.cli.main query "What is machine learning?"
# Check Ollama status
uv run python -m infrastructure.llm.cli.main check
# List available models
uv run python -m infrastructure.llm.cli.main models
```Related Skills
infrastructure-validation
Skill for the validation infrastructure module providing PDF validation, markdown validation, output integrity checks, link verification, documentation audits, issue categorization, and repository scanning. Use when validating research outputs, checking document quality, running audits, or verifying cross-references.
infrastructure-steganography
Skill for the steganography infrastructure module providing QR code generation with dynamic mailto links, hash manifests, metadata payloads, and document-wide overlay processing. Use this module to insert opt-in cryptographic and steganographic provenance data onto PDFs.
infrastructure-skills
Programmatic discovery of first-party agent SKILL.md files under configured public repo roots (infrastructure, projects, docs/prompts, and .cursor/skills). Use when enumerating skills, validating .cursor/skill_manifest.json, writing docs/_generated/skills_index.md, checking docs/prompts workflow contracts, or wiring editor automation. Exposes discover_skills, write_skill_manifest, manifest_matches_discovery, and check_skill_contracts.
infrastructure-search-literature
Paperclip-style multi-source literature search across arXiv, Crossref, local JSON corpora, and (opt-in) the Paperclip API. Provides Paper/SearchQuery/SearchResult data models, a LiteratureClient aggregator with per-backend failure isolation, DOI/arXiv-aware deduplication via merge_papers, deterministic JSON caching via SearchCache, an HttpClient protocol for test injection, and a CLI (search/to-bibtex). Use when finding papers by topic, building reading lists, populating references.bib from a query, or replaying a prior search reproducibly.
infrastructure-search
Discovery utilities for academic literature. Currently exposes the `literature` submodule — Paperclip-style multi-source search across arXiv, Crossref, local JSON corpora, and (opt-in) the Paperclip API, with deterministic JSON caching, a `LiteratureClient` aggregator, normalised `Paper` records, and a CLI. Use when the user wants to find papers, build reading lists, populate references.bib from a query, or replay a prior search reproducibly. Designed to host additional discovery workflows without breaking the public API.
infrastructure-scientific
Skill for the scientific infrastructure module providing numerical stability checks, performance benchmarking, scientific documentation generation, implementation validation, and module/workflow templates. Use when benchmarking functions, checking numerical stability, validating scientific implementations, or creating scientific module scaffolds.
infrastructure-reporting
Skill for the reporting infrastructure module providing pipeline reporting, error aggregation, executive summaries, dashboard generation, test reporting, and multi-project reports. Use when generating build reports, aggregating errors, creating visual dashboards, or producing executive summaries across projects.
infrastructure-rendering
Skill for the rendering infrastructure module providing multi-format output generation including PDF manuscripts, HTML web pages, Beamer/Reveal.js slides, and posters. Use when rendering research outputs, converting markdown to PDF, generating slides, or configuring LaTeX rendering.
infrastructure-reference-citation
BibTeX read/write/convert that matches the syntax/semantics of projects/template_code_project/manuscript/references.bib (consumed by Pandoc with --natbib -- see infrastructure/rendering/_pdf_combined_renderer.py). Provides BibEntry/BibDatabase models, parse_bibfile/render_database functions, paper_to_bibentry conversion from literature search results, generate_citation_key in the project's house style (firstauthorlastname+year+firsttitleword), LaTeX-special-character escape helpers, and a CLI (validate/format/convert). Use when reading or writing .bib files, exporting search results to BibTeX, or generating citation keys.
infrastructure-reference
Bibliographic-reference utilities for research projects. Read, write, and convert BibTeX entries that match the syntax/semantics of projects/template_code_project/manuscript/references.bib (consumed by Pandoc with --natbib during PDF render -- see infrastructure/rendering/_pdf_combined_renderer.py). Currently exposes the `citation` submodule (BibTeX I/O + Paper→BibEntry conversion); designed to host additional reference workflows (e.g. CSL-JSON export, ORCID lookups) without breaking the public API.
infrastructure-publishing
Skill for the publishing infrastructure module providing academic publishing workflows including BibTeX CLI citation generation, APA/MLA citation helper functions, DOI management, Zenodo publication, arXiv submission preparation, GitHub releases, and publication readiness validation. Use when publishing research, generating citations, minting DOIs, or preparing submissions.
infrastructure-prose
Prose analysis utilities for research manuscripts and prose-focused projects. Provides readability metrics (Flesch, Flesch-Kincaid, Gunning Fog), heading-outline structural analysis, editorial quality flags (passive voice, hedge words, citation density, long sentences), aggregate ManuscriptReport across a manuscript directory, and a CLI (metrics/outline/quality/report). Use when analyzing manuscripts for readability, building editorial dashboards, validating heading structure, extracting citation keys from prose, or wiring prose-quality gates into the pipeline.