Use ScryCLI’s AI-powered suggestions to automatically fix code errors and implement improvements
After analyzing your code, ScryCLI can help you fix detected errors through AI-generated code updates. This guide shows you how to leverage AI suggestions for efficient error resolution.
{ "action": "write_file", "file": "src/lib/auth.ts", "content": "import { getConfig } from '../config/configManage.js';\n// Updated code with fix..."}
The write_file action overwrites the entire file content. The AI includes the full file content in the response, not just the changed lines. While the AI’s system prompt mentions update_file, it is processed the same as write_file by the tool executor.
# Add try-catch blocks> Wrap the file operations in src/tools/ with proper error handling# Add null checks> Add null checking to the config access in src/lib/isModelSelected.ts# Handle async errors> Add error handling to the async llmCall in src/model/openRouter.ts
# Add TypeScript types> Add proper type definitions to the useChat hook parameters# Fix type errors> Fix the TypeScript error in the llmCall return type# Add type guards> Add type guards to the JSON parsing in useToolExecutor
# Improve authentication> Strengthen the JWT verification in src/lib/auth.ts# Add input validation> Add path validation to prevent directory traversal in readFile# Sanitize user input> Add input sanitization to the file path resolver
When a fix requires changes across multiple files:
# Step 1: Update the interface> Update the llmCallParams interface in src/model/openRouter.ts to include options# Step 2: Update the implementation> Update the llmCall function to use the new options parameter# Step 3: Update callers> Update useChat.ts to pass options when calling llmCall
For complex multi-file fixes, address one file at a time and verify each change before moving to the next.
# Improve code structure> Refactor the file tree generation to use a class-based approach# Extract common logic> Extract the path resolution logic from all tool functions into a shared utility# Simplify complex functions> Simplify the useToolExecutor effect by breaking it into smaller functions
# Provide context for complex fixes> Update the authentication flow to support OAuth, keeping compatibility with the existing JWT approach in src/lib/auth.ts
# Step 1: Identify> Check src/model/openRouter.ts for type errors# AI Response:# "Property 'model' not found on config"# Step 2: Fix> Add optional chaining to config.model access and handle undefined case# Step 3: Verify> Read src/model/openRouter.ts and check the fix# Step 4: Testnpm run build
# Step 1: Security scan> Analyze src/tools/readFile.ts for security vulnerabilities# AI Response:# "Path traversal vulnerability - user input not validated"# Step 2: Request fix> Add path validation to readFile to prevent directory traversal attacks# Step 3: Review implementation> Read src/tools/readFile.ts# Step 4: Apply similar fix to other tools> Apply the same path validation to writeFile, createFile, and deleteFile
# Step 1: Identify code smell> Review src/hooks/useToolExecutor.ts for code quality issues# Step 2: Request refactor> Extract the instruction parsing logic into a separate utility function# Step 3: Create new file> Create src/utils/parseInstruction.ts with the extracted logic# Step 4: Update original> Update useToolExecutor.ts to use the new parseInstruction utility
# The tool executor will log:# "Error executing tool: Unexpected token"# Try rephrasing your request:> Update src/lib/auth.ts to add better error handling - respond with valid JSON only
# If file doesn't exist:# "Error: ENOENT: no such file or directory"# Verify the file path:> Show me the file tree for the src directory# Then use correct path:> Update src/lib/auth.ts (not lib/auth.ts)