Velt Suggestions Best Practices
Guide for implementing Velt's Suggestions API (Beta): a propose-then-review editing workflow where edits from humans or AI agents are captured as proposals that reviewers accept or reject on the Velt comment dialog. Contains 18 rules across 6 categories.
When to Apply
Reference these guidelines when:
- Adding suggestion mode to form inputs, tables, or custom components
- Implementing an AI-proposes / human-reviews workflow, in the browser or over REST
- Wiring
data-velt-suggestion-targetattributes to DOM elements - Choosing between zero-config auto-commit (default since v6.0.0-beta.13),
autoCommit: false,onTargetEditCommit, thetargetEditCommitevent, or manual commits - Handling accept/reject events and applying accepted changes
- Building custom accept/reject UI with
acceptSuggestion()/rejectSuggestion()(v6.0.9-beta.1) - Querying suggestions by target or status for custom UI
- Understanding suggestion lifecycle states (pending, accepted, rejected, stale, apply_failed)
Rule Categories by Priority
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Core | CRITICAL | core- |
| 2 | Targets | CRITICAL | targets- |
| 3 | Mode | HIGH | mode- |
| 4 | Capture | HIGH | capture- |
| 5 | Lifecycle | HIGH | lifecycle- |
| 6 | Data | MEDIUM | data- |
Quick Reference
1. Core (CRITICAL)
core-auth-provider-authProviderobject (user,generateToken,retryConfig) onVeltProvider, then set the documentcore-setup-overview- Comments prerequisite,SuggestionElementhandle, the five-step pipeline, backfill oftype: 'suggestion'annotations
2. Targets (CRITICAL)
targets-define- stabledata-velt-suggestion-targetIDs, value reading order, commit onfocusoutvschangetargets-register-getter-registerTarget()getters for multi-input targets that read live values;unregisterTarget()cleanup
3. Mode (HIGH)
mode-enable-disable-enableSuggestionMode()/disableSuggestionMode(), not persisted,autoCommitcleared on disablemode-state-observation-useSuggestionModeState()/isSuggestionModeEnabled$()for toggle UI
4. Capture (HIGH)
capture-zero-config-autoCommitdefaults totrue; passautoCommit: falsefor detect-only modecapture-auto-commit-onTargetEditCommitreturnssummary/summaryHtml/metadataornull; always wins overautoCommitcapture-deferred-commit- gate commits with thetargetEditCommitevent plusautoCommit: falsecapture-manual-startSuggestion()+commitSuggestion()for non-DOM and AI flows; rejection guardscapture-summary-html-summaryHtmlrich bodies, plainsummaryfallback, DOMPurify sanitizing
5. Lifecycle (HIGH)
lifecycle-accept-reject- idempotentsuggestionAcceptedhandler on the comment element appliesnewValuelifecycle-resolve-programmatically-acceptSuggestion()/rejectSuggestion()and hooks; deprecatedacceptCommentAnnotation()pairlifecycle-stale-drift-suggestionStale,driftDetected,apply_failedlifecycle-status-reference- exact status literals and which element emits each event
6. Data (MEDIUM)
data-query-suggestions-useSuggestions/usePendingSuggestion/getSuggestions$withSuggestionGetSuggestionsFilterdata-types-reference-SuggestionData,Suggestion<T>variants, React hooks tabledata-backend-rest- RESTtype: "suggestion"with asuggestionpayload andagentblock;agentSuggestionsfilter
Prerequisites
Suggestions require Velt Comments: the accept/reject UI renders on the Velt comment dialog. Configure VeltProvider with an authProvider and set a document, and confirm Comments work before adding Suggestions.
How to Use
Read individual rule files for detailed explanations and code examples:
rules/shared/core/core-setup-overview.md
rules/shared/capture/capture-zero-config.md
rules/shared/lifecycle/lifecycle-accept-reject.md
Each rule file contains:
- Brief explanation of why it matters
- Incorrect and correct code examples (React / Next.js and Other Frameworks)
- Verification checklist
- Source pointers to official docs
Compiled Documents
AGENTS.md- Compressed index of all rules with file paths (start here)AGENTS.full.md- Full verbose guide with all rules expanded inline