scitex_template

Template management for SciTeX projects.

Functions

create_child_git(*_a, **_k)

find_parent_git(*_a, **_k)

get_available_templates_info()

Get information about all available SciTeX project templates.

get_template_tree(template_id)

Create template in a tempdir and return its tree output.

init_git_repo(*_a, **_k)

remove_child_git(*_a, **_k)

scitex_template.build_directory_tree(project_dir, structure=None)[source]

Create the standard project directory tree.

Parameters:
  • project_dir (str) – Project root directory (must already exist).

  • structure (dict, optional) – Directory tree specification. Defaults to PROJECT_STRUCTURE.

Raises:

RuntimeError – If a directory cannot be created.

Return type:

None

scitex_template.clone_module(project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Create a module project template.

Tries to clone from the GitHub template repo first. Falls back to inline scaffold if clone fails.

Parameters:
  • project_dir (str) – Path to project directory (will be created).

  • git_strategy (str, optional) – Git initialization strategy.

  • branch (str, optional) – Specific branch of the template repository to clone.

  • tag (str, optional) – Specific tag/release of the template repository to clone.

  • **kwargs – Additional keyword arguments forwarded to clone_project.

Returns:

True if successful, False otherwise.

Return type:

bool

scitex_template.clone_pip_project(project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Create a new pip project from the template repository.

Parameters:
  • project_dir (str) – Path to project directory (will be created). Can be a simple name like “my_project” or a full path like “./projects/my_project”

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, None). Default is ‘child’.

  • branch (str, optional) – Specific branch of the template repository to clone. If None, clones the default branch. Mutually exclusive with tag parameter.

  • tag (str, optional) – Specific tag/release of the template repository to clone. If None, clones the default branch. Mutually exclusive with branch parameter.

Returns:

True if successful, False otherwise

Return type:

bool

Example

>>> from scitex.template import clone_pip_project
>>> clone_pip_project("my_pip_project")
>>> clone_pip_project("./projects/my_project")
>>> clone_pip_project("my_project", branch="develop")
>>> clone_pip_project("my_project", tag="v1.0.0")
scitex_template.clone_research(project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Create a new research project from the template repository.

Parameters:
  • project_dir (str) – Path to project directory (will be created). Can be a simple name like “my_project” or a full path like “./projects/my_project”

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, None). Default is ‘child’.

  • branch (str, optional) – Specific branch of the template repository to clone. If None, clones the default branch. Mutually exclusive with tag parameter.

  • tag (str, optional) – Specific tag/release of the template repository to clone. If None, clones the default branch. Mutually exclusive with branch parameter.

Returns:

True if successful, False otherwise

Return type:

bool

Example

>>> from scitex.template import clone_research
>>> clone_research("my_research_project")
>>> clone_research("./projects/my_project")
>>> clone_research("my_project", branch="develop")
>>> clone_research("my_project", tag="v1.0.0")
scitex_template.clone_research_minimal(project_dir, git_strategy='child', branch=None, tag=None, include_dirs=None)[source]

Create a new minimal research project from scitex-writer (single source of truth).

Clones scitex-writer and keeps only essential directories for manuscript writing.

Parameters:
  • project_dir (str) – Path to project directory (will be created). Can be a simple name like “my_project” or a full path like “./projects/my_project”

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, None). Default is ‘child’.

  • branch (str, optional) – Specific branch of the template repository to clone.

  • tag (str, optional) – Specific tag/release of the template repository to clone.

  • include_dirs (list of str, optional) – Top-level items to keep. Defaults to MINIMAL_INCLUDE_DIRS.

Returns:

True if successful, False otherwise

Return type:

bool

Example

>>> from scitex.template import clone_research_minimal
>>> clone_research_minimal("my_research_project")
>>> clone_research_minimal("./projects/my_project")
scitex_template.clone_scitex_minimal(project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Create a minimal scitex project with writer and scholar workspaces.

Parameters:
  • project_dir (str) – Path to project directory (will be created).

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, ‘origin’, None).

  • branch (str, optional) – Specific branch of the writer template to clone.

  • tag (str, optional) – Specific tag/release of the writer template to clone.

  • **kwargs – Additional keyword arguments forwarded to writer ensure.

