From hephaestus
Port and generalize utility scripts from one project into ProjectHephaestus for cross-project reuse
How this skill is triggered — by the user, by Claude, or both
Slash command
/hephaestus:create-reusable-utilitiesThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
| Aspect | Details |
| Aspect | Details |
|---|---|
| Date | 2026-02-13 |
| Objective | Port 5 utility scripts from ProjectOdyssey to ProjectHephaestus, generalizing them for cross-project use |
| Outcome | Successfully ported all utilities with 93% test coverage (53/57 tests passing) |
| Category | Architecture |
Use this skill when you need to:
For each utility:
# Original: ProjectOdyssey/scripts/utility.py (functional)
def fix_thing(content: str) -> str:
hardcoded_pattern = r"/home/user/project-manual/"
return re.sub(hardcoded_pattern, "", content)
# Ported: hephaestus/<category>/utility.py (class-based)
class ThingFixer:
"""Fixes things in a configurable way."""
def __init__(self, options: Optional[FixerOptions] = None):
self.options = options or FixerOptions()
self.pattern = self.options.pattern or r"/home/[^/]+/[^/]+"
def fix_thing(self, content: str) -> Tuple[str, int]:
"""Fix things and return (fixed_content, fix_count)."""
new_content, count = re.subn(self.pattern, "", content)
return new_content, count
Key Changes:
hephaestus/
├── <category>/
│ ├── __init__.py # Export classes
│ ├── utility.py # Implementation
│ └── options.py # Configuration dataclasses (optional)
Update __init__.py:
from hephaestus.<category>.utility import UtilityClass, Options
__all__ = ["UtilityClass", "Options"]
#!/usr/bin/env python3
"""CLI wrapper for UtilityClass."""
import argparse
import sys
from pathlib import Path
from hephaestus.<category>.utility import UtilityClass, Options
def main() -> int:
parser = argparse.ArgumentParser(description="...")
parser.add_argument("input", type=Path, help="Input file")
parser.add_argument("--dry-run", action="store_true")
parser.add_argument("-v", "--verbose", action="store_true")
args = parser.parse_args()
options = Options(dry_run=args.dry_run, verbose=args.verbose)
utility = UtilityClass(options)
result = utility.process(args.input)
return 0 if result else 1
if __name__ == "__main__":
sys.exit(main())
Make executable:
chmod +x scripts/<utility_name>.py
Create tests/test_<category>_<utility>.py:
import pytest
from hephaestus.<category>.utility import UtilityClass
def test_basic_functionality():
"""Test basic use case."""
utility = UtilityClass()
result = utility.process("input")
assert result == "expected"
def test_edge_cases():
"""Test boundary conditions."""
utility = UtilityClass()
assert utility.process("") == ""
assert utility.process(None) raises ValueError
def test_configuration():
"""Test custom configuration."""
options = Options(custom_param="value")
utility = UtilityClass(options)
result = utility.process("input")
assert "value" in result
def test_integration(tmp_path):
"""Test full workflow with files."""
test_file = tmp_path / "test.txt"
test_file.write_text("content")
utility = UtilityClass()
utility.process_file(test_file)
assert test_file.read_text() == "processed"
Run verification checklist:
# 1. Test imports
python3 -c "from hephaestus.<category>.utility import UtilityClass; print('OK')"
# 2. Run tests
python -m pytest tests/test_<category>_<utility>.py -v
# 3. Test CLI wrapper
PYTHONPATH=. python3 scripts/<utility_name>.py --help
# 4. Check syntax
python3 -m py_compile hephaestus/**/*.py
# 5. Run all tests
python -m pytest tests/ -v
Problem: Used Read tool which showed escaped backslashes (\\n), then tried to use Edit tool with those escaped values.
What Happened:
return "\\n".join(fixed_lines), fixesold_string="\\n" thinking that's the actual content\n not \\nSolution:
old_string="\n"Problem: Created pattern \]({pattern}/([^)]+)\) intending to capture path after system prefix.
What Happened:
pattern = rf"\]({self.system_path_pattern}/([^)]+)\)" # Two groups!
replacement = r"](\1)" # Referenced wrong group
The self.system_path_pattern itself contains [^/]+ character classes which aren't capturing groups, but the outer () creates group 1, and the inner ([^)]+) creates group 2.
Solution:
# Use non-capturing group for pattern, capture only the path
pattern = rf"\]\({self.system_path_pattern}/([^)]+)\)"
replacement = r"](\1)" # Now \1 is the path after system prefix
Problem: Used Python heredoc to insert regex pattern with \b word boundary.
What Happened:
pattern = r"https?://...\. \b..."
Python interpreted \b as backspace character (0x08) in the string literal, breaking the regex.
Solution:
pattern = r"https?://...\b..."pattern = "https?://...\\b..."repr(pattern) to see actual bytesProblem: File had double-escaped strings, attempted to fix by running git checkout to restore, which lost the bare URL fix I had just added.
What Happened:
_fix_md034_bare_urls() method to filegit checkout to restore clean versionSolution:
Don't use git checkout on files with uncommitted work
Instead: Read original from git, apply changes programmatically
git show HEAD:file.py > /tmp/clean.py
# Apply changes to /tmp/clean.py
mv /tmp/clean.py file.py
Or: Stash work, checkout, reapply stash
git stash
git checkout file.py
git stash pop
]\( in Markdown Link PatternProblem: Pattern \]({path}) didn't match markdown links [text](url).
What Happened:
[text](url)](url) not just (url)\]({path}) was missing the opening parenthesisSolution:
# Wrong: Matches ] followed by (path)
pattern = r"\]({path})"
# Right: Matches ]( followed by path
pattern = r"\]\({path}\)"
Colors (hephaestus/cli/colors.py)
LinkFixer (hephaestus/markdown/link_fixer.py)
/home/user/repo/file.md → file.md/agents/index.md → ../agents/index.md (depth-aware)LinkFixerOptions(system_path_pattern=r"/custom/path")MarkdownFixer (enhanced)
_fix_md034_bare_urls() for MD034 compliancehttps://example.com → <https://example.com>ReadmeValidator (hephaestus/validation/readme_commands.py)
ReadmeValidator(allowed_prefixes=["custom", "commands"])VersionManager (hephaestus/version/manager.py)
parse_version("1.2.3") → (1, 2, 3)Benchmark Compare (hephaestus/benchmarks/compare.py)
mojo_version → runtime_versionAll wrappers follow standard pattern:
PYTHONPATH=. python3 scripts/<name>.py --help
PYTHONPATH=. python3 scripts/<name>.py input.file [--dry-run] [-v]
Created wrappers:
scripts/fix_invalid_links.pyscripts/validate_readme_commands.pyscripts/update_version.pyscripts/compare_benchmarks.py(result, count)repr() to see actual bytes, watch for \b vs backspacegit checkout files with uncommitted changes~/ProjectOdyssey/scripts/hephaestus/<category>/tests/test_*.pynpx claudepluginhub homericintelligence/projecthephaestus --plugin hephaestusGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.