How to Register a Custom LaTeX CV Template with the /add-template Command

To register a custom LaTeX CV template, run the /add-template command with your template path, answer the interactive prompts for metadata and compilation settings, and let the system validate the build before activating it in your AI Job Search workflow.

The MadsLorentzen/ai-job-search repository ships with a default moderncv template, but power users can register a custom LaTeX CV template to match specific branding or layout requirements. This workflow is handled entirely by the /add-template command defined in .claude/commands/add-template.md, which manages directory creation, dependency validation, and template activation without manual file manipulation.

Understanding the /add-template Command Architecture

The registration logic lives in .claude/commands/add-template.md, which defines an interactive seven-phase workflow for ingesting LaTeX source files. According to the command specification, the system distinguishes between CV and cover-letter templates, detects compilation engines automatically, and enforces a mandatory compile test before activation. All template data is stored under the templates/ directory with strict folder conventions for portability.

Step-by-Step Registration Workflow

When you invoke /add-template with a file path or directory, the command executes the following phases:

Argument Parsing and Template Detection

The command first evaluates flags: --list displays registered templates, --use <name> switches active templates, and a bare path initiates new registration. The assistant queries whether the source is a CV or cover letter and reads all referenced .tex, .cls, and .sty files into memory for processing.

Metadata Collection and Configuration

Between lines 50-60 of the specification, the system extracts or confirms:

  • Name: A kebab-case identifier (e.g., awesome-cv)
  • Compile engine: lualatex, xelatex, or pdflatex (auto-detected via \fontspec presence)
  • Fonts: Bundled versus system-installed typefaces
  • Style rules: Color schemes, section ordering, and date formatting
  • Page limits: Default 2 pages for CVs, 1 for cover letters
  • Known pitfalls: Special macros requiring escape handling

File Layout Creation Under templates/

The command creates a structured folder hierarchy:

  • templates/cv/<name>/ for CVs
  • templates/cover_letters/<name>/ for cover letters

Each folder receives:

  • template.tex: Skeleton with [PLACEHOLDER] tokens for personal data
  • Class and style files (.cls, .sty)
  • fonts/ subdirectory for bundled typefaces
  • TEMPLATE.md: Manifest following the markdown format specified in lines 78-100

Mandatory Compilation Testing

Before registration completes, the system generates _compile_test.tex (lines 104-115), populates all [PLACEHOLDER] tokens with realistic dummy data, and executes the declared engine. If compilation fails, the assistant reports errors, proposes fixes, and retries until the PDF generates successfully.

Activation and Template Switching

Upon successful compilation, the command injects a managed block into 05-cv-templates.md (for CVs) or 06-cover-letter-templates.md (for cover letters). These blocks (defined in lines 27-40) tell the /apply workflow which skeleton, manifest, and engine to use. Only one managed block may exist per file; switching templates replaces the existing block. Activation is confirmed via the summary output described in lines 50-64.

Command Reference and Usage Examples

Register templates using these patterns:


# List all registered templates

/add-template --list

# Register a new CV template from a local directory

/add-template /path/to/my-cv-template/

# Switch to an existing custom template

/add-template --use awesome-cv

# Revert to the stock moderncv template

/add-template --use default

During interactive registration, expect prompts like:

  • "Is this a CV or a cover letter template?"
  • "What is the template name (kebab-case)?"
  • "Which LaTeX engine should be used? (lualatex / xelatex / pdflatex)"

Key Source Files and Documentation

The complete implementation spans these repository locations:

Summary

  • The /add-template command in MadsLorentzen/ai-job-search manages the complete lifecycle of custom LaTeX CV templates.
  • Registration requires passing a path, selecting CV versus cover-letter type, and confirming metadata including engine and fonts.
  • The system creates a dedicated folder under templates/cv/<name>/ containing template.tex, dependencies, and a TEMPLATE.md manifest.
  • A mandatory compile test using _compile_test.tex must pass before activation (lines 104-115).
  • Active templates are managed via injected blocks in 05-cv-templates.md or 06-cover-letter-templates.md.
  • Use --use <name> to switch templates and --use default to restore the built-in moderncv style.

Frequently Asked Questions

Can I register a template that uses system fonts instead of bundled fonts?

Yes. During the metadata interview phase (lines 50-60), the system distinguishes between bundled fonts placed in the fonts/ subdirectory and system-installed typefaces. Simply indicate which fonts are system dependencies, and the compile test will verify their availability without copying them into the template folder.

What happens if my LaTeX template fails the mandatory compile test?

If the _compile_test.tex build fails, the assistant reports the specific error, suggests corrective actions (such as missing package installations or placeholder syntax fixes), and retries the compilation. Registration cannot complete until this test passes, ensuring only working templates enter the workflow.

How do I switch between multiple custom CV templates without re-registering them?

Use the /add-template --use <name> flag, where <name> is the kebab-case identifier you assigned during registration. This updates the managed block in 05-cv-templates.md (lines 27-40) to point to the selected template's manifest and compilation settings, replacing the previous entry without deleting the underlying template files.

Does the command support cover letter templates as well as CVs?

Yes. The registration workflow handles both document types. When prompted, indicate whether the source is a cover letter; the system then creates the folder under templates/cover_letters/<name>/ and manages activation in 06-cover-letter-templates.md instead of the CV guidance file.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →