This file provides repository guidance for coding agents and contributors working in Sprigcode.
Sprigcode is a transaction engine for semantic code edits.
It accepts typed edit operations, resolves them against a codebase, applies minimal safe edits, verifies constraints, and returns either a deterministic diff or a typed failure.
Sprigcode is not:
- an AI agent
- a chatbot
- a SaaS product
- a dashboard
- a generic codemod marketplace
Use these names consistently:
- Project:
Sprigcode - Repository:
moengadaniel/sprigcode - CLI:
sprigcode - Transaction file example:
transaction.sprigcode.json - Protocol:
Sprigcode Transaction Format - npm scope:
@sprigcode - Packages:
@sprigcode/core@sprigcode/ts@sprigcode/cli@sprigcode/schema@sprigcode/testkit
packages/core: language-agnostic engine, errors, diagnostics, text edits, diffing, rollback, and reportingpackages/ts: TypeScript and TSX adapterpackages/cli: command-line interfacepackages/schema: transaction document schemapackages/testkit: golden-test and fixture utilitiesdocs: architecture, lifecycle, errors, testing, CLI, and governance docsexamples: runnable examples and failure demos
@sprigcode/core must remain language-agnostic.
Core owns:
- transaction document types
- anchors
- constraints
- lifecycle
- typed errors and diagnostics
- low-level text edits
- conflict detection
- rollback
- diff reporting
- JSON-serializable results
Core must not import from language adapters.
Language adapters own:
- parsing
- source-file loading
- syntax-aware anchor resolution
- symbol resolution
- language-specific planning
- language-specific verification
Adapters must fail closed when an edit is ambiguous or unsupported.
The CLI is a client of the engine.
The CLI may handle:
- argument parsing
- loading transaction files
- loading workspaces
- invoking the engine
- formatting human-readable output
- emitting JSON output
- setting exit codes
The CLI must not contain semantic edit logic.
v0.1 focuses on TypeScript and TSX.
Supported operations:
add_importremove_importrename_symboladd_required_parameterupdate_call_sitesextend_object_literalreplace_call_expressioninsert_statement_before_call
Do not claim support for other languages or operations unless they are implemented and tested.
Unsupported or ambiguous edits must fail closed.
Important rules:
- a wrong edit is a critical bug
- a typed refusal is acceptable
- do not guess when anchors are ambiguous
- do not silently skip failed operations
Required typed error codes include:
INVALID_TRANSACTION_DOCUMENTUNSUPPORTED_LANGUAGEUNSUPPORTED_OPERATIONUNSUPPORTED_SYNTAXANCHOR_NOT_FOUNDANCHOR_NOT_UNIQUEMATCH_COUNT_FAILEDCONFLICTING_EDITSVALUE_NOT_AVAILABLE_IN_CALLER_SCOPEPUBLIC_API_BOUNDARYTYPECHECK_FAILEDFORMAT_FAILEDNON_IDEMPOTENT_TRANSACTIONROLLBACK_FAILEDWORKSPACE_PATH_ESCAPEINTERNAL_ERRORGENERATED_FILE_BLOCKED
Do not change public APIs casually.
Any public API change must include:
- tests
- documentation
- clear design reasoning
- example updates when needed
Write documentation like a senior software engineer:
- precise
- honest
- calm
- practical
- no hype
- no unsupported claims
- limitations clearly documented
Do not claim Sprigcode is perfect or universally correct.
- treat transaction files as untrusted input
- validate paths to avoid workspace escape
- do not execute arbitrary project scripts unless explicitly required
- do not read secrets unless required for the task and explicitly provided
- prefer least privilege in examples and tests
Coding agents must run the verification loop before reporting completion:
npm install
npm run lint
npm run typecheck
npm test
npm run test:golden
npm run test:smoke
npm run test:npm-smoke
npm run buildIf the task touches demos, packaging, or installation flows, also run any relevant smoke or pack commands.
If a command fails:
- identify the root cause
- fix it
- rerun the failed command
- rerun the full verification loop
Before any release:
- all packages build
- CLI validate, check, and apply work
- examples run end to end
- supported operations have tests
- rollback is tested
- ambiguous and missing anchors return typed failures
- README and governance docs are present and honest
For deeper detail, see:
README.mddocs/architecture.mddocs/sprigcode-ir.mddocs/transactions.mddocs/typed-errors.mddocs/testing-strategy.mddocs/accuracy-contract.mddocs/cli.md