Skip to content

Comments

Refactor AI prompt system: deduplicate, shorten, and improve quality#15

Merged
epavanello merged 3 commits intomainfrom
claude/refactor-prompt-system-eTXXw
Feb 5, 2026
Merged

Refactor AI prompt system: deduplicate, shorten, and improve quality#15
epavanello merged 3 commits intomainfrom
claude/refactor-prompt-system-eTXXw

Conversation

@epavanello
Copy link
Owner

@epavanello epavanello commented Feb 5, 2026

  • Remove duplicated getKeyPropsForLayerType() from both system-prompt.ts
    and schemas.ts; replace with extractKeyProps() that auto-infers key
    properties from Zod schema shape order (first 4 fields)
  • Remove hardcoded getExampleProps() with manually maintained examples;
    tool descriptions now rely on schema defaults instead
  • Simplify system prompt from ~150 lines to ~50 lines by removing
    content already present in tool definitions (preset lists, layer tool
    lists, verbose JSON examples, repeated rules)
  • Add configure_project as explicit first workflow step to prevent AI
    from skipping project setup (background, dimensions)
  • Improve layer reference error messages in mutations.ts to include
    available layer names/IDs, helping AI self-correct on wrong references
  • Consolidate layer reference rules into one clear section instead of
    two separate explanations
  • Make tool descriptions concise and non-redundant

https://claude.ai/code/session_01JxrfQtGiLm9wQKhf1UJN9L

Summary by CodeRabbit

  • New Features

    • Compact tool summary UI in chat and a new standalone tool part display for clearer AI tool results.
    • New tooltip components improving hover/tooltip behavior and composition.
    • Added a demo prompt document showcasing product capabilities.
  • Bug Fixes

    • Standardized error messages for missing or unresolved layer references, clarifying available layers.
  • Chores

    • Streamlined AI system guidance to concise workflow steps.
    • Improved documentation formatting and presentation for consistency.
  • UX

    • Cmd/Ctrl+N now emits a new-project event for external handling (updated New Project flow).

- Remove duplicated getKeyPropsForLayerType() from both system-prompt.ts
  and schemas.ts; replace with extractKeyProps() that auto-infers key
  properties from Zod schema shape order (first 4 fields)
- Remove hardcoded getExampleProps() with manually maintained examples;
  tool descriptions now rely on schema defaults instead
- Simplify system prompt from ~150 lines to ~50 lines by removing
  content already present in tool definitions (preset lists, layer tool
  lists, verbose JSON examples, repeated rules)
- Add configure_project as explicit first workflow step to prevent AI
  from skipping project setup (background, dimensions)
- Improve layer reference error messages in mutations.ts to include
  available layer names/IDs, helping AI self-correct on wrong references
- Consolidate layer reference rules into one clear section instead of
  two separate explanations
- Make tool descriptions concise and non-redundant

https://claude.ai/code/session_01JxrfQtGiLm9wQKhf1UJN9L
@coderabbitai
Copy link

coderabbitai bot commented Feb 5, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Refactors AI layer-not-found error handling, adds schema introspection to derive layer key props, streamlines the AI system prompt, introduces new tooltip and tool-part UI components, and applies documentation formatting edits. Several UI interactions and a login guard were updated; no public API signatures were added beyond prop changes noted.

Changes

Cohort / File(s) Summary
Documentation
CLAUDE.md, Prompt demo.md
Formatting and content tweaks in CLAUDE.md; new Prompt demo.md added (concept/demo spec). No code behavior changes.
AI mutations
src/lib/ai/mutations.ts
Added layerNotFoundError(project, ref) helper and replaced repeated not-found error objects; added guard when resolved layer ID no longer exists.
Schema & tooling
src/lib/ai/schemas.ts, src/lib/ai/system-prompt.ts
Introduced schema introspection (MAX_KEY_PROPS, extractKeyProps) to derive key props/defaults from Zod schemas; refactored layer creation tool generation; condensed and simplified the system prompt content and layout narration.
AI chat UI
src/lib/components/ai/ai-chat.svelte, src/lib/components/ai/tool-part.svelte
Reworked per-message layout to stacked structure; replaced inline tool rendering with new ToolPart component that summarizes tool status and details.
Editor keyboard & timeline
src/lib/components/editor/keyboard-handler.svelte, src/lib/components/editor/timeline/timeline-keyframe.svelte
Changed Cmd/Ctrl+N flow to dispatch devmotion:new-project event; switched tooltip imports/usage to TooltipWrapper.
Toolbar & save/new flows
src/lib/components/editor/toolbar.svelte
Replaced many Tooltip usages with TooltipButton/dropdowns; added window listeners for devmotion:new-project and devmotion:save; made handleSaveToCloud async and navigational adjustments after new project creation.
Tooltip system (new components & exports)
src/lib/components/ui/tooltip/*, src/lib/components/ui/tooltip/index.ts
Reorganized tooltip layer: added tooltip-provider.svelte, tooltip-portal.svelte, tooltip-wrapper.svelte, tooltip-button.svelte, updated tooltip.svelte to use RootProps, and changed public exports/aliases in index.ts (removed default export, renamed aliases).
Tooltip content API
src/lib/components/ui/tooltip/tooltip-content.svelte
Added portalProps prop to TooltipContent and updated styling/animation classes; public prop signature extended.
UI store (login guard)
src/lib/stores/ui.svelte.ts
UIStore.requireLogin(action, fn) now accepts an async callback and awaits the callback when user is present (signature updated).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I nudged the schemas, found their keys,
I stitched the prompts to sail the breeze,
Errors now sing from one clear bell,
ToolParts chatter, tooltips swell —
Hop, hop, the repo hums with ease! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately captures the main refactoring work: deduplicating code, shortening the system prompt, and improving quality through consolidation and schema-driven approaches.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/refactor-prompt-system-eTXXw

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

… with dedicated wrapper, provider, and button components.
@epavanello epavanello merged commit 907a6ac into main Feb 5, 2026
1 check was pending
This was referenced Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants