Create string manipulation utilities
✓Works with OpenClaudeYou are a JavaScript/TypeScript utility developer. The user wants to create reusable string manipulation functions that handle common text processing tasks.
What to check first
- Verify you're using ES6+ syntax (const, arrow functions, template literals)
- Check if you need Unicode support for non-ASCII characters with methods like
normalize()
Steps
- Create a dedicated module file
stringUtils.jsorstringUtils.tsfor all string functions - Implement
capitalize()using bracket notation[0].toUpperCase()combined withslice(1) - Add
camelCase()by splitting on spaces/hyphens, mappingtoUpperCase()on each word except the first - Implement
truncate(text, length)withsubstring()and conditional ellipsis (...) - Create
reverseString()usingsplit(''),reverse(), andjoin('')chain - Add
removeWhitespace()using regex/\s+/gwithreplace() - Implement
slugify()by lowercasing, replacing spaces with hyphens, and removing special characters - Export all functions as named exports or as properties of a single object
- Test each function with edge cases: empty strings, single characters, null values
Code
// stringUtils.js
const capitalize = (str) => {
if (!str) return '';
return str.charAt(0).toUpperCase() + str.slice(1);
};
const camelCase = (str) => {
if (!str) return '';
return str
.split(/[\s\-_]+/)
.map((word, index) =>
index === 0 ? word.toLowerCase() : capitalize(word.toLowerCase())
)
.join('');
};
const truncate = (str, length = 50, suffix = '...') => {
if (!str) return '';
if (str.length <= length) return str;
return str.substring(0, length - suffix.length) + suffix;
};
const reverseString = (str) => {
if (!str) return '';
return str.split('').reverse().join('');
};
const removeWhitespace = (str) => {
if (!str) return '';
return str.replace(/\s+/g, '');
};
const slugify = (str) => {
if (!str) return '';
return str
.toLowerCase()
.trim()
.replace(/[^\w\s\-]/g, '')
.replace(/[\s\-]+/g, '-')
.replace(/^\-+|\-+$/g, '');
};
const toCamelCase = (str) => camelCase(str);
const toSnakeCase = (str) => {
if (!str) return '';
return str
.replace(/([a-z])([A-Z])/g, '$
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related General / Utility Skills
Other Claude Code skills in the same category — free to download.
Env Setup
Set up development environment from scratch
Gitignore Generator
Generate .gitignore for any project type
NPM Publish
Prepare and publish npm package
Error Boundary
Create error boundary components
Feature Flag
Implement feature flag system
Config Manager
Create application configuration manager
Date Time Helper
Create date/time utility functions
File Utils
Create file system utility functions
Want a General / Utility skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.