Add Rafid Prompt Tool - AI-powered prompt optimization app#46620
Open
HumanBotRafid wants to merge 1 commit intoanthropics:mainfrom
Open
Add Rafid Prompt Tool - AI-powered prompt optimization app#46620HumanBotRafid wants to merge 1 commit intoanthropics:mainfrom
HumanBotRafid wants to merge 1 commit intoanthropics:mainfrom
Conversation
Premium AI prompt optimiser with Quick Optimise and Deep Build modes,
powered by Claude via @anthropic-ai/sdk. Built with Next.js 14 App
Router, Tailwind CSS, and next/font/google (Playfair Display + DM Sans).
- Single-page layout: Navbar, Hero, Mode Toggle, Input Form, Output
- /api/optimise: one-shot rewrite with {optimised, explanation} JSON
- /api/deepbuild/questions + /api/deepbuild/generate: clarify-then-build
- Robust JSON extraction with fence stripping + balanced-brace fallback
- localStorage-backed daily usage cap (3/day), SSR-safe with Limit modal
- Brand tokens (#FAF8F5 bg, #0D0D0D ink, #C8852A amber) in Tailwind
- Copy button, fade-in animations, mobile responsive stacking
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces the complete Rafid Prompt Tool application, a Next.js-based web application that optimizes AI prompts using Claude. The tool offers two modes: Quick Optimise for instant improvements and Deep Build for iterative refinement through guided questions.
Key Changes
Core Application Structure
PromptTool.tsx): Orchestrates the entire flow with state management for two optimization modes, usage tracking, and error handlinglayout.tsx,page.tsx): Next.js app structure with custom fonts (Playfair Display, DM Sans) and metadataglobals.css,tailwind.config.ts): Custom Tailwind theme with amber accent color, custom shadows, and animationsUI Components
API Routes
/api/optimise: Quick optimization endpoint that takes a prompt and returns optimized version with explanation/api/deepbuild/questions: Generates 3-5 contextual questions based on the initial prompt/api/deepbuild/generate: Final generation endpoint that combines original prompt with user answers to questionsUtilities & Helpers
lib/anthropic.ts: Claude API client wrapper with JSON parsing supportlib/parseJson.ts: Robust JSON extraction from Claude responses (handles code fences, balanced braces)lib/prompts.ts: System prompts for quick optimize, deep build questions, and deep build generationlib/apiHelpers.ts: Request validation, error mapping, and type guardslib/usage.ts: Client-side usage tracking with localStorage, daily limit enforcement (3 free uses/day)lib/types.ts: TypeScript types for modes, goals, target AIs, API responses, and usage recordsConfiguration
@/*).env.examplefor ANTHROPIC_API_KEYNotable Implementation Details
https://claude.ai/code/session_01AEUzJynCeHD5hgd8tughvW