Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
General / UtilitybeginnerNew

String Utils

Share

Create string manipulation utilities

Works with OpenClaude

You 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

  1. Create a dedicated module file stringUtils.js or stringUtils.ts for all string functions
  2. Implement capitalize() using bracket notation [0].toUpperCase() combined with slice(1)
  3. Add camelCase() by splitting on spaces/hyphens, mapping toUpperCase() on each word except the first
  4. Implement truncate(text, length) with substring() and conditional ellipsis (...)
  5. Create reverseString() using split(''), reverse(), and join('') chain
  6. Add removeWhitespace() using regex /\s+/g with replace()
  7. Implement slugify() by lowercasing, replacing spaces with hyphens, and removing special characters
  8. Export all functions as named exports or as properties of a single object
  9. 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

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
generalstringutilities

Install command:

curl -o ~/.claude/skills/string-utils.md https://claude-skills-hub.vercel.app/skills/general/string-utils.md

Related General / Utility Skills

Other Claude Code skills in the same category — free to download.

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.