Visual feedback for AI coding agents - Svelte port of Agentation
Annotate UI elements with a single click and get structured data for your AI agent. Perfect for use with Claude Code.
npm install agentation-svelte
# or
pnpm add agentation-svelte
# or
yarn add agentation-svelte
Add to your root layout (+layout.svelte):
<script>
import { Agentation } from 'agentation-svelte';
import { dev } from '$app/environment';
</script>
<slot />
{#if dev}
<Agentation />
{/if}
That's it! Press Cmd/Ctrl + Shift + A to start annotating.
<script>
import { Agentation } from 'agentation-svelte';
</script>
<!-- Automatically copies annotations to clipboard -->
<Agentation />
<script>
import { Agentation } from 'agentation-svelte';
function handleAnnotation(annotation) {
console.log('Element:', annotation.element);
console.log('Path:', annotation.elementPath);
console.log('Text:', annotation.text);
console.log('Position:', annotation.boundingBox);
// Send to your agent/API
sendToAgent(annotation);
}
</script>
<Agentation
onAnnotationAdd={handleAnnotation}
copyToClipboard={false}
/>
<script>
import { Agentation } from 'agentation-svelte';
import { dev } from '$app/environment';
</script>
<!-- Only shows in development -->
{#if dev}
<Agentation />
{/if}
| Prop | Type | Default | Description |
|---|---|---|---|
onAnnotationAdd |
(annotation: Annotation) => void |
undefined |
Callback when annotation is added |
copyToClipboard |
boolean |
true |
Auto-copy to clipboard |
enabled |
boolean |
true |
Enable/disable component |
interface Annotation {
element: string; // "button", "div", etc.
elementPath: string; // "body > main > div.container > button#submit"
text: string; // Element text content
boundingBox: {
x: number;
y: number;
width: number;
height: number;
};
attributes: { // All element attributes
[key: string]: string;
};
timestamp: string; // ISO 8601 timestamp
}
Cmd/Ctrl + Shift + A or click the blue button<script>
import { Agentation } from 'agentation-svelte';
function handleAnnotation(annotation) {
// Format for Claude Code
const feedback = `
Please update this element:
- Element: ${annotation.element}
- Location: ${annotation.elementPath}
- Current text: "${annotation.text}"
- Position: x=${annotation.boundingBox.x}, y=${annotation.boundingBox.y}
`;
// Copy to clipboard for Claude
navigator.clipboard.writeText(feedback);
}
</script>
<Agentation onAnnotationAdd={handleAnnotation} />
<script>
async function handleAnnotation(annotation) {
await fetch('/api/feedback', {
method: 'POST',
body: JSON.stringify(annotation)
});
}
</script>
<Agentation
onAnnotationAdd={handleAnnotation}
copyToClipboard={false}
/>
<script>
import { dev } from '$app/environment';
function handleAnnotation(annotation) {
console.table(annotation);
console.log('Bounding box:', annotation.boundingBox);
console.log('Attributes:', annotation.attributes);
}
</script>
{#if dev}
<Agentation onAnnotationAdd={handleAnnotation} />
{/if}
The component uses these colors by default:
Styles are scoped to the component but can be overridden.
Cmd/Ctrl + Shift + A - Toggle annotation modeESC - Exit annotation mode+layout.svelte<script>
import { Agentation } from 'agentation-svelte';
import { dev } from '$app/environment';
</script>
<slot />
{#if dev}
<Agentation />
{/if}
<!-- routes/+page.svelte -->
<script>
import { Agentation } from 'agentation-svelte';
</script>
<h1>My Page</h1>
<!-- Only on this page -->
<Agentation />
<script>
import { browser, dev } from '$app/environment';
import { onMount } from 'svelte';
let showAgentation = false;
onMount(() => {
// Only load if Cmd+Shift+D is pressed
const handler = (e) => {
if (e.metaKey && e.shiftKey && e.key === 'D') {
showAgentation = true;
}
};
window.addEventListener('keydown', handler);
return () => window.removeEventListener('keydown', handler);
});
</script>
{#if browser && dev && showAgentation}
<Agentation />
{/if}
| Feature | React | Svelte |
|---|---|---|
| Bundle size | ~8KB | ~6KB |
| Dependencies | React 18+ | Svelte 4/5 |
| API | Same | Same |
| Performance | Fast | Faster |
| Setup | <Agentation /> |
<Agentation /> |
enabled prop is truedev environment if using conditionalcopyToClipboard is trueonAnnotationAdd callback as alternativeSee examples/ directory for:
This is a Svelte port of the original React version. Issues and PRs welcome!
MIT
Made for Claude Code and SvelteKit 🚀