Returns:

True if successful, False otherwise.

Return type:

bool

scitex_template.clone_singularity(project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Create a new singularity project from the template repository.

Parameters:
  • project_dir (str) – Path to project directory (will be created). Can be a simple name like “my_project” or a full path like “./projects/my_project”

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, None). Default is ‘child’.

  • branch (str, optional) – Specific branch of the template repository to clone. If None, clones the default branch. Mutually exclusive with tag parameter.

  • tag (str, optional) – Specific tag/release of the template repository to clone. If None, clones the default branch. Mutually exclusive with branch parameter.

Returns:

True if successful, False otherwise

Return type:

bool

Example

>>> from scitex.template import clone_singularity
>>> clone_singularity("my_singularity_project")
>>> clone_singularity("./projects/my_project")
>>> clone_singularity("my_project", branch="develop")
>>> clone_singularity("my_project", tag="v1.0.0")
scitex_template.clone_template(template_id, project_dir, git_strategy='child', branch=None, tag=None, **kwargs)[source]

Clone a project template by ID.

Unified dispatcher that resolves template IDs (including aliases) and delegates to the appropriate clone function.

Parameters:
  • template_id (str) – Template identifier. Canonical IDs: research, research_minimal, scitex_minimal, pip_project, singularity, paper_directory, module, scitex_app. Aliases: minimal (->scitex_minimal), pip-project, paper, stx-module, app (->scitex_app).

  • project_dir (str) – Path to project directory (will be created).

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, ‘origin’, None).

  • branch (str, optional) – Specific branch to clone.

  • tag (str, optional) – Specific tag to clone.

  • **kwargs (Any) – Additional keyword arguments forwarded to the clone function (e.g. include_dirs for research_minimal).

Returns:

True if successful, False otherwise.

Return type:

bool

Raises:

ValueError – If template_id is unknown.

scitex_template.clone_writer_directory(project_dir, git_strategy='child', branch='main', tag=None, **kwargs)[source]

Create a new paper directory from the scitex-writer template repository.

Parameters:
  • project_dir (str) – Path to project directory (will be created). Can be a simple name like “my_paper” or a full path like “./papers/my_paper”

  • git_strategy (str, optional) – Git initialization strategy (‘child’, ‘parent’, None). Default is ‘child’.

  • branch (str, optional) – Specific branch of the template repository to clone. Default is ‘main’. Mutually exclusive with tag parameter.

  • tag (str, optional) – Specific tag/release of the template repository to clone. If None, uses the branch. Mutually exclusive with branch parameter.

Returns:

True if successful, False otherwise

Return type:

bool

Example

>>> from scitex.template import clone_writer_directory
>>> clone_writer_directory("my_paper")  # Uses main branch
>>> clone_writer_directory("./papers/my_paper")
>>> clone_writer_directory("my_paper", branch="develop")
>>> clone_writer_directory("my_paper", tag="v2.0.0")
scitex_template.create_child_git(*_a, **_k)
scitex_template.create_env_template(project_dir, metadata)[source]

Create config/.env.template with project-specific placeholders.

Parameters:
  • project_dir (str) – Project root directory.

  • metadata (dict) – Keys: name, id.

Returns:

Path to the generated .env.template.

Return type:

Path

scitex_template.create_minimal_readme(project_dir, metadata)[source]

Create a minimal README for empty projects.

Parameters:
  • project_dir (str) – Project root directory.

  • metadata (dict) – Keys: name, created_at, owner_full_name or owner, description.

Returns:

Path to the generated README.md.

Return type:

Path

scitex_template.create_paths_config(project_dir)[source]

Create config/paths.json with resolved directory paths.

Parameters:

project_dir (str) – Project root directory.

Returns:

Path to the generated paths.json.

Return type:

Path

scitex_template.create_project_config(project_dir, metadata)[source]

Create project.yaml (or .json fallback) in config/.

