text-truncator

Truncates text to a length limit while preserving sentence boundaries.

410|79|Updated Jan 10, 2026
One-click install
npx skills add https://github.com/VanGong1999/screen-creative-skills --skill text-truncator-vangong1999
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: text-truncator
Source: https://github.com/VanGong1999/screen-creative-skills/tree/main/category/tools/text-truncator
Command: npx skills add https://github.com/VanGong1999/screen-creative-skills --skill text-truncator-vangong1999

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve? Long texts often exceed input length limits for AI models, previews, or summaries, and naive cutting breaks sentences mid-word. This Skill truncates text to a specified maximum length while keeping semantic and sentence integrity intact. ## Core Features & Use Cases - Sentence-Aware Truncation: Cuts at natural boundaries like periods, question marks, and exclamation points instead of mid-sentence. - Strict Length Control: Guarantees output never exceeds the specified character limit, with optional truncation markers like "...". - Batch and File Support: Truncates text read from files or processes lists of texts in one pass via the Python script. - Use Case: When feeding a 50,000-character novel chapter into an AI with a 10,000-character limit, truncate it at the nearest sentence ending and receive a structured report of original length, truncated length, and cut position. ## Quick Start Truncate the provided text to a maximum of 5000 characters, cutting at the nearest sentence boundary and appending an ellipsis marker.

Frequently Asked Questions about text-truncator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I truncate text without cutting sentences in half?▼

Use sentence-boundary-aware truncation that searches for the last sentence-ending punctuation within the length limit. This tool checks Chinese markers like 。!?;and cuts at the nearest one found after 80% of the target length.

How to truncate Chinese text to a character limit in Python?▼

Call the truncate_text function with your text and max_length parameter. It slices the string at the limit, then adjusts the cut point to the nearest Chinese sentence-ending punctuation to preserve semantic completeness.

Can I truncate text read directly from a file?▼

Yes, the truncate_text_from_file method reads a file with a specified encoding (default UTF-8) and truncates its content. It returns error codes for missing files or decoding failures.

Does the truncator support batch processing of multiple texts?▼

Yes, the batch_truncate_text method accepts a list of strings and a shared max_length, returning a list of result dictionaries with status codes, truncated content, and processing messages for each input.

What happens if no sentence boundary exists near the length limit?▼

If no sentence-ending punctuation appears after 80% of the maximum length, the tool falls back to a hard cut at the exact character limit. This guarantees the output never exceeds the specified length.