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
| // app/layout.tsx | |
| async function RootLayout() { | |
| const user = await fetch('https://api.example.com/user').then(r => r.json()); | |
| return <nav>{user.name}</nav>; | |
| } | |
| // app/page.tsx | |
| async function HomePage() { | |
| const user = await fetch('https://api.example.com/user').then(r => r.json()); | |
| return <h1>Welcome, {user.name}</h1>; |
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
| // Cached indefinitely until manual invalidation | |
| const product = await fetch('https://api.example.com/products/123').then(r => r.json()); | |
| // Revalidated every 60 seconds | |
| const inventory = await fetch('https://api.example.com/inventory', { | |
| next: { revalidate: 60 } | |
| }).then(r => r.json()); | |
| // Never cached | |
| const user = await fetch('https://api.example.com/user', { |
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
| // app/products/[id]/page.tsx | |
| // This route is statically generated at build time | |
| export async function generateStaticParams() { | |
| const products = await fetch('https://api.example.com/products').then(r => r.json()); | |
| return products.map((p: any) => ({ id: p.id })); | |
| } | |
| export default async function ProductPage({ params }: { params: { id: string } }) { | |
| const product = await fetch(`https://api.example.com/products/${params.id}`).then(r => r.json()); | |
| return <h1>{product.name}</h1>; |
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
| // app/products/page.tsx | |
| export default function ProductsPage() { | |
| return ( | |
| <ul> | |
| <li><Link href="/products/1">Product 1</Link></li> | |
| <li><Link href="/products/2">Product 2</Link></li> | |
| </ul> | |
| ); | |
| } |
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
| import { execSync } from 'child_process'; | |
| function runHeadlessTask(prompt: string): string { | |
| try { | |
| const output = execSync(`claude -p "${prompt.replace(/"/g, '\\"')}"`, { | |
| encoding: 'utf-8', | |
| stdio: ['pipe', 'pipe', 'pipe'] | |
| }); | |
| return output; | |
| } catch (error) { |
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
| // scripts/nightly-refactor.ts | |
| import { exec } from 'child_process'; | |
| import { promisify } from 'util'; | |
| import { appendFileSync } from 'fs'; | |
| const execAsync = promisify(exec); | |
| async function nightlyRefactor(): Promise<void> { | |
| const timestamp = new Date().toISOString(); | |
| const logPath = '/var/log/claude-automation/refactor.log'; |
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
| # .github/workflows/auto-analyze-failures.yml | |
| name: Analyze Test Failures | |
| on: | |
| workflow_run: | |
| workflows: ["Run Tests"] | |
| types: [completed] | |
| jobs: | |
| analyze: | |
| if: ${{ github.event.workflow_run.conclusion == 'failure' }} |
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
| interface ClaudeJsonOutput { | |
| response: string; | |
| files_changed: Array<{ | |
| path: string; | |
| operation: 'created' | 'modified' | 'deleted'; | |
| diff?: string; | |
| }>; | |
| tokens_used: number; | |
| model: string; | |
| session_id?: string; |
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
| import { spawn } from 'child_process'; | |
| function streamHeadlessTask(prompt: string, onChunk: (data: string) => void): Promise<void> { | |
| return new Promise((resolve, reject) => { | |
| const proc = spawn('claude', [ | |
| '-p', prompt, | |
| '--stream', | |
| '--no-session-persistence' | |
| ]); | |
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
| import { spawn } from 'child_process'; | |
| import { promises as fs } from 'fs'; | |
| interface AgentTask { | |
| id: string; | |
| prompt: string; | |
| workingDir: string; | |
| } | |
| interface AgentResult { |
NewerOlder