Parameters:
  • project_dir (str) – Project root directory.

  • metadata (dict) – Keys: name, id, description, created_at, owner, progress, hypotheses.

Returns:

Path to the generated config file.

Return type:

Path

scitex_template.create_project_readme(project_dir, metadata)[source]

Create a comprehensive README for templated projects.

Parameters:
  • project_dir (str) – Project root directory.

  • metadata (dict) – Keys: name, created_at, updated_at, owner_full_name or owner, description, hypotheses, progress, id.

Returns:

Path to the generated README.md.

Return type:

Path

scitex_template.create_requirements_file(project_dir)[source]

Create requirements.txt with standard scientific packages.

Parameters:

project_dir (str) – Project root directory.

Returns:

Path to the generated requirements.txt.

Return type:

Path

scitex_template.customize_minimal_template(project_dir, metadata)[source]

Customise a minimal (scitex-writer) template with project metadata.

Writes title.tex and authors.tex under 00_shared/ (direct clone) or scitex/writer/00_shared/ (nested layout).

Parameters:
  • project_dir (str) – Path to the project directory.

  • metadata (dict) – Project metadata.

Return type:

None

scitex_template.customize_template(project_dir, metadata, template_type='research')[source]

Customise a cloned template with project-specific information.

Replaces placeholder text in README.md, title.tex, and authors.tex.

Parameters:
  • project_dir (str) – Path to the project directory.

  • metadata (dict) – Project metadata. Expected keys: name, description, owner (username), owner_full_name.

  • template_type (str) – Template type hint (currently unused, reserved for future).

Return type:

None

scitex_template.ensure_integration(project_path)[source]

Convenience function to ensure integration exists.

Parameters:

project_path (Path) – Root path of the project

Returns:

True if integration is set up (or already exists)

Return type:

bool

scitex_template.find_parent_git(*_a, **_k)
scitex_template.get_all_templates()[source]

Get all templates combined into one string.

Returns:

All templates with headers, ordered by priority: 1. session - Main workflow template 2. io - File I/O patterns 3. Others (config, module, etc.)

Return type:

str

scitex_template.get_available_templates_info()[source]

Get information about all available SciTeX project templates.

Returns:

List of template information dictionaries, each containing: - id: Template identifier (used in code) - name: Human-readable template name - description: Template description - github_url: GitHub repository URL - use_case: When to use this template - tree: Tree-command-style directory listing

Return type:

list[dict]

Example

>>> from scitex.template import get_available_templates_info
>>> templates = get_available_templates_info()
>>> for template in templates:
...     print(f"{template['name']}: {template['description']}")
scitex_template.get_code_template(template_id, filepath=None, docstring=None)[source]

Get a code template by ID.

Parameters:
  • template_id (str) – Template identifier (session, session-minimal, session-plot, etc.)

  • filepath (str, optional) – File path to include in template header.

  • docstring (str, optional) – Custom docstring for the template.

Returns:

Formatted template content.

Return type:

str

scitex_template.init_git_repo(*_a, **_k)
scitex_template.list_code_templates()[source]

List all available code templates.

Returns:

List of template info dictionaries.

Return type:

list[dict]

scitex_template.remove_child_git(*_a, **_k)
scitex_template.setup_scholar_writer_integration(project_path, force=False)[source]

Set up scholar-writer integration structure with symlinks.

Handles two project layouts:

  1. Standalone writer (flat): 00_shared/ at project root Creates: scholar/bib_files/ Symlink: 00_shared/bib_files/merged_scholar.bib

  2. Nested writer (scitex ecosystem): scitex/writer/00_shared/ Creates: scitex/scholar/bib_files/ Symlink: scitex/writer/00_shared/bib_files/merged_scholar.bib

Parameters:
  • project_path (Path) – Root path of the project

  • force (bool) – If True, recreate symlinks even if they exist

Returns:

Result with keys: success, layout, scholar_dir, symlink_created, errors

Return type:

dict

Modules

cli

CLI for scitex-template.

mcp_server

MCP Server for SciTeX Template - Project Scaffolding Framework.

registry

Registry of templates vendored in this repo.