This guide helps Claude (and similar AI assistants) work effectively on the vscode-terramate project.
Note: Read agents.md first for comprehensive project documentation. This file contains Claude-specific tips and workflow guidance.
Project: VSCode extension for Terramate (Infrastructure-as-Code orchestration tool)
Language: TypeScript
Key Components: Syntax highlighting + LSP client for terramate-ls
Package Manager: pnpm (preferred) or npm
Test Framework: Mocha with VS Code test harness
Approach:
- Edit
syntaxes/terramate.tmLanguage.jsonto add TextMate grammar pattern - Add test fixture in
testFixture/with example usage - Add test case in appropriate
*.test.tsfile - Run
pnpm testto verify - Test manually with F5 (Extension Development Host)
Example locations:
- Block definitions:
"patterns"→"repository"→"blocks" - Keywords:
"repository"→"keywords" - String patterns:
"repository"→"strings"
Approach:
- Review
src/extension.ts(all LSP logic is here) - Check server options (
serverOptions) and client options (clientOptions) - Enable trace:
"terramate.languageServer.trace.server": "verbose" - Test with Extension Development Host
- Check Output panel: View → Output → "Terramate"
Approach:
- Create/update fixture in
testFixture/(organize by feature) - Add test using pattern from existing tests
- Use helpers from
src/test/helper.ts:activate(),sleep(),testDiagnostics() - Run specific suite:
pnpm test:syntax,pnpm test:core, orpnpm test:pro - Run all:
pnpm test
Files to update:
- User-facing features →
README.md - Release process → Already documented in
README.md - Contributing guidelines →
CONTRIBUTING.md - AI assistant info →
agents.mdor this file
- ✅ Use tabs for indentation (project standard)
- ✅ Validate JSON after changes
- ✅ Test with
pnpm installif dependencies changed - ✅ Check
publisher,version,nameremain consistent
- ✅ Validate JSON (no trailing commas!)
- ✅ Test regex patterns carefully (TextMate/Oniguruma flavor)
- ✅ Reload VS Code window to see changes
- ✅ Add both positive and negative test cases
- ✅ Maintain TypeScript strict mode compliance
- ✅ Handle errors gracefully (extension shouldn't crash)
- ✅ Use
context.subscriptions.push()for disposables - ✅ Test both with and without
terramate-lsin PATH
- ✅ Use
async/awaitpattern consistently - ✅ Add
sleep()delays for LSP operations (LSP is async) - ✅ Clean up test fixtures if needed
- ✅ Name tests descriptively:
'should recognize X block syntax'
# Initial setup
pnpm install
pnpm compile
# Development loop
pnpm watch # Auto-recompile on changes
# Press F5 to launch Extension Development Host# Full test suite (slow first run, downloads VS Code)
pnpm test
# Quick iteration (reuses downloaded VS Code)
sh ./scripts/test-quick.sh
# Specific suites
pnpm test:syntax # Fast, no LSP required
pnpm test:core # Requires terramate-ls
pnpm test:pro # Requires Pro-enabled terramate-ls# Bump version (creates commit + tag)
npm run version:patch # or version:minor, version:major
# Push (triggers no automation yet)
git push && git push --tags
# Create GitHub release → triggers automated publishingpnpm lint| File | Purpose | Requires LSP? |
|---|---|---|
syntax.test.ts |
Basic language recognition | No |
lint.test.ts |
Error diagnostics | Yes |
languageserver.test.ts |
LSP startup & basic features | Yes |
lsp-positions.test.ts |
Go-to-definition, hover | Yes |
lsp-edge-cases.test.ts |
Complex LSP scenarios | Yes |
lsp-imports-workspace.test.ts |
Cross-file features | Yes |
bundle.test.ts |
Pro: bundle/component syntax | No |
generate.test.ts |
Generate block syntax | No |
Pattern:
suite('Feature Name', () => {
test('should do specific thing', async () => {
const docUri = getDocUri('subfolder/file.tm');
await activate(docUri);
await sleep(2000); // Wait for LSP
const doc = vscode.workspace.textDocuments.find(
d => d.uri.toString() === docUri.toString()
);
assert.ok(doc);
assert.strictEqual(doc.languageId, 'terramate');
});
});Best practices:
- Use descriptive test names
- One assertion per test (or closely related assertions)
- Add comments for non-obvious waits/delays
- Clean up test fixtures in
testFixture/subdirectories - Test both success and failure cases
- Check
package.json→activationEventsincludesonLanguage:terramate - Verify file extension in
contributes.languages.extensions - Check VS Code recognizes file (bottom-right status bar)
- Check
terramate-lsin PATH:which terramate-ls - Enable trace:
"terramate.languageServer.trace.server": "verbose" - Check Output panel: View → Output → "Terramate"
- Look for spawn errors in extension host console
- "terramate-ls not found" → Install or set
binPathin test - Timeout errors → Increase
sleep()duration (LSP may be slow) - Unexpected diagnostics → Check
terramate-lsversion compatibility - File not found → Verify path in
testFixture/
- After grammar changes → Reload VS Code window (Cmd/Ctrl+Shift+P → "Reload Window")
- Regex not matching → Test pattern in regex tester (use Oniguruma flavor)
- Scopes wrong → Use "Developer: Inspect Editor Tokens and Scopes"
feat: add X feature- New functionalityfix: resolve X issue- Bug fixeschore: X- Maintenance (deps, build, etc.)docs: update X- Documentation onlytest: add X tests- Test additions/changesrefactor: improve X- Code improvements
feature/description- New featuresfix/description- Bug fixeschore/description- Maintenance
- Create branch from
main - Make changes with commits
- Run
pnpm lintandpnpm test - Push branch and open PR
- CI must pass (build, lint, test)
- Get review from maintainer
- Squash and merge to main
Before creating a release:
- All tests pass:
pnpm test - Linting passes:
pnpm lint - Manual testing in Extension Development Host
-
CHANGELOG.mdupdated:- Move items from
[Unreleased]to new version section - Add date in format:
[0.0.6] - YYYY-MM-DD - Categorize changes: Added, Changed, Fixed, etc.
- Update version links at bottom of file
- Commit:
git commit -m "docs: update changelog for v0.0.6"
- Move items from
- Version bumped:
npm run version:patch(or minor/major) - Changes pushed:
git push && git push --tags - GitHub release created with release notes (can copy from CHANGELOG)
- Monitor release workflow: Actions tab
- Verify publishing: Marketplace
- TextMate grammar changes require VS Code reload - "Reload Window" command
- Tests download VS Code on first run - Takes time, use
test-quick.shfor iterations - LSP operations are async - Always use
sleep()in tests after operations - Package.json uses tabs - Maintain consistency
- Extension must be compiled - Run
pnpm compilebefore testing if TypeScript changed - Test fixtures are shared - Don't delete/modify without checking test dependencies
- Pro features need Pro LSP - Some tests skip if Pro not available
- Extension should activate quickly (lazy load when possible)
- Language server spawns on first
.tmfile open - Syntax highlighting is fast (TextMate grammar)
- LSP features may have slight delay (server processing)
- Extension reads
terramate.languageServer.binPathsetting (user-provided path) - Spawns external process (
terramate-ls) - No network requests from extension itself
- LSP may make network requests (Terramate Cloud features)
- VS Code Extension API: https://code.visualstudio.com/api
- LSP Specification: https://microsoft.github.io/language-server-protocol/
- TextMate Grammars: https://macromates.com/manual/en/language_grammars
- Terramate Docs: https://terramate.io/docs
- Terramate GitHub: https://github.com/terramate-io/terramate
- Discord Community: https://terramate.io/discord
- Check existing patterns in the codebase
- Run tests frequently:
pnpm test - Test manually with F5
- Check CI workflow for deployment requirements
- Ask maintainers on Discord or GitHub issues
When loading context for a task, prioritize:
-
Task-specific:
- Syntax →
syntaxes/terramate.tmLanguage.json - LSP →
src/extension.ts - Tests → relevant
src/test/*.test.ts+src/test/helper.ts
- Syntax →
-
Always useful:
package.json- Extension manifestREADME.md- User docsagents.md- This guide's companion
-
Configuration:
tsconfig.json- TypeScript configeslint.config.js- Linting rules.github/workflows/*.yml- CI/CD
-
Test data:
testFixture/- Browse subdirectories relevant to task