add-chat-template
Skill by InternLM
Adds or audits an XTuner chat-template implementation and its loss mask for a Hugging Face or local model. Built for developers supporting new models in XTuner's message and tokenizer code.
Install add-chat-template
Built from the published package, never by AI.
git clone --depth 1 https://github.com/InternLM/xtuner /tmp/xtuner && mkdir -p ~/.claude/skills && cp -r /tmp/xtuner/.claude/skills/add-chat-template ~/.claude/skills/add-chat-templateRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/InternLM/xtuner /tmp/xtuner && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/xtuner/.claude/skills/add-chat-template ~/.gemini/antigravity-cli/skills/add-chat-templateAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
The add-chat-template skill guides work on XTuner chat-template implementations and their loss masks. It treats the official Hugging Face tokenizer or processor as the rendering oracle. The assistant is told to inventory the model's artifacts, run a bundled audit script, and write a stop contract before implementing. The workflow covers rendering parity, loss on assistant output and stop tokens, regression tests, and checks against vLLM and SGLang.
It is aimed at developers who add a new model under xtuner/v1/data_proto/messages or check an existing implementation against apply_chat_template. The skill says not to infer a template or stop contract from another model in the same family. It also says to pin the reference revision of the model repository in tests or CI.
Written from the project's SKILL.md and checked against it.
What it can do
- Reference inventoryRecords the official repo or local directory, revision, tokenizer class, and template kwargs before coding.
- Chat template auditRuns a bundled script that inventories a model's tokenizer-side chat template.
- Stop contract tableLists configured stops, template boundaries, and engine stops for each transition.
- Loss mask designSets which assistant output, reasoning, tool calls, and stop tokens receive loss.
- Integration guidanceShows which XTuner seams to update when registering a new chat template.
- Regression test matrixLists test cases for turns, tools, reasoning, system input, and Unicode alignment.
- Engine validationCompares vLLM and SGLang rendering and stop behavior with the official renderer.
What you need
- Access to the official Hugging Face model repository or a local model directory
- Python to run the bundled audit script
- The XTuner repository with its tests and message code
- Transformers and the tokenizer or processor for the target model
- vLLM and SGLang at the target versions for engine validation
Try asking
- Add a chat template for this new Hugging Face model in XTuner with the right loss mask.
- Audit our existing XTuner chat template against the official apply_chat_template output.
- Write a stop contract table for this model's assistant, user, and tool transitions.
Good to know
- Does not infer a template or stop contract from another model in the same family.
- Validation against vLLM and SGLang depends on installing those engines at the target versions.
- Focused on XTuner's message and tokenizer code rather than general chat template work.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: .claude/skills/add-chat-template/SKILL.md, .claude/skills/add-chat-template/scripts/audit_hf_chat_template.py. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md13 KB -
agents/openai.yaml272 B -
scripts/audit_hf_chat_template.py8 KB
Alternatives to add-chat-template
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
add-chat-template: common questions
What does the add-chat-template skill do?
It helps add or audit an XTuner chat-template implementation and its loss mask. It uses the official Hugging Face tokenizer or processor as the reference for rendering.
How does it decide which tokens get loss?
It inventories configured generation stops, template boundaries, and engine stops before writing the mask. Assistant output receives loss by default, while user, tool, system, and generation prompt content stays masked.
Who is this skill for?
It is for developers supporting a new model in XTuner or checking an existing implementation. The source describes it for work under xtuner/v1/data_proto/messages and related tests.
How do I install add-chat-template?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is add-chat-template free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is add-chat-template safe to use?
It scores 85 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to add-chat-template?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
