# Scaffold patterns A **scaffold pattern** is a pack contribution that says "when you see a file matching this path/shape, suggest this template id with these variables." Inference uses patterns to seed `infer templates` / `onboard --scaffold-templates --ast` with high-confidence candidates without re-implementing matching locally. Patterns are **data**. The inspector layer interprets them — they cannot run shell, evaluate code, or touch the network. ## Contributing patterns from a pack Add a `scaffoldPatternFiles[]` entry to your pack manifest: ```ts import { definePackManifest } from '@shrkcrft/plugin-api'; export default definePackManifest({ schema: 'sharkcraft.pack/v1', info: { name: '@your-org/pack', version: '0.1.0' }, contributions: { scaffoldPatternFiles: ['./src/assets/scaffold-patterns.ts'], // … }, }); ``` Then default-export an array of patterns from that file: ```ts import { defineScaffoldPatterns } from '@shrkcrft/plugin-api'; export default defineScaffoldPatterns([ { id: 'app.service-contract-pattern', title: 'Service contract scaffold', description: 'Detects service contracts and maps them to app.service-contract.', matchPaths: ['packages/app/src/contracts/**/*.ts'], templateId: 'app.service-contract', variables: [ { name: 'name', from: 'filename.kebab' }, { name: 'pascal', from: 'className.stripPrefix:I' }, ], appliesWhen: ['onboard', 'infer-template', 'create-service'], confidence: 'high', tags: ['app', 'service'], }, ]); ``` ## Variable extraction strategies | Strategy | Source | |--------------------------------|------------------------------------------------------------------| | `filename.kebab` | basename in kebab-case (`user-profile`) | | `filename.pascal` | basename in PascalCase (`UserProfile`) | | `className` | PascalCase of basename (alias for `filename.pascal`) | | `className.stripPrefix:
` | PascalCase basename with `
` stripped (e.g. `I` from `IUserService`)|
| `functionName` | camelCase of basename |
| `directoryName` | name of the file's parent directory |
| `nearestPackageName` | nearest `package.json` `name` field |
## CLI
```bash
shrk scaffolds list # every pattern with id, template, source
shrk scaffolds get