knitwork-x

v2026.09.25

Utilities to generate JavaScript and TypeScript code programmatically. Use when building code generators, AST-to-code output, or dynamic source generation.

GitHub
Install command
npx skhub add hairyf/knitwork-x
Markdown
SKILL.md

knitwork-x provides programmatic code generation for JavaScript and TypeScript. It is forked from knitwork and adds comprehensive TypeScript helpers: ESM (import/export), strings, variables, classes, interfaces, functions, types, control flow (if/try/loop/switch), and serialization (object/array/map/set). All gen* functions return strings suitable for splicing into source; they are pure and do not mutate inputs.

Use this skill when an agent needs to generate code strings (e.g. for codegen tools, plugins, or dynamic module output).

Core References

TopicDescriptionReference
OverviewPurpose, install, when to usecore-overview
ESMImport, export, default export, dynamic importcore-esm
StringgenString, escapeString, genTemplateLiteralcore-string
VariablegenVariable, genVariableNamecore-variable
Design GuidelinesNaming, params, options (for contributors)core-design-guidelines

Features

TopicDescriptionReference
ClassgenClass, genConstructor, genProperty, genMethod, getter/setterfeatures-class
InterfacegenInterface, genIndexSignaturefeatures-interface
EnumgenEnum, genConstEnumfeatures-enum
FunctiongenFunction, genArrowFunction, genBlock, genParamfeatures-function
TypegenTypeAlias, genUnion, genIntersection, genMappedType, etc.features-type
ConditionalgenConditionalType, genTernaryfeatures-conditional
DecoratorgenDecoratorfeatures-decorator
Module & NamespacegenModule, genNamespace, genDeclareNamespacefeatures-module-namespace
ConditiongenIf, genElse, genElseIffeatures-condition
TrygenTry, genCatch, genFinallyfeatures-try
LoopgenFor, genForOf, genWhile, genDoWhilefeatures-loop
SwitchgenSwitch, genCase, genDefaultfeatures-switch
StatementgenReturn, genThrow, genPrefixedBlockfeatures-statement
Object & SerializationgenObject, genArray, genMap, genSet, genTypeObjectfeatures-object
UtilsgenComment, genKey, genLiteral, genRegExp, wrapInDelimitersfeatures-utils

Key Points

  • Return type: Every gen* function returns a string (code fragment).
  • Options: Most accept an optional options object (e.g. export, singleQuotes, indent); default to {}.
  • Indent: When supported, pass indent as the last parameter; use indent + " " for nested blocks.
  • Strings: Use genString(input, options) for quoted/escaped output so singleQuotes is respected.
  • Composing: Combine gen* outputs (e.g. genClass(..., [genConstructor(...)])) to build larger snippets.
Discovery
Tags

No tags published for this skill.

Version
Latest version metadata

Version

v2026.09.25

Published

Sep 25, 2026

Category

Uncategorized

License

MIT

Source path

skills/knitwork-x

Default branch

main

Latest commit

5866b9f

Tree SHA

e66fbae