<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Bilal Haidar</title>
    <description>The latest articles on Forem by Bilal Haidar (@bhaidar).</description>
    <link>https://forem.com/bhaidar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F127567%2Ff131b7c5-65e0-4f76-be20-363ec27aa152.png</url>
      <title>Forem: Bilal Haidar</title>
      <link>https://forem.com/bhaidar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/bhaidar"/>
    <language>en</language>
    <item>
      <title>How to Use Claude.ai's Research Toggle Inside Claude Code</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Tue, 27 Jan 2026 06:31:06 +0000</pubDate>
      <link>https://forem.com/bhaidar/how-to-use-claudeais-research-toggle-inside-claude-code-469d</link>
      <guid>https://forem.com/bhaidar/how-to-use-claudeais-research-toggle-inside-claude-code-469d</guid>
      <description>&lt;h2 id="the-missing-feature-that-changes-everything"&gt;The Missing Feature That Changes Everything&lt;/h2&gt;

&lt;p&gt;If you've been using Claude Code for development, you've probably noticed something frustrating: you can search the web, but you can't access Claude's powerful &lt;strong&gt;Research&lt;/strong&gt; feature.&lt;/p&gt;

&lt;p&gt;Web search gives you quick answers in seconds. Research gives you comprehensive, multi-source reports with citations in 5 to 30 minutes. They're not the same thing, and for serious technical decisions, Research is a game changer.&lt;/p&gt;

&lt;p&gt;This guide shows you how to bring Research into Claude Code using a clever workaround that spawns a background agent to control your browser.&lt;/p&gt;




&lt;h2 id="the-problem-web-search-vs-research"&gt;The Problem: Web Search vs Research&lt;/h2&gt;

&lt;h3 id="what-web-search-does"&gt;What Web Search Does&lt;/h3&gt;

&lt;p&gt;When you ask Claude Code to search the web, it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Runs a single search query&lt;/li&gt;
&lt;li&gt;Reads the top 10 results&lt;/li&gt;
&lt;li&gt;Summarizes what it finds&lt;/li&gt;
&lt;li&gt;Returns an answer in 10 to 30 seconds&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is great for quick lookups like "What's the syntax for Laravel's whereHas?" or "Who maintains this package?"&lt;/p&gt;

&lt;h3 id="what-research-does"&gt;What Research Does&lt;/h3&gt;

&lt;p&gt;When you use the Research toggle in Claude.ai, it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Breaks your question into multiple search strategies&lt;/li&gt;
&lt;li&gt;Runs dozens of searches across different angles&lt;/li&gt;
&lt;li&gt;Reads full articles, not just snippets&lt;/li&gt;
&lt;li&gt;Follows links to related content&lt;/li&gt;
&lt;li&gt;Cross-references sources for accuracy&lt;/li&gt;
&lt;li&gt;Identifies patterns and contradictions&lt;/li&gt;
&lt;li&gt;Synthesizes everything into a comprehensive report&lt;/li&gt;
&lt;li&gt;Includes proper citations&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This takes 5 to 30 minutes, but the output is dramatically different.&lt;/p&gt;

&lt;h3 id="real-world-comparison"&gt;Real World Comparison&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Query&lt;/strong&gt;: "What's new in Laravel 12?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Search Result&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Laravel 12 introduces several new features including improved routing performance and better Eloquent query optimization. The release focuses on developer experience improvements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Research Result&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A 15+ paragraph report covering:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Complete feature changelog with code examples&lt;/li&gt;
&lt;li&gt;Breaking changes from Laravel 11&lt;/li&gt;
&lt;li&gt;Step by step migration guide&lt;/li&gt;
&lt;li&gt;Performance benchmarks comparing v11 vs v12&lt;/li&gt;
&lt;li&gt;Community reception and early adopter feedback&lt;/li&gt;
&lt;li&gt;Package compatibility status&lt;/li&gt;
&lt;li&gt;Links to 20+ authoritative sources&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;For architectural decisions, migration planning, or evaluating new technologies, Research is worth the wait.&lt;/p&gt;

&lt;h3 id="the-gap"&gt;The Gap&lt;/h3&gt;

&lt;p&gt;Claude Code has web search built in. But the Research toggle only exists in the Claude.ai web interface. There's no &lt;code&gt;/research&lt;/code&gt; command, no API endpoint, no native way to access it from your terminal.&lt;/p&gt;

&lt;p&gt;Until now.&lt;/p&gt;




&lt;h2 id="the-solution-background-agents-chrome-automation"&gt;The Solution: Background Agents + Chrome Automation&lt;/h2&gt;

&lt;p&gt;Here's the insight: Claude Code can control your Chrome browser through the Claude in Chrome extension. And Claude.ai runs in Chrome. So we can make Claude Code open Claude.ai, toggle Research, run a query, and extract the results.&lt;/p&gt;

&lt;p&gt;But there's a catch. Research takes 5 to 30 minutes. If we run this as a normal task, Claude Code would block and wait, wasting your time.&lt;/p&gt;

&lt;p&gt;The solution is &lt;strong&gt;background agents&lt;/strong&gt;. We spawn a dedicated agent that runs the Research automation while your main Claude Code session continues working on other tasks. When Research completes, the results are saved to your project and the agent reports back.&lt;/p&gt;

&lt;h3 id="architecture"&gt;Architecture&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;┌─────────────────────────────────────┐
│  Your Main Claude Code Session      │
│  (Keep working &lt;span class="hljs-keyword"&gt;on&lt;/span&gt; other tasks)      │
└──────────────────┬──────────────────┘
                   │ Spawn background agent
                   ▼
┌─────────────────────────────────────┐
│  Background Agent                   │
│  (Dedicated &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; research task)       │
└──────────────────┬──────────────────┘
                   │ Uses claude &lt;span class="hljs-comment"&gt;--chrome&lt;/span&gt;
                   ▼
┌─────────────────────────────────────┐
│  Claude &lt;span class="hljs-keyword"&gt;in&lt;/span&gt; Chrome Extension         │
│  (Controls your browser)            │
└──────────────────┬──────────────────┘
                   │ Navigates &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; interacts
                   ▼
┌─────────────────────────────────────┐
│  Claude.ai Research Feature         │
│  (Runs &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; &lt;span class="hljs-number"&gt;5&lt;/span&gt;&lt;span class="hljs-number"&gt;-30&lt;/span&gt; minutes)            │
└──────────────────┬──────────────────┘
                   │ Extracts results
                   ▼
┌─────────────────────────────────────┐
│  ./docs/research/report.md          │
│  (Saved &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; your project)            │
└─────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="prerequisites"&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;Before setting this up, you need:&lt;/p&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirement&lt;/th&gt;
&lt;th&gt;Details&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Claude Code&lt;/td&gt;
&lt;td&gt;Version 2.0.60 or higher (for background agents)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude Plan&lt;/td&gt;
&lt;td&gt;Pro, Team, Max, or Enterprise (Research requires paid plan)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chrome&lt;/td&gt;
&lt;td&gt;Google Chrome browser (not Brave, Arc, or other Chromium browsers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Claude in Chrome&lt;/td&gt;
&lt;td&gt;The official extension from Anthropic&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3 id="install-claude-in-chrome-extension"&gt;Install Claude in Chrome Extension&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Visit &lt;a href="https://chromewebstore.google.com/detail/claude/fcoeoabgfenejglbffodgkkbkcdhcgfn" rel="noopener noreferrer"&gt;Claude Chrome Extension&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Click "Add to Chrome"&lt;/li&gt;
&lt;li&gt;Sign in with your Claude account when prompted&lt;/li&gt;
&lt;li&gt;Pin the extension to your toolbar (click puzzle icon, then pin)&lt;/li&gt;
&lt;/ol&gt;

&lt;h2 id="critical-fix-the-native-messaging-conflict"&gt;Critical Fix: The Native Messaging Conflict&lt;/h2&gt;
&lt;p&gt;If you have both &lt;strong&gt;Claude Desktop&lt;/strong&gt; and &lt;strong&gt;Claude Code&lt;/strong&gt; installed, there's a conflict that prevents &lt;code&gt;claude --chrome&lt;/code&gt; from connecting to the browser extension.&lt;/p&gt;
&lt;h3 id="diagnosing-the-problem"&gt;Diagnosing the Problem&lt;/h3&gt;
&lt;p&gt;Run this command:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ls ~&lt;span class="hljs-regexp"&gt;/Library/&lt;/span&gt;Application\ Support&lt;span class="hljs-regexp"&gt;/Google/&lt;/span&gt;Chrome&lt;span class="hljs-regexp"&gt;/NativeMessagingHosts/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If you see &lt;strong&gt;both&lt;/strong&gt; of these files, you have the conflict:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt;      ← Claude Desktop
com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_code_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt; ← Claude Code
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Chrome connects to the first one (Claude Desktop) and ignores Claude Code.&lt;/p&gt;
&lt;h3 id="the-fix"&gt;The Fix&lt;/h3&gt;
&lt;p&gt;Back up the Claude Desktop configuration:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;mv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt; \
   ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.backup&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Quit Chrome completely (Cmd+Q on Mac, not just closing the window)&lt;/li&gt;
&lt;li&gt;Restart Chrome&lt;/li&gt;
&lt;li&gt;Open the Claude extension by clicking its icon in the toolbar&lt;/li&gt;
&lt;li&gt;Test the connection with &lt;code&gt;claude --chrome&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id="reverting-later"&gt;Reverting Later&lt;/h3&gt;

&lt;p&gt;If you need Claude Desktop's Chrome integration back:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;mv ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.backup&lt;/span&gt; \
   ~/Library/Application\ Support/Google/Chrome/NativeMessagingHosts/com&lt;span class="hljs-selector-class"&gt;.anthropic&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.claude_browser_extension&lt;/span&gt;&lt;span class="hljs-selector-class"&gt;.json&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;




&lt;h2 id="installing-the-research-skill"&gt;Installing the Research Skill&lt;/h2&gt;

&lt;p&gt;The Research skill consists of several files that tell Claude Code how to perform the automation.&lt;/p&gt;

&lt;h3 id="file-structure"&gt;File Structure&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;~&lt;span class="hljs-regexp"&gt;/.claude/skills&lt;/span&gt;&lt;span class="hljs-regexp"&gt;/web-research-task/&lt;/span&gt;
├── SKILL.md                    &lt;span class="hljs-comment"&gt;# Main skill documentation&lt;/span&gt;
├── agent-prompt.md             &lt;span class="hljs-comment"&gt;# Step-by-step instructions for the agent&lt;/span&gt;
└── commands/
    └── research-via-web.md     &lt;span class="hljs-comment"&gt;# Slash command definition&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="step-1-create-the-directories"&gt;Step 1: Create the Directories&lt;/h3&gt;
&lt;pre&gt;&lt;code&gt;mkdir -p ~&lt;span class="hljs-regexp"&gt;/.claude/&lt;/span&gt;skills&lt;span class="hljs-regexp"&gt;/web-research-task/&lt;/span&gt;commands
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id="step-2-create-skill-md"&gt;Step 2: Create SKILL.md&lt;/h3&gt;

&lt;p&gt;Save this as &lt;code&gt;~/.claude/skills/web-research-task/SKILL.md&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;# Claude Web Research Task

## Purpose
This skill enables Claude Code &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; spawn a dedicated background agent that uses 
Claude &lt;span class="hljs-keyword"&gt;in&lt;/span&gt; Chrome &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-keyword"&gt;access&lt;/span&gt; Claude.ai&lt;span class="hljs-symbol"&gt;'s&lt;/span&gt; Research toggle, run deep research 
queries, &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; comprehensive results.

IMPORTANT: This task MUST run as a background agent because Research takes 
&lt;span class="hljs-number"&gt;5&lt;/span&gt; &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-number"&gt;30&lt;/span&gt;+ minutes. Do &lt;span class="hljs-keyword"&gt;NOT&lt;/span&gt; skip this step &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; try &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; inline it into other workflows.

## Prerequisites

&lt;span class="hljs-number"&gt;1&lt;/span&gt;. Claude &lt;span class="hljs-keyword"&gt;in&lt;/span&gt; Chrome Extension installed &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; authenticated
&lt;span class="hljs-number"&gt;2&lt;/span&gt;. Claude Code v2.&lt;span class="hljs-number"&gt;0.60&lt;/span&gt;+ (&lt;span class="hljs-keyword"&gt;for&lt;/span&gt; background agents)
&lt;span class="hljs-number"&gt;3&lt;/span&gt;. Paid Claude subscription (Pro/Team/Max/Enterprise)
&lt;span class="hljs-number"&gt;4&lt;/span&gt;. Chrome browser running

## How &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; Invoke

### Option &lt;span class="hljs-number"&gt;1&lt;/span&gt;: Background Agent (Recommended)

Start Claude Code &lt;span class="hljs-keyword"&gt;with&lt;/span&gt; Chrome integration:
  claude &lt;span class="hljs-comment"&gt;--chrome&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;Then&lt;/span&gt; spawn the research task:
  Spawn a background agent &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; research via Claude.ai: &lt;span class="hljs-string"&gt;"Your query here"&lt;/span&gt;

Press Ctrl+Shift+B &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; &lt;span class="hljs-keyword"&gt;not&lt;/span&gt; automatically backgrounded.

### Option &lt;span class="hljs-number"&gt;2&lt;/span&gt;: Slash Command

  /research-via-web &lt;span class="hljs-string"&gt;"Your query here"&lt;/span&gt;

## Workflow Steps

The background agent will:

&lt;span class="hljs-number"&gt;1&lt;/span&gt;. &lt;span class="hljs-keyword"&gt;Open&lt;/span&gt; &lt;span class="hljs-keyword"&gt;new&lt;/span&gt; Chrome tab &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; https://claude.ai
&lt;span class="hljs-number"&gt;2&lt;/span&gt;. &lt;span class="hljs-keyword"&gt;Wait&lt;/span&gt; &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; page load
&lt;span class="hljs-number"&gt;3&lt;/span&gt;. Click &lt;span class="hljs-string"&gt;"Research"&lt;/span&gt; toggle (bottom left &lt;span class="hljs-keyword"&gt;of&lt;/span&gt; chat interface)
&lt;span class="hljs-number"&gt;4&lt;/span&gt;. Enter the research query &lt;span class="hljs-keyword"&gt;in&lt;/span&gt; the chat input
&lt;span class="hljs-number"&gt;5&lt;/span&gt;. Submit &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; &lt;span class="hljs-keyword"&gt;wait&lt;/span&gt; &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; research &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; complete (&lt;span class="hljs-number"&gt;5&lt;/span&gt;-&lt;span class="hljs-number"&gt;30&lt;/span&gt; minutes)
&lt;span class="hljs-number"&gt;6&lt;/span&gt;. Extract the full response including citations
&lt;span class="hljs-number"&gt;7&lt;/span&gt;. Save &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-keyword"&gt;file&lt;/span&gt;: ./docs/research/[timestamp]-[query-slug].md
&lt;span class="hljs-number"&gt;8&lt;/span&gt;. &lt;span class="hljs-keyword"&gt;Return&lt;/span&gt; summary &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; main Claude Code session

## Critical Instructions

&lt;span class="hljs-keyword"&gt;When&lt;/span&gt; executing this task:

- Run as BACKGROUND AGENT (&lt;span class="hljs-keyword"&gt;use&lt;/span&gt; run_in_background: &lt;span class="hljs-literal"&gt;true&lt;/span&gt;)
- DO &lt;span class="hljs-keyword"&gt;NOT&lt;/span&gt; attempt &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; speed this up &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; skip steps
- &lt;span class="hljs-keyword"&gt;WAIT&lt;/span&gt; &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; the Research feature &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; fully complete
- Poll the page every &lt;span class="hljs-number"&gt;30&lt;/span&gt; seconds &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; check completion status
- Only extract results &lt;span class="hljs-keyword"&gt;AFTER&lt;/span&gt; seeing the full research output

## Expected Timeline

| Phase | Duration |
|&lt;span class="hljs-comment"&gt;-------|----------|&lt;/span&gt;
| Navigate &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; claude.ai | &lt;span class="hljs-number"&gt;5&lt;/span&gt;-&lt;span class="hljs-number"&gt;10&lt;/span&gt; seconds |
| Toggle Research | &lt;span class="hljs-number"&gt;2&lt;/span&gt;-&lt;span class="hljs-number"&gt;5&lt;/span&gt; seconds |
| Enter query | &lt;span class="hljs-number"&gt;5&lt;/span&gt;-&lt;span class="hljs-number"&gt;10&lt;/span&gt; seconds |
| Research execution | &lt;span class="hljs-number"&gt;5&lt;/span&gt;-&lt;span class="hljs-number"&gt;30&lt;/span&gt; minutes |
| Extract results | &lt;span class="hljs-number"&gt;10&lt;/span&gt;-&lt;span class="hljs-number"&gt;30&lt;/span&gt; seconds |
| Save &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-keyword"&gt;file&lt;/span&gt; | &lt;span class="hljs-number"&gt;2&lt;/span&gt;-&lt;span class="hljs-number"&gt;5&lt;/span&gt; seconds |

Total: &lt;span class="hljs-number"&gt;6&lt;/span&gt; &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-number"&gt;35&lt;/span&gt; minutes (mostly waiting &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; Research)
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id="step-3-create-agent-prompt-md"&gt;Step 3: Create agent-prompt.md&lt;/h3&gt;

&lt;p&gt;Save this as &lt;code&gt;~/.claude/skills/web-research-task/agent-prompt.md&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-meta"&gt;# Web Research Agent Instructions&lt;/span&gt;

You are a background agent tasked with performing deep research using 
Claude.ai's Research feature via Chrome automation.

&lt;span class="hljs-meta"&gt;## Your Mission&lt;/span&gt;

Execute deep research through the Claude.ai web interface &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; &lt;span class="hljs-keyword"&gt;return&lt;/span&gt; 
comprehensive results.

&lt;span class="hljs-meta"&gt;## Step-by-Step Execution&lt;/span&gt;

&lt;span class="hljs-meta"&gt;### Step 1: Navigate to Claude.ai&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;Open&lt;/span&gt; a &lt;span class="hljs-keyword"&gt;new&lt;/span&gt; Chrome &lt;span class="hljs-built_in"&gt;tab&lt;/span&gt; &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; navigate to https:&lt;span class="hljs-comment"&gt;//claude.ai&lt;/span&gt;

&lt;span class="hljs-built_in"&gt;Wait&lt;/span&gt; &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; the page to fully &lt;span class="hljs-keyword"&gt;load&lt;/span&gt;. Look &lt;span class="hljs-keyword"&gt;for&lt;/span&gt;:
- The chat interface
- The model selector
- The input field at the bottom

&lt;span class="hljs-keyword"&gt;If&lt;/span&gt; you see a login &lt;span class="hljs-keyword"&gt;screen&lt;/span&gt;, &lt;span class="hljs-keyword"&gt;STOP&lt;/span&gt; &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; notify the user.

&lt;span class="hljs-meta"&gt;### Step 2: Start a New Conversation&lt;/span&gt;

Click &lt;span class="hljs-string"&gt;"New chat"&lt;/span&gt; to ensure you have a fresh conversation.

&lt;span class="hljs-meta"&gt;### Step 3: Enable Research Toggle&lt;/span&gt;

Location: Bottom left of the chat interface, look &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; &lt;span class="hljs-string"&gt;"Research"&lt;/span&gt; button.

Action: Click the Research toggle to &lt;span class="hljs-keyword"&gt;enable&lt;/span&gt; it. The button should change 
state (often turns blue &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; shows as active).

Verification: Confirm Research mode is enabled before proceeding.

&lt;span class="hljs-meta"&gt;### Step 4: Enter the Research Query&lt;/span&gt;

&lt;span class="hljs-built_in"&gt;Type&lt;/span&gt; the research query into the chat input field.

&lt;span class="hljs-meta"&gt;### Step 5: Submit and Monitor&lt;/span&gt;

Press Enter &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; click Send to submit the query.

CRITICAL WAITING PERIOD:
- Research takes &lt;span class="hljs-number"&gt;5&lt;/span&gt; to &lt;span class="hljs-number"&gt;30&lt;/span&gt;+ minutes
- &lt;span class="hljs-keyword"&gt;DO&lt;/span&gt; &lt;span class="hljs-keyword"&gt;NOT&lt;/span&gt; interrupt &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; timeout early
- Poll the page every &lt;span class="hljs-number"&gt;30&lt;/span&gt; to &lt;span class="hljs-number"&gt;60&lt;/span&gt; seconds to check status

Completion indicators:
- Research progress &lt;span class="hljs-built_in"&gt;bar&lt;/span&gt; reaches &lt;span class="hljs-number"&gt;100&lt;/span&gt;%
- &lt;span class="hljs-string"&gt;"Research complete"&lt;/span&gt; message appears
- Final formatted &lt;span class="hljs-keyword"&gt;output&lt;/span&gt; with citations is visible
- No more loading indicators

&lt;span class="hljs-meta"&gt;### Step 6: Extract Results&lt;/span&gt;

Once complete, extract:
&lt;span class="hljs-number"&gt;1.&lt;/span&gt; The full research response text
&lt;span class="hljs-number"&gt;2.&lt;/span&gt; All citations &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; sources
&lt;span class="hljs-number"&gt;3.&lt;/span&gt; Any structured data &lt;span class="hljs-keyword"&gt;or&lt;/span&gt; summaries

&lt;span class="hljs-meta"&gt;### Step 7: Save Results&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;Create&lt;/span&gt; the &lt;span class="hljs-keyword"&gt;output&lt;/span&gt; file with this &lt;span class="hljs-keyword"&gt;format&lt;/span&gt;:

Filename: YYYYMMDD-HHMMSS-[query-slug].md

Content:
&lt;span class="hljs-meta"&gt;# Research: [Query Title]&lt;/span&gt;

**Generated**: [ISO Timestamp]
**Duration**: [Approximate duration]
**Source**: Claude.ai Research Feature
**Query**: [Original query]

---

[FULL RESEARCH CONTENT HERE]

---

&lt;span class="hljs-meta"&gt;## Sources Referenced&lt;/span&gt;

[List all citations from the research]

&lt;span class="hljs-keyword"&gt;Save&lt;/span&gt; location: ./docs/research/

&lt;span class="hljs-meta"&gt;### Step 8: Report Back&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;Return&lt;/span&gt; to the main Claude &lt;span class="hljs-built_in"&gt;Code&lt;/span&gt; session with:
- Confirmation of completion
- File path &lt;span class="hljs-built_in"&gt;where&lt;/span&gt; results are &lt;span class="hljs-built_in"&gt;saved&lt;/span&gt;
- Brief &lt;span class="hljs-number"&gt;2&lt;/span&gt;&lt;span class="hljs-number"&gt;-3&lt;/span&gt; sentence summary of &lt;span class="hljs-built_in"&gt;key&lt;/span&gt; findings

&lt;span class="hljs-meta"&gt;## Important Reminders&lt;/span&gt;

&lt;span class="hljs-number"&gt;1.&lt;/span&gt; PATIENCE IS REQUIRED: Research is slow by &lt;span class="hljs-built_in"&gt;design&lt;/span&gt;. &lt;span class="hljs-keyword"&gt;Do&lt;/span&gt; &lt;span class="hljs-keyword"&gt;not&lt;/span&gt; rush.
&lt;span class="hljs-number"&gt;2.&lt;/span&gt; BACKGROUND ONLY: This task must &lt;span class="hljs-keyword"&gt;run&lt;/span&gt; as a background agent.
&lt;span class="hljs-number"&gt;3.&lt;/span&gt; COMPLETE EXTRACTION: &lt;span class="hljs-built_in"&gt;Wait&lt;/span&gt; &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; ALL content before extracting.
&lt;span class="hljs-number"&gt;4.&lt;/span&gt; PRESERVE CITATIONS: Sources are critical; never omit them.
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id="step-4-create-the-slash-command"&gt;Step 4: Create the Slash Command&lt;/h3&gt;

&lt;p&gt;Save this as &lt;code&gt;~/.claude/skills/web-research-task/commands/research-via-web.md&lt;/code&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;# /research-via-web&lt;/span&gt;

Execute deep research using Claude.ai's Research feature via Chrome automation.

&lt;span class="hljs-comment"&gt;## Usage&lt;/span&gt;

  /research-via-web &lt;span class="hljs-string"&gt;"Your research query here"&lt;/span&gt;

&lt;span class="hljs-comment"&gt;## Behavior&lt;/span&gt;

This command MUST be &lt;span class="hljs-built_in"&gt;run&lt;/span&gt; &lt;span class="hljs-keyword"&gt;as&lt;/span&gt; a background agent. When invoked:

&lt;span class="hljs-number"&gt;1.&lt;/span&gt; Spawns a dedicated background agent
&lt;span class="hljs-number"&gt;2.&lt;/span&gt; Uses Claude &lt;span class="hljs-keyword"&gt;in&lt;/span&gt; Chrome &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; navigate &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; claude.ai
&lt;span class="hljs-number"&gt;3.&lt;/span&gt; Enables &lt;span class="hljs-keyword"&gt;the&lt;/span&gt; Research toggle
&lt;span class="hljs-number"&gt;4.&lt;/span&gt; Submits &lt;span class="hljs-keyword"&gt;the&lt;/span&gt; query
&lt;span class="hljs-number"&gt;5.&lt;/span&gt; Waits &lt;span class="hljs-keyword"&gt;for&lt;/span&gt; full completion (&lt;span class="hljs-number"&gt;5&lt;/span&gt; &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; &lt;span class="hljs-number"&gt;30&lt;/span&gt; minutes)
&lt;span class="hljs-number"&gt;6.&lt;/span&gt; Extracts &lt;span class="hljs-keyword"&gt;and&lt;/span&gt; saves results &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; ./docs/research/

&lt;span class="hljs-comment"&gt;## CRITICAL: Background Execution Required&lt;/span&gt;

Research takes significant &lt;span class="hljs-built_in"&gt;time&lt;/span&gt;. This command runs autonomously &lt;span class="hljs-keyword"&gt;while&lt;/span&gt; 
you &lt;span class="hljs-keyword"&gt;continue&lt;/span&gt; other work.

Press Ctrl+Shift+B &lt;span class="hljs-keyword"&gt;after&lt;/span&gt; invoking &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; send &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; background &lt;span class="hljs-keyword"&gt;if&lt;/span&gt; needed.

&lt;span class="hljs-comment"&gt;## Examples&lt;/span&gt;

  /research-via-web &lt;span class="hljs-string"&gt;"Compare Inertia.js vs Livewire for Laravel SPAs in 2026"&lt;/span&gt;

  /research-via-web &lt;span class="hljs-string"&gt;"Best practices for SQL Server query optimization"&lt;/span&gt;

  /research-via-web &lt;span class="hljs-string"&gt;"SharePoint Framework SPFx performance patterns"&lt;/span&gt;

&lt;span class="hljs-comment"&gt;## Output Location&lt;/span&gt;

Results saved &lt;span class="hljs-keyword"&gt;to&lt;/span&gt;: ./docs/research/YYYYMMDD-HHMMSS-query-slug.md
&lt;/code&gt;&lt;/pre&gt;

&lt;h3 id="step-5-add-to-your-project-s-claude-md"&gt;Step 5: Add to Your Project's CLAUDE.md&lt;/h3&gt;

&lt;p&gt;Add this section to your project's &lt;code&gt;CLAUDE.md&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;## Deep Research via Claude.ai&lt;/span&gt;

&lt;span class="hljs-keyword"&gt;When&lt;/span&gt; deep research is needed (not just web search), spawn a background agent:

  Spawn a background agent for web research: &lt;span class="hljs-string"&gt;"YOUR QUERY"&lt;/span&gt;

Or use the slash command:

  /research-via-web &lt;span class="hljs-string"&gt;"YOUR QUERY"&lt;/span&gt;

This opens Claude.ai via Chrome, toggles Research, runs the query, and 
saves results to ./docs/research/

CRITICAL: This MUST run as background agent. Takes 5 to 30 minutes. 
Do not skip or inline into other workflows.

&lt;span class="hljs-comment"&gt;### When to Use Research vs Web Search&lt;/span&gt;

|&lt;span class="hljs-string"&gt; Use Research &lt;/span&gt;|&lt;span class="hljs-string"&gt; Use Web Search &lt;/span&gt;|
|&lt;span class="hljs-string"&gt;--------------&lt;/span&gt;|&lt;span class="hljs-string"&gt;----------------&lt;/span&gt;|
|&lt;span class="hljs-string"&gt; Complex analysis &lt;/span&gt;|&lt;span class="hljs-string"&gt; Quick fact lookup &lt;/span&gt;|
|&lt;span class="hljs-string"&gt; Multi-source synthesis &lt;/span&gt;|&lt;span class="hljs-string"&gt; Single answer needed &lt;/span&gt;|
|&lt;span class="hljs-string"&gt; Comprehensive reports &lt;/span&gt;|&lt;span class="hljs-string"&gt; During active coding &lt;/span&gt;|
|&lt;span class="hljs-string"&gt; When citations matter &lt;/span&gt;|&lt;span class="hljs-string"&gt; Speed is priority &lt;/span&gt;|
&lt;/code&gt;&lt;/pre&gt;




&lt;h2 id="using-the-research-skill"&gt;Using the Research Skill&lt;/h2&gt;

&lt;h3 id="step-1-start-claude-code-with-chrome"&gt;Step 1: Start Claude Code with Chrome&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;claude &lt;span class="hljs-comment"&gt;--chrome&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You should see a message indicating the Chrome extension is connected.&lt;/p&gt;

&lt;h3 id="step-2-verify-connection"&gt;Step 2: Verify Connection&lt;/h3&gt;

&lt;p&gt;Type &lt;code&gt;/chrome&lt;/code&gt; in Claude Code to check the connection status. You should see the extension is detected and connected.&lt;/p&gt;

&lt;h3 id="step-3-run-a-research-task"&gt;Step 3: Run a Research Task&lt;/h3&gt;

&lt;p&gt;Option A - Natural language:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-built_in"&gt;Spawn&lt;/span&gt; a background &lt;span class="hljs-built_in"&gt;agent&lt;/span&gt; &lt;span class="hljs-keyword"&gt;to&lt;/span&gt; research via Claude.ai: &lt;span class="hljs-string"&gt;"What are the latest Laravel 12 features and breaking changes from Laravel 11?"&lt;/span&gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Option B - Slash command:&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;/research-via-web &lt;span class="hljs-comment"&gt;"What are the latest Laravel 12 features and breaking changes from Laravel 11?"&lt;/span&gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="step-4-send-to-background-if-needed-"&gt;Step 4: Send to Background (if needed)&lt;/h3&gt;

&lt;p&gt;If the task doesn't automatically run in the background, press &lt;code&gt;Ctrl+Shift+B&lt;/code&gt; to send it to the background.&lt;/p&gt;

&lt;h3 id="step-5-continue-working"&gt;Step 5: Continue Working&lt;/h3&gt;

&lt;p&gt;Your main Claude Code session is free. Continue coding, run other commands, or start another task.&lt;/p&gt;

&lt;h3 id="step-6-check-status"&gt;Step 6: Check Status&lt;/h3&gt;

&lt;p&gt;To see how your background agent is doing:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;/bashes&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or ask:&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-keyword"&gt;Show&lt;/span&gt; &lt;span class="hljs-keyword"&gt;status&lt;/span&gt; &lt;span class="hljs-keyword"&gt;of&lt;/span&gt; background agents&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id="step-7-review-results"&gt;Step 7: Review Results&lt;/h3&gt;

&lt;p&gt;When complete, the agent saves results to:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;.&lt;span class="hljs-regexp"&gt;/docs/&lt;/span&gt;research&lt;span class="hljs-regexp"&gt;/YYYYMMDD-HHMMSS-query-slug.md&lt;/span&gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can reference this file in your main session:&lt;/p&gt;
&lt;br&gt;
&lt;pre&gt;&lt;code&gt;@&lt;span class="hljs-keyword"&gt;docs&lt;/span&gt;/&lt;span class="hljs-keyword"&gt;research&lt;/span&gt;/&lt;span class="hljs-keyword"&gt;20260126&lt;/span&gt;-&lt;span class="hljs-keyword"&gt;143022&lt;/span&gt;-&lt;span class="hljs-keyword"&gt;laravel&lt;/span&gt;-&lt;span class="hljs-keyword"&gt;12&lt;/span&gt;-&lt;span class="hljs-keyword"&gt;features&lt;/span&gt;.&lt;span class="hljs-keyword"&gt;md&lt;/span&gt;&lt;br&gt;
Summarize the key breaking changes I need to handle for migration&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;h2 id="example-workflow"&gt;Example Workflow&lt;/h2&gt;

&lt;p&gt;Here's a real workflow for planning a Laravel 11 to 12 migration:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;span class="hljs-comment"&gt;# Start Claude Code with Chrome&lt;/span&gt;&lt;br&gt;
claude &lt;span class="hljs-comment"&gt;--chrome&lt;/span&gt;

&lt;p&gt;&lt;span&gt;# Spawn research on Laravel 12 changes&lt;/span&gt;&lt;br&gt;
&amp;gt; Spawn a background agent &lt;span&gt;to&lt;/span&gt; research via Claude.ai: &lt;span&gt;"Complete Laravel 12 migration guide from Laravel 11, including all breaking changes, deprecated features, and new requirements"&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;# Agent starts in background, you continue working&lt;/span&gt;&lt;br&gt;
&amp;gt; Review &lt;span&gt;my&lt;/span&gt; routes/web.php &lt;span&gt;for&lt;/span&gt; any deprecated patterns&lt;/p&gt;

&lt;p&gt;&lt;span&gt;# Check research progress&lt;/span&gt;&lt;br&gt;
&amp;gt; /bashes&lt;/p&gt;

&lt;p&gt;&lt;span&gt;# 20 minutes later, research completes&lt;/span&gt;&lt;br&gt;
&lt;span&gt;# Results saved to ./docs/research/20260126-laravel-12-migration.md&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;# Use the research in your work&lt;/span&gt;&lt;br&gt;
&amp;gt; @docs/research/&lt;span&gt;20260126&lt;/span&gt;-laravel&lt;span&gt;-12&lt;/span&gt;-migration.md&lt;br&gt;
&amp;gt; Based &lt;span&gt;on&lt;/span&gt; this research, create a migration checklist &lt;span&gt;for&lt;/span&gt; &lt;span&gt;my&lt;/span&gt; project&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;


&lt;h2 id="troubleshooting"&gt;Troubleshooting&lt;/h2&gt;

&lt;h3 id="-browser-extension-is-not-connected-"&gt;"Browser extension is not connected"&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Check if Chrome is running&lt;/li&gt;
&lt;li&gt;Check if extension is installed and signed in&lt;/li&gt;
&lt;li&gt;Run the native messaging fix (see Critical Fix section above)&lt;/li&gt;
&lt;li&gt;Restart Chrome completely (Cmd+Q)&lt;/li&gt;
&lt;li&gt;Try &lt;code&gt;claude --chrome&lt;/code&gt; again&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id="research-toggle-not-found"&gt;Research toggle not found&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ensure you have a paid Claude plan (Pro, Team, Max, or Enterprise)&lt;/li&gt;
&lt;li&gt;The Research toggle is at the bottom left of the Claude.ai chat interface&lt;/li&gt;
&lt;li&gt;Try manually verifying it exists by visiting claude.ai&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id="task-times-out"&gt;Task times out&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Research can legitimately take 30+ minutes for complex queries&lt;/li&gt;
&lt;li&gt;Don't interrupt the process&lt;/li&gt;
&lt;li&gt;If it fails, try a more specific query&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id="agent-skips-the-research-step"&gt;Agent skips the Research step&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you're running as a background agent&lt;/li&gt;
&lt;li&gt;The skill files must be installed correctly&lt;/li&gt;
&lt;li&gt;Check that CLAUDE.md includes the instruction to NOT skip Research&lt;/li&gt;
&lt;/ul&gt;




&lt;h2 id="why-this-matters"&gt;Why This Matters&lt;/h2&gt;

&lt;p&gt;This setup bridges a significant gap in Claude Code's capabilities. For developers making architectural decisions, evaluating technologies, or planning migrations, the difference between a 10-second web search and a 20-minute deep research session is the difference between a guess and an informed decision.&lt;/p&gt;

&lt;p&gt;The background agent approach means you don't have to choose between thoroughness and productivity. Start the research, continue your work, and integrate the findings when they're ready.&lt;/p&gt;

&lt;p&gt;It's Claude helping Claude help you.&lt;/p&gt;




&lt;h2 id="credits"&gt;Credits&lt;/h2&gt;

&lt;p&gt;Original idea by &lt;a href="https://x.com/EleanorKonik/status/2015454448600969635" rel="noopener noreferrer"&gt;@EleanorKonik&lt;/a&gt;. This article formalizes her concept into a working implementation.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>cli</category>
      <category>tooling</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>The Task Tool: Claude Code's Agent Orchestration System</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Tue, 27 Jan 2026 06:20:00 +0000</pubDate>
      <link>https://forem.com/bhaidar/the-task-tool-claude-codes-agent-orchestration-system-4bf2</link>
      <guid>https://forem.com/bhaidar/the-task-tool-claude-codes-agent-orchestration-system-4bf2</guid>
      <description>&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduction&lt;/li&gt;
&lt;li&gt;What is the Task Tool?&lt;/li&gt;
&lt;li&gt;How It Works&lt;/li&gt;
&lt;li&gt;Available Agent Types&lt;/li&gt;
&lt;li&gt;Background vs Foreground Execution&lt;/li&gt;
&lt;li&gt;When to Use Which Agent&lt;/li&gt;
&lt;li&gt;Practical Examples&lt;/li&gt;
&lt;li&gt;Managing Background Tasks&lt;/li&gt;
&lt;li&gt;Best Practices&lt;/li&gt;
&lt;li&gt;Common Patterns&lt;/li&gt;
&lt;li&gt;Troubleshooting&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;The Task tool is Claude Code's most powerful feature for handling complex, multi-step operations. Think of it as Claude's ability to spawn specialized "colleagues" - autonomous sub-agents that can work independently while you continue with other tasks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Insight&lt;/strong&gt;: Claude Code isn't just one AI - it's a system that can orchestrate multiple AI agents, each with specialized skills and tools, working in parallel or sequence to accomplish complex goals.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Task Tool?
&lt;/h2&gt;

&lt;p&gt;The Task tool is a function that allows Claude to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Spawn sub-agents&lt;/strong&gt;: Create separate Claude instances with specialized capabilities&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delegate work&lt;/strong&gt;: Assign specific tasks with detailed instructions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run autonomously&lt;/strong&gt;: Sub-agents work independently until task completion&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Execute in background&lt;/strong&gt;: Long-running tasks don't block your workflow&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Return results&lt;/strong&gt;: Completed work is reported back to the main session&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Architecture
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main Claude Session (You interact here)
    ↓
    ├─→ Task Tool invocation
    │       ↓
    │   Sub-Agent (Specialized Claude instance)
    │       ├─→ Has own context &amp;amp; memory
    │       ├─→ Access to specific tools
    │       ├─→ Works autonomously
    │       └─→ Returns results when done
    │
    └─→ You continue working (if background)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Basic Invocation
&lt;/h3&gt;

&lt;p&gt;When Claude calls the Task tool:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;general-purpose&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Short task description&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Detailed instructions for the sub-agent&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"run_in_background"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"model"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;haiku&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Optional: use faster model --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What Happens
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Agent Creation&lt;/strong&gt;: New Claude instance spawned with specified type&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context Loading&lt;/strong&gt;: Agent receives the prompt with all necessary instructions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Autonomous Execution&lt;/strong&gt;: Agent uses its available tools to complete the task&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result Reporting&lt;/strong&gt;: Agent returns findings/outputs to main session&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleanup&lt;/strong&gt;: Agent terminates after completion&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Key Parameters
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Required&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;subagent_type&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Which specialized agent to use&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;description&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;3-5 word summary of task&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prompt&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ Yes&lt;/td&gt;
&lt;td&gt;Detailed instructions for agent&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;run_in_background&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Run async (true) or blocking (false)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;model&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;sonnet&lt;/code&gt; (default), &lt;code&gt;opus&lt;/code&gt;, or &lt;code&gt;haiku&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;resume&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;❌ No&lt;/td&gt;
&lt;td&gt;Resume a previous agent by ID&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Available Agent Types
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. General-Purpose Agent
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tools Available&lt;/strong&gt;: All tools (Read, Write, Edit, Grep, Glob, Bash, WebFetch, WebSearch, etc.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Complex research tasks&lt;/li&gt;
&lt;li&gt;Multi-step file operations&lt;/li&gt;
&lt;li&gt;Web scraping and analysis&lt;/li&gt;
&lt;li&gt;Tasks requiring multiple tool types&lt;/li&gt;
&lt;li&gt;Open-ended exploration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- "Search the codebase for all API endpoints and document them"
- "Research best practices for implementing OAuth 2.0"
- "Find all TODO comments and create GitHub issues"
- "Analyze dependencies and identify outdated packages"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When Claude Uses It&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You ask for research that requires multiple searches&lt;/li&gt;
&lt;li&gt;Complex codebase analysis spanning many files&lt;/li&gt;
&lt;li&gt;Tasks that need both web research and code inspection&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Explore Agent
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tools Available&lt;/strong&gt;: Glob, Grep, LS, Read, NotebookRead, WebFetch, WebSearch (NO Edit/Write)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast codebase exploration&lt;/li&gt;
&lt;li&gt;Finding files by patterns&lt;/li&gt;
&lt;li&gt;Searching code for keywords&lt;/li&gt;
&lt;li&gt;Answering "where/how" questions about code&lt;/li&gt;
&lt;li&gt;Read-only analysis&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Thoroughness Levels&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;quick&lt;/code&gt;: Basic searches, first match priority&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;medium&lt;/code&gt;: Moderate exploration, multiple locations&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;very thorough&lt;/code&gt;: Comprehensive analysis, all possibilities&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- "Where are errors from the client handled?"
- "What is the codebase structure?"
- "Find all files that use the Authentication service"
- "How does the payment processing flow work?"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When Claude Uses It&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You ask exploratory questions about the codebase&lt;/li&gt;
&lt;li&gt;Need to understand architecture or flow&lt;/li&gt;
&lt;li&gt;Searching for patterns across many files&lt;/li&gt;
&lt;li&gt;Read-only investigation needed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: Faster than general-purpose for search tasks because it has fewer tools to consider.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Plan Agent
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tools Available&lt;/strong&gt;: All tools EXCEPT Task, ExitPlanMode, Edit, Write, NotebookEdit&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Designing implementation strategies&lt;/li&gt;
&lt;li&gt;Creating step-by-step plans&lt;/li&gt;
&lt;li&gt;Identifying critical files before coding&lt;/li&gt;
&lt;li&gt;Considering architectural trade-offs&lt;/li&gt;
&lt;li&gt;Planning complex features&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Workflow&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Agent explores codebase&lt;/li&gt;
&lt;li&gt;Analyzes existing patterns&lt;/li&gt;
&lt;li&gt;Designs implementation approach&lt;/li&gt;
&lt;li&gt;Returns detailed plan for approval&lt;/li&gt;
&lt;li&gt;Main Claude executes plan after approval&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- "Plan implementation of user authentication"
- "Design a strategy for migrating to a new database"
- "Create a refactoring plan for the API layer"
- "Plan how to add real-time notifications"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When Claude Uses It&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tasks require architectural decisions&lt;/li&gt;
&lt;li&gt;Multiple valid implementation approaches exist&lt;/li&gt;
&lt;li&gt;Large-scale changes affecting many files&lt;/li&gt;
&lt;li&gt;User explicitly enters "plan mode"&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  4. Bash Agent
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Tools Available&lt;/strong&gt;: Bash only&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git operations&lt;/li&gt;
&lt;li&gt;Command execution&lt;/li&gt;
&lt;li&gt;Terminal tasks&lt;/li&gt;
&lt;li&gt;Running scripts&lt;/li&gt;
&lt;li&gt;System operations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- "Run git operations to create a feature branch"
- "Execute npm install and build"
- "Run database migrations"
- "Clean up temporary files"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;When Claude Uses It&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Git-heavy workflows&lt;/li&gt;
&lt;li&gt;Command-line only operations&lt;/li&gt;
&lt;li&gt;No file reading/editing needed&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  5. Feature Development Agents
&lt;/h3&gt;

&lt;h4&gt;
  
  
  code-reviewer
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;: PR reviews, bug detection, security analysis, code quality&lt;/p&gt;

&lt;h4&gt;
  
  
  code-explorer
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;: Deep feature analysis, tracing execution paths, understanding dependencies&lt;/p&gt;

&lt;h4&gt;
  
  
  code-architect
&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;Best For&lt;/strong&gt;: Feature architecture design, implementation blueprints, build sequences&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Specialized Plugin Agents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;statusline-setup&lt;/strong&gt;: Configure Claude Code status line&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;claude-code-guide&lt;/strong&gt;: Answer questions about Claude Code features&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;agent-sdk-dev&lt;/strong&gt;: Verify Agent SDK applications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;plugin-dev&lt;/strong&gt;: Plugin creation and validation&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;code-simplifier&lt;/strong&gt;: Refactor code for clarity&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;laravel-simplifier&lt;/strong&gt;: PHP/Laravel specific refactoring&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Background vs Foreground Execution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Foreground (Default)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Behavior&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Blocks main session until completion&lt;/li&gt;
&lt;li&gt;You wait for results before continuing&lt;/li&gt;
&lt;li&gt;Claude pauses until agent finishes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use When&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Task takes &amp;lt;30 seconds&lt;/li&gt;
&lt;li&gt;You need results immediately to continue&lt;/li&gt;
&lt;li&gt;Task is prerequisite for next steps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Search for all API endpoints" (blocks for 10 seconds, returns results, you continue)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Background (&lt;code&gt;run_in_background: true&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Behavior&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Agent runs asynchronously&lt;/li&gt;
&lt;li&gt;You can continue with other work&lt;/li&gt;
&lt;li&gt;Notification when complete&lt;/li&gt;
&lt;li&gt;Output saved to file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Use When&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Task takes &amp;gt;1 minute&lt;/li&gt;
&lt;li&gt;You don't need results immediately&lt;/li&gt;
&lt;li&gt;Task is independent of current work&lt;/li&gt;
&lt;li&gt;Long-running operations (builds, tests, research)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Run comprehensive test suite" (launches in background, you continue coding, notified when done)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Request Background Execution
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;: Natural language&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Spawn a background agent to run web research for Laravel packages"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;: Keyboard shortcut&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Press Ctrl+Shift+B when invoking a task
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 3&lt;/strong&gt;: Explicit instruction&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Run this as a background task: analyze the entire codebase for security issues"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  When to Use Which Agent
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Decision Tree
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Do you need to WRITE or EDIT code?
├─ YES → general-purpose or feature-dev agents
└─ NO → Continue...

Is it codebase EXPLORATION?
├─ YES → Explore agent
└─ NO → Continue...

Is it PLANNING before implementation?
├─ YES → Plan agent
└─ NO → Continue...

Is it ONLY bash commands?
├─ YES → Bash agent
└─ NO → general-purpose agent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Quick Reference
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Task Type&lt;/th&gt;
&lt;th&gt;Agent&lt;/th&gt;
&lt;th&gt;Background?&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Find files/patterns&lt;/td&gt;
&lt;td&gt;Explore&lt;/td&gt;
&lt;td&gt;No (fast)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Answer code questions&lt;/td&gt;
&lt;td&gt;Explore&lt;/td&gt;
&lt;td&gt;No (fast)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web research&lt;/td&gt;
&lt;td&gt;general-purpose&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multi-file refactor&lt;/td&gt;
&lt;td&gt;general-purpose&lt;/td&gt;
&lt;td&gt;Maybe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Plan feature&lt;/td&gt;
&lt;td&gt;Plan&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Run tests&lt;/td&gt;
&lt;td&gt;Bash&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Build project&lt;/td&gt;
&lt;td&gt;Bash&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Code review&lt;/td&gt;
&lt;td&gt;code-reviewer&lt;/td&gt;
&lt;td&gt;Maybe&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security audit&lt;/td&gt;
&lt;td&gt;code-reviewer&lt;/td&gt;
&lt;td&gt;YES&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Practical Examples
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Example 1: Codebase Exploration
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Request&lt;/strong&gt;: "Where is authentication handled?"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude's Decision&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Explore&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Find authentication handling&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Search the codebase to find where authentication is handled.
    Look for:
    - Auth middleware
    - Login controllers
    - Authentication services
    - JWT/session handling

    Return file paths and brief descriptions.
  &lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Explore?&lt;/strong&gt;: Read-only search, no edits needed, fast results.&lt;/p&gt;




&lt;h3&gt;
  
  
  Example 2: Deep Web Research
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Request&lt;/strong&gt;: "/research-via-web 'Laravel latest packages'"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude's Decision&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;general-purpose&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Research Laravel packages&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"run_in_background"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Use Claude in Chrome to access claude.ai Research feature.

    Steps:
    1. Navigate to claude.ai
    2. Enable Research toggle
    3. Submit query: "Laravel latest packages 2026"
    4. Wait 5-30 minutes for completion
    5. Extract full results with citations
    6. Save to ./docs/research/[timestamp]-laravel-packages.md

    Return summary when complete.
  &lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why general-purpose + background?&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Needs browser automation tools&lt;/li&gt;
&lt;li&gt;Takes 5-30 minutes&lt;/li&gt;
&lt;li&gt;Complex multi-step workflow&lt;/li&gt;
&lt;li&gt;User can continue working&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example 3: Feature Planning
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Request&lt;/strong&gt;: "Add dark mode to the application"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude's Decision&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Plan&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Plan dark mode implementation&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Design an implementation plan for adding dark mode.

    Explore:
    - Current styling approach (CSS/Tailwind/CSS-in-JS)
    - Existing theme infrastructure
    - Components that need updates

    Plan:
    - Theme toggle component
    - State management approach
    - CSS variable strategy
    - Component modifications needed

    Return step-by-step implementation plan.
  &lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Plan?&lt;/strong&gt;: Architectural decision, multiple approaches possible, user should approve before implementation.&lt;/p&gt;




&lt;h3&gt;
  
  
  Example 4: Running Tests
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Request&lt;/strong&gt;: "Run the test suite"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude's Decision&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Bash&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Run test suite&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"run_in_background"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Execute the test suite:

    1. Run: npm test (or appropriate test command)
    2. Capture full output
    3. Report:
       - Pass/fail summary
       - Failed test details
       - Coverage metrics if available
  &lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why Bash + background?&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Command-line only&lt;/li&gt;
&lt;li&gt;May take several minutes&lt;/li&gt;
&lt;li&gt;User doesn't need to wait&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example 5: Security Review
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;User Request&lt;/strong&gt;: "Review this PR for security issues"&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Claude's Decision&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;code-reviewer&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Security review PR #123&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Review PR #123 for security vulnerabilities:

    Check for:
    - SQL injection risks
    - XSS vulnerabilities
    - Authentication bypasses
    - Insecure dependencies
    - Exposed secrets

    Use confidence-based filtering - only report high-priority issues.
  &lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why code-reviewer?&lt;/strong&gt;: Specialized for security analysis, confidence filtering, review workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing Background Tasks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  View All Tasks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;/tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Show status of all background agents
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Output&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Background Tasks:
- ac88940: Research Laravel packages (running, 18 min)
- ac88941: Run test suite (completed, 3 min ago)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Check Task Progress
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Option 1&lt;/strong&gt;: Read output file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Read /private/tmp/claude/-Users-you-project/tasks/ac88940.output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2&lt;/strong&gt;: Tail live output&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /private/tmp/claude/-Users-you-project/tasks/ac88940.output
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 3&lt;/strong&gt;: Wait for notification&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(Claude automatically notifies you when complete)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Kill a Task
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Kill background task ac88940
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use the KillShell tool if it's a Bash background task.&lt;/p&gt;




&lt;h3&gt;
  
  
  Resume a Task
&lt;/h3&gt;

&lt;p&gt;If a task was interrupted or you want to continue work:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;invoke&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"Task"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"subagent_type"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;general-purpose&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"resume"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;ac88940&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"prompt"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Continue from where you left off...&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/invoke&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use Case&lt;/strong&gt;: Agent hit rate limits, network issues, or you want to add follow-up instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Choose the Right Agent
&lt;/h3&gt;

&lt;p&gt;❌ &lt;strong&gt;Don't&lt;/strong&gt;: Use general-purpose for simple searches&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Find the User model" → general-purpose agent (overkill)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Do&lt;/strong&gt;: Use Explore for read-only searches&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Find the User model" → Explore agent (faster, appropriate)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Be Specific in Prompts
&lt;/h3&gt;

&lt;p&gt;❌ &lt;strong&gt;Don't&lt;/strong&gt;: Vague instructions&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Research authentication"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Do&lt;/strong&gt;: Detailed, structured prompts&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Research OAuth 2.0 implementation best practices for Laravel.
Include:
- Authorization code flow setup
- Token storage strategies
- Security considerations
- Popular Laravel packages
Provide code examples and cite sources."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Use Background for Long Tasks
&lt;/h3&gt;

&lt;p&gt;❌ &lt;strong&gt;Don't&lt;/strong&gt;: Block for minutes&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Run full test suite" → foreground (you wait 5 minutes)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Do&lt;/strong&gt;: Background long operations&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Run full test suite in background" → continue working, notified when done
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Rule of Thumb&lt;/strong&gt;: If task takes &amp;gt;30 seconds, run in background.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. Model Selection
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Sonnet (default)&lt;/strong&gt;: Best quality, moderate speed&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Complex tasks, code generation, architectural decisions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Haiku&lt;/strong&gt;: Fast, cost-effective&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Simple searches, quick analysis, repetitive tasks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Opus&lt;/strong&gt;: Maximum capability (rarely needed)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Extremely complex reasoning, critical decisions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;parameter&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"model"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;haiku&lt;span class="nt"&gt;&amp;lt;/parameter&amp;gt;&lt;/span&gt;  &lt;span class="c"&gt;&amp;lt;!-- For quick file search --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  5. Don't Nest Tasks Unnecessarily
&lt;/h3&gt;

&lt;p&gt;❌ &lt;strong&gt;Don't&lt;/strong&gt;: Task within task within task&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main → Task → Sub-Task → Sub-Sub-Task (complexity explosion)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Do&lt;/strong&gt;: Flatten when possible&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Main → Task with comprehensive instructions
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Exception&lt;/strong&gt;: Legitimate parallel work (e.g., Plan agent explores, then reports to main Claude who executes).&lt;/p&gt;




&lt;h3&gt;
  
  
  6. Provide Context
&lt;/h3&gt;

&lt;p&gt;Agents don't automatically see your full conversation history. Give them what they need:&lt;/p&gt;

&lt;p&gt;❌ &lt;strong&gt;Don't&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Fix the bug we discussed earlier"  (agent has no idea)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ &lt;strong&gt;Do&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"Fix the bug in src/api/users.js:45 where user.name is undefined.
Error: Cannot read property 'name' of undefined.
This happens when the API returns null for deleted users.
Add null check before accessing properties."
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Common Patterns
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pattern 1: Explore → Plan → Execute
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: "Add user authentication"

Step 1: Explore agent
  → Understand current auth infrastructure
  → Find related files
  → Identify patterns

Step 2: Plan agent
  → Design implementation strategy
  → Return plan for approval

Step 3: Main Claude
  → Execute approved plan
  → Write code
  → Run tests
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Pattern 2: Parallel Background Tasks
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: "Prepare for deployment"

Launch simultaneously:
- Background Task 1: Run test suite
- Background Task 2: Build production assets
- Background Task 3: Run security audit
- Background Task 4: Update dependencies

All complete → Review results → Deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Pattern 3: Research → Implement
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: "Implement rate limiting"

Step 1: general-purpose agent (background)
  → Research rate limiting strategies
  → Find Laravel packages
  → Best practices documentation

Step 2: Main Claude (after research completes)
  → Review research findings
  → Choose approach with user
  → Implement solution
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Pattern 4: Iterative Exploration
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;User: "How does the payment flow work?"

Step 1: Explore agent
  → Find PaymentController
  → Returns initial findings

Step 2: Explore agent (resume or new)
  → "Now trace what happens in PaymentService"
  → Returns service details

Step 3: Explore agent
  → "Check the webhook handlers"
  → Complete picture emerges
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Issue: Task Takes Too Long
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Symptoms&lt;/strong&gt;: Background task running for hours&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check output file: &lt;code&gt;tail -f /path/to/task.output&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Look for stuck browser operations, infinite loops, or waiting&lt;/li&gt;
&lt;li&gt;Kill and relaunch with refined prompt&lt;/li&gt;
&lt;li&gt;Use faster model (haiku) if appropriate&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Issue: Task Fails Immediately
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Symptoms&lt;/strong&gt;: Error returned right away&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Causes&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Missing required parameters&lt;/li&gt;
&lt;li&gt;Invalid agent type&lt;/li&gt;
&lt;li&gt;Malformed prompt&lt;/li&gt;
&lt;li&gt;Tool access restrictions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;: Check error message, verify agent has needed tools&lt;/p&gt;




&lt;h3&gt;
  
  
  Issue: Agent Can't Find Files
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Symptoms&lt;/strong&gt;: "No files found" despite files existing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Verify working directory in prompt&lt;/li&gt;
&lt;li&gt;Check file paths are correct&lt;/li&gt;
&lt;li&gt;Use absolute paths instead of relative&lt;/li&gt;
&lt;li&gt;Try different search patterns (glob vs grep)&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Issue: Background Task Not Notifying
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Symptoms&lt;/strong&gt;: Task completes but you don't see results&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Manually read output file&lt;/li&gt;
&lt;li&gt;Check &lt;code&gt;/tasks&lt;/code&gt; for completion status&lt;/li&gt;
&lt;li&gt;Verify &lt;code&gt;run_in_background: true&lt;/code&gt; was set&lt;/li&gt;
&lt;li&gt;Look in task output directory&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  Issue: Out of Context/Tokens
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Symptoms&lt;/strong&gt;: Agent fails with context limit error&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solutions&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Break task into smaller sub-tasks&lt;/li&gt;
&lt;li&gt;Use more specific search parameters&lt;/li&gt;
&lt;li&gt;Limit file reads to essential sections&lt;/li&gt;
&lt;li&gt;Use haiku model for smaller context&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Advanced Techniques
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Technique 1: Chained Agents
&lt;/h3&gt;

&lt;p&gt;Run agents sequentially where each builds on previous:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent 1 (Explore): Find all API endpoints → saves to api-list.md
Agent 2 (general-purpose): Read api-list.md, generate OpenAPI spec
Agent 3 (code-reviewer): Review OpenAPI spec for completeness
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Technique 2: Parallel Research
&lt;/h3&gt;

&lt;p&gt;Launch multiple research agents simultaneously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Background Agent 1: Research authentication methods
Background Agent 2: Research authorization patterns
Background Agent 3: Research session management

All complete → Synthesize findings → Choose approach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Technique 3: Recursive Exploration
&lt;/h3&gt;

&lt;p&gt;Agent explores, finds new areas, spawns new agents:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Explore Agent: "Map the application architecture"
  → Finds frontend/, backend/, mobile/
  → Reports back

Main Claude spawns 3 new Explore agents:
  → Agent A: Explore frontend/
  → Agent B: Explore backend/
  → Agent C: Explore mobile/

All report back → Main Claude synthesizes complete map
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Technique 4: Progressive Refinement
&lt;/h3&gt;

&lt;p&gt;Use agent results to refine next agent's instructions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Agent 1: "Find authentication code"
  → Returns 50 files

Agent 2: "Focus on JWT implementation in these 10 files: [list]"
  → Returns detailed JWT analysis

Agent 3: "Check these 3 security concerns in the JWT code: [specifics]"
  → Returns security audit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The Task tool transforms Claude Code from a helpful assistant into an orchestration system for autonomous AI agents. By understanding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Which agent to use&lt;/strong&gt; (Explore for searching, general-purpose for complex work, Plan for architecture)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;When to use background&lt;/strong&gt; (tasks &amp;gt;30 seconds, independent work)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How to write effective prompts&lt;/strong&gt; (specific, structured, with context)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Managing task lifecycle&lt;/strong&gt; (viewing, monitoring, killing, resuming)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can tackle increasingly complex workflows while maintaining productivity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaway&lt;/strong&gt;: Don't think of Claude Code as a single AI - think of it as a team of specialized AIs you can deploy in parallel to accomplish sophisticated goals.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Further Reading&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Claude Code documentation: &lt;a href="https://claude.com/code" rel="noopener noreferrer"&gt;https://claude.com/code&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Agent SDK for building custom agents&lt;/li&gt;
&lt;li&gt;Plugin development for extending agent capabilities&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>automation</category>
    </item>
    <item>
      <title>How to Properly Deprecate API Endpoints in Laravel</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Fri, 09 Jan 2026 10:01:29 +0000</pubDate>
      <link>https://forem.com/bhaidar/how-to-properly-deprecate-api-endpoints-in-laravel-2dp6</link>
      <guid>https://forem.com/bhaidar/how-to-properly-deprecate-api-endpoints-in-laravel-2dp6</guid>
      <description>&lt;p&gt;API evolution is inevitable. As your application grows, you'll need to phase out old endpoints while maintaining backward compatibility. But what happens when you need to deprecate only one HTTP method of an endpoint while keeping others active?&lt;/p&gt;

&lt;p&gt;In this post, I'll show you how to handle a common scenario: deprecating a GET request while keeping the POST request active on the same route, using the same controller.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine you have this route setup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // modules/Products/Routes/api.php
  Route::get('/products/{id}/export', ProductExportController::class)-&amp;gt;name('export');
  Route::post('/products/{id}/export', ProductExportController::class)-&amp;gt;name('export');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both routes use the same controller, but you want to deprecate the GET method while keeping POST active. Simply adding deprecation headers in the controller would affect both methods.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Proper Deprecation Matters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before diving into solutions, let's understand why this matters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Client Communication&lt;/strong&gt;: Consumers need advance notice to migrate&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Standards Compliance&lt;/strong&gt;: HTTP has standard headers for deprecation (Deprecation, Sunset)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring&lt;/strong&gt;: Track which clients still use deprecated endpoints&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Graceful Migration&lt;/strong&gt;: Avoid breaking production systems&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Solution 1: Separate Legacy Controller (Recommended)
&lt;/h2&gt;

&lt;p&gt;The cleanest approach is to create a dedicated controller for the deprecated endpoint that delegates to the main controller while adding deprecation headers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create the Legacy Controller
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // app/Http/Controllers/ProductExportLegacyController.php
  &amp;lt;?php

  namespace App\Http\Controllers;

  use Illuminate\Http\Request;

  class ProductExportLegacyController
  {
      public function __invoke(Request $request, $id)
      {
          // Delegate to the main controller
          $response = app(ProductExportController::class)($request, $id);

          // Add deprecation headers
          return $response
              -&amp;gt;header('Deprecation', 'true')
              -&amp;gt;header('Sunset', 'Sat, 01 Jun 2026 00:00:00 GMT')
              -&amp;gt;header('X-API-Warn', 'This endpoint is deprecated. Use POST /products/{id}/export instead');
      }
  }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Update Your Routes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // Deprecated GET endpoint
  Route::get('/products/{id}/export', ProductExportLegacyController::class)
      -&amp;gt;name('exportLegacy'); // DEPRECATED - Use POST instead

  // Active POST endpoint
  Route::post('/products/{id}/export', ProductExportController::class)
      -&amp;gt;name('export');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Clear separation of concerns&lt;/li&gt;
&lt;li&gt;✅ Easy to remove when deprecation period ends&lt;/li&gt;
&lt;li&gt;✅ No conditional logic in main controller&lt;/li&gt;
&lt;li&gt;✅ Self-documenting code&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution 2: Method-Aware Middleware
&lt;/h2&gt;

&lt;p&gt;If you prefer middleware, create one that checks the HTTP method before adding headers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Create the Middleware
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  php artisan make:middleware DeprecateGetMethod

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // app/Http/Middleware/DeprecateGetMethod.php
  &amp;lt;?php

  namespace App\Http\Middleware;

  use Closure;
  use Illuminate\Http\Request;

  class DeprecateGetMethod
  {
      public function handle(Request $request, Closure $next, ?string $sunset = null, ?string $message = null)
      {
          $response = $next($request);

          if ($request-&amp;gt;isMethod('GET')) {
              $response-&amp;gt;headers-&amp;gt;set('Deprecation', 'true');
              $response-&amp;gt;headers-&amp;gt;set('Sunset', $sunset ?? now()-&amp;gt;addMonths(6)-&amp;gt;toRfc7231String());

              if ($message) {
                  $response-&amp;gt;headers-&amp;gt;set('X-API-Warn', $message);
              }
          }

          return $response;
      }
  }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Register the Middleware
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // bootstrap/app.php or app/Http/Kernel.php
  protected $middlewareAliases = [
      // ... other middleware
      'deprecate.get' =&amp;gt; \App\Http\Middleware\DeprecateGetMethod::class,
  ];

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Apply to Route
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  Route::get('/products/{id}/export', ProductExportController::class)
      -&amp;gt;name('exportLegacy')
      -&amp;gt;middleware('deprecate.get:2026-06-01,Use POST method instead');

  Route::post('/products/{id}/export', ProductExportController::class)
      -&amp;gt;name('export');


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Reusable across multiple routes&lt;/li&gt;
&lt;li&gt;✅ Parameterized sunset date and message&lt;/li&gt;
&lt;li&gt;✅ Clean route definitions&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution 3: Generic Deprecation Middleware
&lt;/h2&gt;

&lt;p&gt;For maximum flexibility, create a middleware that works with any HTTP method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/Http/Middleware/DeprecateEndpoint.php
  &amp;lt;?php

  namespace App\Http\Middleware;

  use Closure;
  use Illuminate\Http\Request;

  class DeprecateEndpoint
  {
      public function handle(Request $request, Closure $next, ?string $methods = null, ?string $sunset = null, ?string $replacement = null)
      {
          $response = $next($request);

          // If no methods specified, deprecate all
          // If methods specified, only deprecate those methods
          $deprecatedMethods = $methods ? explode(',', strtoupper($methods)) : ['*'];

          if ($deprecatedMethods === ['*'] || in_array($request-&amp;gt;method(), $deprecatedMethods)) {
              $response-&amp;gt;headers-&amp;gt;set('Deprecation', 'true');
              $response-&amp;gt;headers-&amp;gt;set('Sunset', $sunset ?? now()-&amp;gt;addMonths(6)-&amp;gt;toRfc7231String());

              if ($replacement) {
                  $response-&amp;gt;headers-&amp;gt;set('Link', "&amp;lt;{$replacement}&amp;gt;; rel=\"alternate\"");
              }
          }

          return $response;
      }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // Deprecate only GET and DELETE methods
  Route::match(['get', 'delete'], '/products/{id}/export', ProductExportController::class)
      -&amp;gt;middleware('deprecated:GET|DELETE,2026-06-01,/api/v2/products/{id}/export');


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Understanding Deprecation Headers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's break down the HTTP headers we're using:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deprecation: true&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard: &lt;a href="https://datatracker.ietf.org/doc/draft-ietf-httpapi-deprecation-header/09/" rel="noopener noreferrer"&gt;https://datatracker.ietf.org/doc/draft-ietf-httpapi-deprecation-header/09/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Purpose: Indicates the endpoint is deprecated&lt;/li&gt;
&lt;li&gt;Client Action: Log warnings, alert developers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sunset: &lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard: &lt;a href="https://datatracker.ietf.org/doc/html/rfc8594" rel="noopener noreferrer"&gt;https://datatracker.ietf.org/doc/html/rfc8594&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Format: RFC 7231 date (e.g., Sat, 01 Jun 2026 00:00:00 GMT)&lt;/li&gt;
&lt;li&gt;Purpose: When the endpoint will be removed&lt;/li&gt;
&lt;li&gt;Client Action: Plan migration before this date&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;X-API-Warn: &lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard: Custom (common practice)&lt;/li&gt;
&lt;li&gt;Purpose: Human-readable deprecation message&lt;/li&gt;
&lt;li&gt;Client Action: Display to developers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Link: ; rel="alternate"&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Standard: &lt;a href="https://datatracker.ietf.org/doc/html/rfc8288" rel="noopener noreferrer"&gt;https://datatracker.ietf.org/doc/html/rfc8288&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Purpose: Points to replacement endpoint&lt;/li&gt;
&lt;li&gt;Client Action: Use this URL instead&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Document Everywhere
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; /**
   * @deprecated This GET endpoint is obsolete as of v2.5.0
   * Will be removed in v3.0.0 (June 2026)
   * Use POST /products/{id}/export instead
   */
  Route::get('/products/{id}/export', ProductExportLegacyController::class)
      -&amp;gt;name('exportLegacy');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Log Deprecated Usage
&lt;/h3&gt;

&lt;p&gt;Track who's still using deprecated endpoints:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public function __invoke(Request $request, $id)
  {
      Log::warning('Deprecated GET /products/export endpoint used', [
          'product_id' =&amp;gt; $id,
          'client_ip' =&amp;gt; $request-&amp;gt;ip(),
          'user_agent' =&amp;gt; $request-&amp;gt;userAgent(),
      ]);

      // ... rest of controller
  }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Communicate the Change
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Update API documentation&lt;/li&gt;
&lt;li&gt;Send email notifications to API consumers&lt;/li&gt;
&lt;li&gt;Add changelog entries&lt;/li&gt;
&lt;li&gt;Update OpenAPI/Swagger specs&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Set Realistic Sunset Dates
&lt;/h3&gt;

&lt;p&gt;Give clients enough time to migrate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minor changes: 3-6 months&lt;/li&gt;
&lt;li&gt;Major changes: 6-12 months&lt;/li&gt;
&lt;li&gt;Breaking changes: 12+ months&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  5. Version Your API
&lt;/h3&gt;

&lt;p&gt;Consider versioned routes for major changes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // Old version (deprecated)
  Route::prefix('v1')-&amp;gt;group(function () {
      Route::get('/products/{id}/export', ProductExportLegacyController::class);
  });

  // New version
  Route::prefix('v2')-&amp;gt;group(function () {
      Route::post('/products/{id}/export', ProductExportController::class);
  });

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Monitoring Deprecated Endpoints
&lt;/h2&gt;

&lt;p&gt;Create a simple monitoring system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/Http/Middleware/TrackDeprecatedUsage.php
  public function handle(Request $request, Closure $next)
  {
      $response = $next($request);

      if ($response-&amp;gt;headers-&amp;gt;has('Deprecation')) {
          event(new DeprecatedEndpointAccessed(
              endpoint: $request-&amp;gt;path(),
              method: $request-&amp;gt;method(),
              user: $request-&amp;gt;user(),
              ip: $request-&amp;gt;ip(),
          ));
      }

      return $response;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then create a dashboard or report:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // Track usage over time
  DB::table('deprecated_endpoint_usage')
      -&amp;gt;select('endpoint', DB::raw('count(*) as hits'))
      -&amp;gt;where('accessed_at', '&amp;gt;', now()-&amp;gt;subDays(30))
      -&amp;gt;groupBy('endpoint')
      -&amp;gt;get();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Removal Process
&lt;/h2&gt;

&lt;p&gt;When the sunset date arrives:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Final Warning Period (1-2 weeks before)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public function __invoke(Request $request, $id)
  {
      Log::critical('FINAL WARNING: Deprecated endpoint will be removed in 2 weeks', [
          'endpoint' =&amp;gt; $request-&amp;gt;path(),
          'removal_date' =&amp;gt; '2026-06-01',
      ]);

      // ... rest of controller
  }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Graceful Removal
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  // Return 410 Gone instead of 404 Not Found
  Route::get('/products/{id}/export', function () {
      return response()-&amp;gt;json([
          'message' =&amp;gt; 'This endpoint was removed on June 1, 2026',
          'replacement' =&amp;gt; 'POST /products/{id}/export',
          'documentation' =&amp;gt; 'https://docs.example.com/api/v2/products',
      ], 410);
  })-&amp;gt;name('exportRemoved');

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Complete Removal
&lt;/h3&gt;

&lt;p&gt;After a grace period (e.g., 3-6 months), remove the route entirely.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Deprecating specific HTTP methods on shared endpoints requires thoughtful implementation. The separate controller approach offers the best balance of clarity and maintainability, while middleware solutions provide reusability across your API.&lt;/p&gt;

&lt;p&gt;Remember:&lt;br&gt;
  ✅ Use standard HTTP headers&lt;br&gt;
  ✅ Provide clear migration paths&lt;br&gt;
  ✅ Give adequate notice&lt;br&gt;
  ✅ Monitor usage&lt;br&gt;
  ✅ Document everything&lt;/p&gt;

&lt;p&gt;Your API consumers will thank you for the smooth transition!&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Supercharge Your AI Coding Workflow: A Complete Guide to Git Worktrees with Claude Code</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Thu, 08 Jan 2026 11:59:09 +0000</pubDate>
      <link>https://forem.com/bhaidar/supercharge-your-ai-coding-workflow-a-complete-guide-to-git-worktrees-with-claude-code-60m</link>
      <guid>https://forem.com/bhaidar/supercharge-your-ai-coding-workflow-a-complete-guide-to-git-worktrees-with-claude-code-60m</guid>
      <description>&lt;p&gt;In the age of AI assisted development, our workflows are evolving rapidly. Tools like Claude Code are transforming how we write, refactor, and debug code. But with this power comes a new challenge: how do we safely let an AI agent make substantial changes to our codebase while maintaining control and continuing our own work? Enter Git worktrees, a powerful yet underutilized feature that pairs exceptionally well with AI coding assistants.&lt;/p&gt;

&lt;p&gt;This guide will take you from worktree basics to advanced workflows specifically designed for AI assisted development. Whether you're a seasoned developer or just starting to integrate AI into your workflow, you'll find practical strategies to boost your productivity while maintaining code quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are Git Worktrees?
&lt;/h2&gt;

&lt;p&gt;Git worktrees allow you to have multiple working directories attached to the same repository simultaneously. Think of them as parallel universes for your codebase, each checked out to a different branch, but all sharing the same Git history and object database.&lt;/p&gt;

&lt;p&gt;Unlike cloning a repository multiple times (which duplicates everything), worktrees are lightweight. They share the &lt;code&gt;.git&lt;/code&gt; directory with your main working copy, meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No duplicate repository data eating up disk space&lt;/li&gt;
&lt;li&gt;All worktrees stay synchronized with the same remote&lt;/li&gt;
&lt;li&gt;Commits made in any worktree are immediately visible to all others&lt;/li&gt;
&lt;li&gt;Branch operations in one worktree affect the shared repository&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Traditional Problem
&lt;/h3&gt;

&lt;p&gt;Before worktrees, if you needed to work on multiple branches simultaneously, you had limited options:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stash and switch&lt;/strong&gt;: Constantly stashing your work, switching branches, then unstashing. This is error prone and disruptive.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple clones&lt;/strong&gt;: Cloning the repository multiple times. This wastes disk space and creates synchronization headaches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Just deal with it&lt;/strong&gt;: Finishing one task completely before starting another. This kills productivity when you're blocked or need to context switch.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Worktree Solution
&lt;/h3&gt;

&lt;p&gt;Worktrees eliminate these compromises. You can have your &lt;code&gt;main&lt;/code&gt; branch checked out in one directory, your &lt;code&gt;feature/authentication&lt;/code&gt; branch in another, and a &lt;code&gt;bugfix/login-error&lt;/code&gt; branch in a third, all simultaneously accessible and all sharing the same repository.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/                    # Main worktree (main branch)
my-project-feature-auth/       # Worktree for authentication feature
my-project-bugfix-login/       # Worktree for login bugfix
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each directory is a fully functional working copy. You can open them in separate IDE windows, run different dev servers, and switch between them instantly by simply changing directories.&lt;/p&gt;

&lt;h2&gt;
  
  
  Git Worktree Commands: The Complete Reference
&lt;/h2&gt;

&lt;p&gt;Before diving into AI specific workflows, let's master the worktree commands you'll use daily.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating Worktrees
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Create a worktree for an existing branch:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../my-project-feature ../path/to/worktree branch-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a worktree with a new branch:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; new-branch-name ../path/to/worktree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a worktree based on a specific commit or tag:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add ../path/to/worktree commit-hash
git worktree add ../path/to/worktree v1.2.3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Create a detached HEAD worktree (useful for exploration):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add &lt;span class="nt"&gt;--detach&lt;/span&gt; ../path/to/worktree HEAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Listing Worktrees
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;View all worktrees:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This outputs something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/home/user/projects/my-app           abc1234 [main]
/home/user/projects/my-app-feature   def5678 [feature/new-ui]
/home/user/projects/my-app-bugfix    ghi9012 [bugfix/login]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Get detailed information:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree list &lt;span class="nt"&gt;--porcelain&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Removing Worktrees
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Remove a worktree (the safe way):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree remove ../path/to/worktree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Force remove (if there are uncommitted changes):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree remove &lt;span class="nt"&gt;--force&lt;/span&gt; ../path/to/worktree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Clean up stale worktree references:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you manually delete a worktree directory, Git still tracks it. Clean up with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree prune
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Moving and Repairing Worktrees
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Move a worktree to a new location:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree move ../old/path ../new/path
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Repair worktree references after moving the main repository:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree repair
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Locking Worktrees
&lt;/h3&gt;

&lt;p&gt;Prevent a worktree from being pruned (useful for worktrees on removable drives):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree lock ../path/to/worktree
git worktree lock &lt;span class="nt"&gt;--reason&lt;/span&gt; &lt;span class="s2"&gt;"On external backup drive"&lt;/span&gt; ../path/to/worktree
git worktree unlock ../path/to/worktree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why Worktrees Are Perfect for AI Assisted Development
&lt;/h2&gt;

&lt;p&gt;Now let's explore why worktrees and AI coding assistants are a match made in developer heaven.&lt;/p&gt;

&lt;h3&gt;
  
  
  The AI Agent Challenge
&lt;/h3&gt;

&lt;p&gt;When you're using an AI coding tool like Claude Code, you're essentially giving an intelligent agent access to modify your files. This creates unique challenges:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Concurrent work&lt;/strong&gt;: While the AI is refactoring your authentication module, you might want to continue working on the UI. Without worktrees, you're blocked.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Experimentation safety&lt;/strong&gt;: AI suggestions might be brilliant or they might break everything. You need a safe space to evaluate them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Context preservation&lt;/strong&gt;: If the AI's changes don't work out, reverting shouldn't disrupt your other work.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multiple AI tasks&lt;/strong&gt;: You might want to run multiple AI assisted tasks in parallel, each exploring different approaches.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  The Worktree Advantage
&lt;/h3&gt;

&lt;p&gt;Worktrees solve all these problems elegantly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Isolation&lt;/strong&gt;: AI changes happen in a separate directory. Your main work is untouched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallelism&lt;/strong&gt;: Run multiple AI tasks simultaneously in different worktrees.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy comparison&lt;/strong&gt;: Diff between worktrees to evaluate AI suggestions against your original code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Zero risk experimentation&lt;/strong&gt;: Delete a worktree and its branch if the AI's approach doesn't pan out.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Continuous productivity&lt;/strong&gt;: Keep working in your main worktree while AI processes in another.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting Up a Worktree Based AI Workflow
&lt;/h2&gt;

&lt;p&gt;Let's build a practical workflow from the ground up.&lt;/p&gt;

&lt;h3&gt;
  
  
  Project Structure
&lt;/h3&gt;

&lt;p&gt;I recommend organizing your worktrees in a consistent pattern. Here's a structure that works well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/projects/
├── my-app/                      # Main worktree (main/develop branch)
├── my-app-ai-refactor/          # AI working on refactoring task
├── my-app-ai-feature/           # AI implementing new feature
└── my-app-ai-experiment/        # AI exploring experimental approach
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why Use Helper Scripts?
&lt;/h3&gt;

&lt;p&gt;While you can create and remove worktrees manually with Git commands, helper scripts provide several important benefits when working with AI assistants:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Consistency&lt;/strong&gt;: When you're creating multiple worktrees throughout the day for different AI tasks, it's easy to make typos or forget your naming convention. Scripts enforce a consistent pattern every time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Reduced cognitive load&lt;/strong&gt;: Instead of remembering the exact syntax for worktree commands, branch naming patterns, and directory paths, you just run one command with a task name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error prevention&lt;/strong&gt;: The scripts include validation to prevent common mistakes like forgetting to specify a task name or accidentally deleting the wrong worktree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Onboarding&lt;/strong&gt;: If you work on a team, scripts make it easy for everyone to follow the same workflow without memorizing commands.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation&lt;/strong&gt;: The scripts themselves serve as documentation for your workflow. New team members can read them to understand the process.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where to Save Your Scripts
&lt;/h3&gt;

&lt;p&gt;You have several options for where to store these scripts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Option 1: In your project repository&lt;/strong&gt; (recommended for team workflows)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;my-project/
├── scripts/
│   ├── create-ai-worktree.sh
│   └── cleanup-ai-worktree.sh
├── src/
└── ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 2: In your home directory&lt;/strong&gt; (recommended for personal use across projects)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;~/bin/
├── create-ai-worktree.sh
└── cleanup-ai-worktree.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If using &lt;code&gt;~/bin/&lt;/code&gt;, make sure it's in your PATH by adding this to your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Option 3: As Git aliases&lt;/strong&gt; (covered later in the Advanced section)&lt;/p&gt;

&lt;h3&gt;
  
  
  The Creation Script
&lt;/h3&gt;

&lt;p&gt;This script automates the creation of a new worktree specifically for AI assisted tasks:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# create-ai-worktree.sh&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Purpose: Creates a new Git worktree with a standardized naming convention&lt;/span&gt;
&lt;span class="c"&gt;#          for AI assisted development tasks.&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Usage: ./create-ai-worktree.sh &amp;lt;task-name&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;# Example: ./create-ai-worktree.sh refactor-auth&lt;/span&gt;

&lt;span class="c"&gt;# Get the project name from the Git repository root directory name&lt;/span&gt;
&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--show-toplevel&lt;/span&gt;&lt;span class="si"&gt;))&lt;/span&gt;

&lt;span class="c"&gt;# Get the task name from the first argument&lt;/span&gt;
&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;

&lt;span class="c"&gt;# Build standardized names for the branch and worktree directory&lt;/span&gt;
&lt;span class="nv"&gt;BRANCH_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ai/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;WORKTREE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"../&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-ai-&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Validate that a task name was provided&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TASK_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: create-ai-worktree.sh &amp;lt;task-name&amp;gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Examples:"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  create-ai-worktree.sh payment-integration"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  create-ai-worktree.sh refactor-auth"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  create-ai-worktree.sh bug-fix-login"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Check if the branch already exists&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;git show-ref &lt;span class="nt"&gt;--verify&lt;/span&gt; &lt;span class="nt"&gt;--quiet&lt;/span&gt; &lt;span class="s2"&gt;"refs/heads/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;BRANCH_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Branch '&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;BRANCH_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;' already exists."&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Either delete it first or choose a different task name."&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Create the new branch and worktree simultaneously&lt;/span&gt;
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BRANCH_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Provide helpful output&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=========================================="&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"AI Worktree Created Successfully!"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=========================================="&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Worktree location: &lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Branch name:       &lt;/span&gt;&lt;span class="nv"&gt;$BRANCH_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Next steps:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  1. cd &lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  2. Install dependencies (composer install, npm install, etc.)"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  3. Launch Claude Code: claude"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"When finished:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  cleanup-ai-worktree.sh &lt;/span&gt;&lt;span class="nv"&gt;$TASK_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  The Cleanup Script
&lt;/h3&gt;

&lt;p&gt;This companion script safely removes a worktree and its associated branch when you're done:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="c"&gt;# cleanup-ai-worktree.sh&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Purpose: Safely removes an AI worktree and its associated branch.&lt;/span&gt;
&lt;span class="c"&gt;#          Includes confirmation to prevent accidental deletion.&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Usage: ./cleanup-ai-worktree.sh &amp;lt;task-name&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;# Example: ./cleanup-ai-worktree.sh refactor-auth&lt;/span&gt;

&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--show-toplevel&lt;/span&gt;&lt;span class="si"&gt;))&lt;/span&gt;
&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
&lt;span class="nv"&gt;BRANCH_NAME&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"ai/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nv"&gt;WORKTREE_PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"../&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;PROJECT_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-ai-&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;TASK_NAME&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

&lt;span class="c"&gt;# Validate that a task name was provided&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-z&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$TASK_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Usage: cleanup-ai-worktree.sh &amp;lt;task-name&amp;gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current AI worktrees:"&lt;/span&gt;
    git worktree list | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\-&lt;/span&gt;&lt;span class="s2"&gt;ai&lt;/span&gt;&lt;span class="se"&gt;\-&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Check if the worktree exists&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt; &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Error: Worktree not found at &lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Current worktrees:"&lt;/span&gt;
    git worktree list
    &lt;span class="nb"&gt;exit &lt;/span&gt;1
&lt;span class="k"&gt;fi&lt;/span&gt;

&lt;span class="c"&gt;# Show what will be deleted and ask for confirmation&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"This will remove:"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Worktree: &lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"  Branch:   &lt;/span&gt;&lt;span class="nv"&gt;$BRANCH_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="c"&gt;# Check for uncommitted changes&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;git status &lt;span class="nt"&gt;--porcelain&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"WARNING: This worktree has uncommitted changes!"&lt;/span&gt;
    git status &lt;span class="nt"&gt;--short&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
&lt;span class="k"&gt;fi
&lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; - &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null

&lt;span class="nb"&gt;read&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Are you sure you want to continue? (y/n) "&lt;/span&gt; &lt;span class="nt"&gt;-n&lt;/span&gt; 1 &lt;span class="nt"&gt;-r&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;[[&lt;/span&gt; &lt;span class="nv"&gt;$REPLY&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;~ ^[Yy]&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="o"&gt;]]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;then&lt;/span&gt;
    &lt;span class="c"&gt;# Remove the worktree&lt;/span&gt;
    git worktree remove &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$WORKTREE_PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="nt"&gt;--force&lt;/span&gt;

    &lt;span class="c"&gt;# Remove the branch&lt;/span&gt;
    git branch &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$BRANCH_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Successfully cleaned up: &lt;/span&gt;&lt;span class="nv"&gt;$TASK_NAME&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;else
    &lt;/span&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Cleanup cancelled."&lt;/span&gt;
&lt;span class="k"&gt;fi&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Installing and Using the Scripts
&lt;/h3&gt;

&lt;p&gt;Follow these steps to set up the scripts on your system:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create the scripts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;bin&lt;/code&gt; directory in your home folder if it doesn't exist:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; ~/bin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the creation script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/bin/create-ai-worktree.sh
&lt;span class="c"&gt;# Paste the script content, save and exit (Ctrl+X, Y, Enter)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the cleanup script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;nano ~/bin/cleanup-ai-worktree.sh
&lt;span class="c"&gt;# Paste the script content, save and exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Make them executable&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/bin/create-ai-worktree.sh
&lt;span class="nb"&gt;chmod&lt;/span&gt; +x ~/bin/cleanup-ai-worktree.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Add to your PATH&lt;/strong&gt; (if not already done)&lt;/p&gt;

&lt;p&gt;Add this line to your &lt;code&gt;~/.bashrc&lt;/code&gt; or &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;PATH&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/bin:&lt;/span&gt;&lt;span class="nv"&gt;$PATH&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then reload your shell configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; ~/.bashrc  &lt;span class="c"&gt;# or source ~/.zshrc&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Use them in any Git repository&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Navigate to any project&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/projects/my-laravel-app

&lt;span class="c"&gt;# Create an AI worktree for a payment feature&lt;/span&gt;
create-ai-worktree.sh payment-processing

&lt;span class="c"&gt;# Output:&lt;/span&gt;
&lt;span class="c"&gt;# ==========================================&lt;/span&gt;
&lt;span class="c"&gt;# AI Worktree Created Successfully!&lt;/span&gt;
&lt;span class="c"&gt;# ==========================================&lt;/span&gt;
&lt;span class="c"&gt;#&lt;/span&gt;
&lt;span class="c"&gt;# Worktree location: ../my-laravel-app-ai-payment-processing&lt;/span&gt;
&lt;span class="c"&gt;# Branch name:       ai/payment-processing&lt;/span&gt;
&lt;span class="c"&gt;# ...&lt;/span&gt;

&lt;span class="c"&gt;# Navigate to the new worktree&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-laravel-app-ai-payment-processing

&lt;span class="c"&gt;# Do your AI assisted work...&lt;/span&gt;

&lt;span class="c"&gt;# When done, return to main project and clean up&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-laravel-app
cleanup-ai-worktree.sh payment-processing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Practical Example: Complete Workflow
&lt;/h3&gt;

&lt;p&gt;Here's a real world example showing the scripts in action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# You're working on your Laravel project&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ~/projects/invoice-app
git status
&lt;span class="c"&gt;# On branch main, everything clean&lt;/span&gt;

&lt;span class="c"&gt;# You want Claude Code to implement a PDF export feature&lt;/span&gt;
create-ai-worktree.sh pdf-export

&lt;span class="c"&gt;# Output shows the worktree was created at ../invoice-app-ai-pdf-export&lt;/span&gt;

&lt;span class="c"&gt;# Move to the AI worktree&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../invoice-app-ai-pdf-export

&lt;span class="c"&gt;# Install dependencies (worktrees don't share node_modules or vendor)&lt;/span&gt;
composer &lt;span class="nb"&gt;install
&lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Start Claude Code and give it the task&lt;/span&gt;
claude

&lt;span class="c"&gt;# ... Claude Code implements the PDF export feature ...&lt;/span&gt;
&lt;span class="c"&gt;# ... You review the changes, run tests, make adjustments ...&lt;/span&gt;

&lt;span class="c"&gt;# Happy with the result? Commit and merge&lt;/span&gt;
git add &lt;span class="nb"&gt;.&lt;/span&gt;
git commit &lt;span class="nt"&gt;-m&lt;/span&gt; &lt;span class="s2"&gt;"feat: implement PDF export for invoices"&lt;/span&gt;

&lt;span class="c"&gt;# Return to main project&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../invoice-app

&lt;span class="c"&gt;# Merge the AI's work&lt;/span&gt;
git merge ai/pdf-export

&lt;span class="c"&gt;# Clean up the worktree and branch&lt;/span&gt;
cleanup-ai-worktree.sh pdf-export

&lt;span class="c"&gt;# Done! The PDF export feature is now in your main branch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This workflow keeps your main development environment clean, lets you experiment freely, and makes it trivial to discard failed experiments or merge successful ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real World Workflow: AI Assisted Feature Development
&lt;/h2&gt;

&lt;p&gt;Let's walk through a complete example of using worktrees with Claude Code to implement a new feature.&lt;/p&gt;

&lt;h3&gt;
  
  
  Scenario
&lt;/h3&gt;

&lt;p&gt;You're building a Laravel application and need to implement a new payment processing feature. You want Claude Code to scaffold the initial implementation while you continue working on unrelated bug fixes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create the AI Worktree
&lt;/h3&gt;

&lt;p&gt;From your main project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a worktree for the AI to work in&lt;/span&gt;
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; feature/payment-processing ../my-app-ai-payments

&lt;span class="c"&gt;# Verify it was created&lt;/span&gt;
git worktree list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Set Up the AI Environment
&lt;/h3&gt;

&lt;p&gt;Navigate to the new worktree and ensure it's ready:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-payments

&lt;span class="c"&gt;# Install dependencies (they're not shared between worktrees)&lt;/span&gt;
composer &lt;span class="nb"&gt;install
&lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# Copy environment file if needed&lt;/span&gt;
&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
php artisan key:generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Launch Claude Code in the AI Worktree
&lt;/h3&gt;

&lt;p&gt;Open Claude Code in the AI worktree directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now give Claude Code your task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;I need you to implement a payment processing system for this Laravel application. 

Requirements:
* Create a PaymentService class that integrates with Stripe
* Add a PaymentController with endpoints for creating and confirming payments
* Create the necessary migrations for storing payment records
* Add appropriate form requests for validation
* Write feature tests for the payment flow

Please implement this step by step, creating each component and explaining your decisions.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 4: Continue Your Own Work
&lt;/h3&gt;

&lt;p&gt;While Claude Code works in the payment worktree, switch back to your main worktree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Continue your bug fixes, completely unaffected by whatever Claude Code is doing in the other directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 5: Review AI Changes
&lt;/h3&gt;

&lt;p&gt;Once Claude Code completes its task, review what it created:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# See what files were changed/created&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-payments
git status

&lt;span class="c"&gt;# Review the diff&lt;/span&gt;
git diff main

&lt;span class="c"&gt;# Or compare specific files&lt;/span&gt;
diff ../my-app/app/Services/ ./app/Services/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Test in Isolation
&lt;/h3&gt;

&lt;p&gt;Run tests in the AI worktree to validate the implementation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-payments
php artisan &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--filter&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;Payment
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 7: Merge or Iterate
&lt;/h3&gt;

&lt;p&gt;If you're satisfied with the AI's work:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Switch to main worktree&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app

&lt;span class="c"&gt;# Merge the AI's branch&lt;/span&gt;
git merge feature/payment-processing

&lt;span class="c"&gt;# Clean up&lt;/span&gt;
git worktree remove ../my-app-ai-payments
git branch &lt;span class="nt"&gt;-d&lt;/span&gt; feature/payment-processing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you need changes, either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Return to the AI worktree and continue prompting Claude Code&lt;/li&gt;
&lt;li&gt;Make manual adjustments in the AI worktree before merging&lt;/li&gt;
&lt;li&gt;Discard and start fresh with a new approach&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Advanced Workflow: Parallel AI Exploration
&lt;/h2&gt;

&lt;p&gt;Sometimes you want the AI to explore multiple approaches simultaneously. Worktrees make this trivial.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Multi Path Strategy
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create three worktrees for different approaches&lt;/span&gt;
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; ai/payments-stripe ../my-app-ai-stripe
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; ai/payments-square ../my-app-ai-square
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; ai/payments-braintree ../my-app-ai-braintree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open Claude Code in each worktree with different prompts:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stripe worktree&lt;/strong&gt;: "Implement payment processing using Stripe's Payment Intents API..."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Square worktree&lt;/strong&gt;: "Implement payment processing using Square's Web Payments SDK..."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Braintree worktree&lt;/strong&gt;: "Implement payment processing using Braintree's Drop-in UI..."&lt;/p&gt;

&lt;h3&gt;
  
  
  Comparing Results
&lt;/h3&gt;

&lt;p&gt;After all three implementations are complete:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Compare code structure&lt;/span&gt;
diff &lt;span class="nt"&gt;-r&lt;/span&gt; ../my-app-ai-stripe/app/Services ../my-app-ai-square/app/Services

&lt;span class="c"&gt;# Compare test coverage&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-stripe &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--coverage&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-square &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--coverage&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app-ai-braintree &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; php artisan &lt;span class="nb"&gt;test&lt;/span&gt; &lt;span class="nt"&gt;--coverage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Selecting the Winner
&lt;/h3&gt;

&lt;p&gt;Once you've evaluated all approaches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Merge your preferred implementation&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../my-app
git merge ai/payments-stripe

&lt;span class="c"&gt;# Clean up all AI worktrees&lt;/span&gt;
git worktree remove ../my-app-ai-stripe
git worktree remove ../my-app-ai-square
git worktree remove ../my-app-ai-braintree

&lt;span class="c"&gt;# Remove branches&lt;/span&gt;
git branch &lt;span class="nt"&gt;-D&lt;/span&gt; ai/payments-stripe ai/payments-square ai/payments-braintree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices for AI Worktree Workflows
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Naming Conventions
&lt;/h3&gt;

&lt;p&gt;Establish clear naming patterns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Worktree directories&lt;/strong&gt;: &lt;code&gt;{project}-ai-{task}&lt;/code&gt; or &lt;code&gt;{project}-{branch-type}-{description}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branch names&lt;/strong&gt;: &lt;code&gt;ai/{task-name}&lt;/code&gt; or &lt;code&gt;ai/{date}/{task-name}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This makes it easy to identify AI related work and clean up when done.&lt;/p&gt;

&lt;h3&gt;
  
  
  Commit Hygiene in AI Worktrees
&lt;/h3&gt;

&lt;p&gt;Instruct your AI to commit frequently with meaningful messages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;As you implement this feature, please commit your changes at logical 
checkpoints with clear commit messages that explain what was done and why. 
Use conventional commit format (feat:, fix:, refactor:, etc.).
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives you granular control when reviewing and the ability to cherry pick specific changes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Regular Cleanup
&lt;/h3&gt;

&lt;p&gt;AI experimentation can leave orphaned worktrees. Schedule regular cleanup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# List all worktrees&lt;/span&gt;
git worktree list

&lt;span class="c"&gt;# Prune any that were manually deleted&lt;/span&gt;
git worktree prune

&lt;span class="c"&gt;# Remove stale AI branches&lt;/span&gt;
git branch &lt;span class="nt"&gt;--list&lt;/span&gt; &lt;span class="s1"&gt;'ai/*'&lt;/span&gt; | xargs &lt;span class="nt"&gt;-n&lt;/span&gt; 1 git branch &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Environment Variables and Secrets
&lt;/h3&gt;

&lt;p&gt;Never let AI worktrees contain real credentials:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;.env.example&lt;/code&gt; files with placeholder values&lt;/li&gt;
&lt;li&gt;Create a specific &lt;code&gt;.env.ai&lt;/code&gt; template for AI worktrees&lt;/li&gt;
&lt;li&gt;Add AI worktree patterns to &lt;code&gt;.gitignore&lt;/code&gt; if they might contain sensitive data
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# .gitignore&lt;/span&gt;
.env
.env.ai
&lt;span class="k"&gt;**&lt;/span&gt;/my-app-ai-&lt;span class="k"&gt;*&lt;/span&gt;/.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  IDE Configuration
&lt;/h3&gt;

&lt;p&gt;If you use VS Code, create a workspace file to manage multiple worktrees:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"folders"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Main Development"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./my-app"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"AI: Payment Feature"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./my-app-ai-payments"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"AI: Refactoring"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"path"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"./my-app-ai-refactor"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"settings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"files.exclude"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"**/node_modules"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"**/vendor"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Troubleshooting Common Issues
&lt;/h2&gt;

&lt;h3&gt;
  
  
  "fatal: 'branch-name' is already checked out"
&lt;/h3&gt;

&lt;p&gt;Git prevents the same branch from being checked out in multiple worktrees. Solutions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Create a new branch instead&lt;/span&gt;
git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; new-branch-name ../path

&lt;span class="c"&gt;# Or detach HEAD in the blocking worktree first&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; ../blocking-worktree
git checkout &lt;span class="nt"&gt;--detach&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Worktree Shows Outdated Code
&lt;/h3&gt;

&lt;p&gt;If your AI worktree doesn't reflect recent commits from another worktree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ../ai-worktree
git fetch origin
git rebase origin/main  &lt;span class="c"&gt;# or merge, depending on your preference&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Dependencies Not Working
&lt;/h3&gt;

&lt;p&gt;Each worktree needs its own installed dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Laravel&lt;/span&gt;
composer &lt;span class="nb"&gt;install
&lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# SPFx&lt;/span&gt;
npm &lt;span class="nb"&gt;install&lt;/span&gt;

&lt;span class="c"&gt;# ASP.NET Core&lt;/span&gt;
dotnet restore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Large Repository, Slow Worktree Creation
&lt;/h3&gt;

&lt;p&gt;For very large repositories, worktree creation can be slow. Use sparse checkout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git worktree add &lt;span class="nt"&gt;--no-checkout&lt;/span&gt; ../sparse-worktree branch-name
&lt;span class="nb"&gt;cd&lt;/span&gt; ../sparse-worktree
git sparse-checkout init &lt;span class="nt"&gt;--cone&lt;/span&gt;
git sparse-checkout &lt;span class="nb"&gt;set &lt;/span&gt;src/relevant-folder
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Integrating with Your Development Workflow
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Git Aliases for Common Operations
&lt;/h3&gt;

&lt;p&gt;Add these to your &lt;code&gt;.gitconfig&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[alias]&lt;/span&gt;
    &lt;span class="c"&gt;# List worktrees with better formatting
&lt;/span&gt;    &lt;span class="py"&gt;wt&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;worktree list&lt;/span&gt;

    &lt;span class="c"&gt;# Create AI worktree quickly
&lt;/span&gt;    &lt;span class="py"&gt;wt-ai&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"!f() { git worktree add -b ai/$1 ../$(basename $(pwd))-ai-$1; }; f"&lt;/span&gt;

    &lt;span class="c"&gt;# Remove AI worktree and branch
&lt;/span&gt;    &lt;span class="py"&gt;wt-ai-rm&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"!f() { git worktree remove ../$(basename $(pwd))-ai-$1 &amp;amp;&amp;amp; git branch -D ai/$1; }; f"&lt;/span&gt;

    &lt;span class="c"&gt;# Prune and clean
&lt;/span&gt;    &lt;span class="py"&gt;wt-clean&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"!git worktree prune &amp;amp;&amp;amp; git branch --list 'ai/*' --merged | xargs -r git branch -d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git wt-ai payments      &lt;span class="c"&gt;# Creates worktree and ai/payments branch&lt;/span&gt;
git wt-ai-rm payments   &lt;span class="c"&gt;# Removes both&lt;/span&gt;
git wt-clean            &lt;span class="c"&gt;# Prune stale worktrees and merged AI branches&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Shell Functions for Complex Workflows
&lt;/h3&gt;

&lt;p&gt;Add to your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start an AI assisted task&lt;/span&gt;
ai_task&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--show-toplevel&lt;/span&gt;&lt;span class="si"&gt;))&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;worktree_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"../&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-ai-&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    git worktree add &lt;span class="nt"&gt;-b&lt;/span&gt; &lt;span class="s2"&gt;"ai/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$worktree_path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
    &lt;span class="nb"&gt;cd&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$worktree_path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    &lt;span class="c"&gt;# Auto detect and install dependencies&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"composer.json"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; composer &lt;span class="nb"&gt;install&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"package.json"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; npm &lt;span class="nb"&gt;install&lt;/span&gt;
    &lt;span class="o"&gt;[&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; &lt;span class="s2"&gt;"*.csproj"&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; dotnet restore

    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Ready! Opening Claude Code..."&lt;/span&gt;
    claude
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;# Quick cleanup&lt;/span&gt;
ai_cleanup&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git rev-parse &lt;span class="nt"&gt;--show-toplevel&lt;/span&gt; 2&amp;gt;/dev/null &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;basename&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;))&lt;/span&gt; | &lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="s1"&gt;'s/-ai-.*//'&lt;/span&gt;&lt;span class="si"&gt;))&lt;/span&gt;
    &lt;span class="nb"&gt;local &lt;/span&gt;&lt;span class="nv"&gt;worktree_path&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"../&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;project_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;-ai-&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;

    git worktree remove &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$worktree_path&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null
    git branch &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="s2"&gt;"ai/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; 2&amp;gt;/dev/null
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Cleaned up ai/&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;task_name&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Git worktrees transform how we can work with AI coding assistants. By providing isolated, parallel working environments, they enable us to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let AI agents work autonomously without blocking our own progress&lt;/li&gt;
&lt;li&gt;Experiment with multiple AI generated solutions simultaneously&lt;/li&gt;
&lt;li&gt;Maintain clean separation between human and AI contributions&lt;/li&gt;
&lt;li&gt;Safely evaluate and iterate on AI suggestions before merging&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The investment in learning worktrees pays dividends every time you use an AI coding tool. The commands become second nature quickly, and the workflow improvements are substantial.&lt;/p&gt;

&lt;p&gt;As AI assisted development continues to evolve, workflows like these will become increasingly important. The developers who master the tooling around AI integration will be the ones who extract the most value from these powerful assistants.&lt;/p&gt;

&lt;p&gt;Start small: next time you have a task suitable for Claude Code, create a dedicated worktree. Experience the freedom of parallel development firsthand. Once you do, you'll wonder how you ever worked without it.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Have questions or want to share your own AI plus worktree workflows? Drop a comment below or reach out on social media. Happy coding!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>claudecode</category>
      <category>git</category>
      <category>worktrees</category>
    </item>
    <item>
      <title>Running Laravel Sail with Podman on macOS: A Step-by-Step Guide</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Mon, 22 Dec 2025 10:51:02 +0000</pubDate>
      <link>https://forem.com/bhaidar/running-laravel-sail-with-podman-on-macos-a-step-by-step-guide-69e</link>
      <guid>https://forem.com/bhaidar/running-laravel-sail-with-podman-on-macos-a-step-by-step-guide-69e</guid>
      <description>&lt;p&gt;Laravel Sail is an excellent Docker-based development environment, but macOS users may want to switch from Docker to &lt;strong&gt;Podman&lt;/strong&gt;, especially if using rootless Podman for security. In this guide, I’ll show you how to run Sail with Podman, step by step, and highlight common pitfalls with solutions.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Install Podman and Set Up a Machine
&lt;/h2&gt;

&lt;p&gt;Install Podman via Homebrew:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;brew &lt;span class="nb"&gt;install &lt;/span&gt;podman
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create and start a Podman machine (a lightweight Linux VM):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman machine init
podman machine start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the connection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman info
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; Initially, Podman may fail to connect, showing &lt;code&gt;Cannot connect to Podman. Please verify your connection&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Use the correct identity key to SSH into the Podman machine. Test with:&lt;br&gt;
&lt;code&gt;ssh -i ~/.local/share/containers/podman/machine/machine -p &amp;lt;port&amp;gt; core@127.0.0.1&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 2: Check Podman Socket and Connections
&lt;/h2&gt;

&lt;p&gt;List Podman system connections:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman system connection list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure the default machine is set correctly. The socket path will be something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ssh://core@127.0.0.1:51011/run/user/501/podman/podman.sock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; Docker commands may fail with &lt;code&gt;Host key verification failed&lt;/code&gt; or &lt;code&gt;Permission denied&lt;/code&gt;.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Add the Podman machine key to your SSH &lt;code&gt;known_hosts&lt;/code&gt; or use the &lt;code&gt;-i&lt;/code&gt; identity option.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tip:&lt;/strong&gt; To avoid specifying the SSH connection every time, you can export the environment variables permanently in your shell configuration (&lt;code&gt;~/.zshrc&lt;/code&gt; or &lt;code&gt;~/.bashrc&lt;/code&gt;):  &lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DOCKER_HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;ssh://core@127.0.0.1:51011
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;DOCKER_SSH_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;/Users/&lt;span class="o"&gt;{&lt;/span&gt;Replace with your User Account&lt;span class="o"&gt;}&lt;/span&gt;/.local/share/containers/podman/machine/machine
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;This allows Sail and Docker CLI commands to automatically use your Podman machine.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 3: Configure Laravel Sail for Podman
&lt;/h2&gt;

&lt;p&gt;Sail uses &lt;code&gt;docker-compose&lt;/code&gt; under the hood. Create a &lt;code&gt;.env&lt;/code&gt; file in your Laravel project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;APP_PORT=8080
VITE_PORT=5173
FORWARD_DB_PORT=4006
FORWARD_MAILHOG_PORT=2008
FORWARD_MAILHOG_DASHBOARD_PORT=2009
FORWARD_MEILISEARCH_PORT=6008
FORWARD_REDIS_PORT=6009
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; Rootless Podman &lt;strong&gt;cannot bind ports below 1024&lt;/strong&gt;.&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; Make sure all ports in &lt;code&gt;.env&lt;/code&gt; are ≥1024 (e.g., &lt;code&gt;VITE_PORT=5173&lt;/code&gt;, &lt;code&gt;APP_PORT=8080&lt;/code&gt;).&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 4: Override the Docker Compose File
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;docker-compose.override.yml&lt;/code&gt; in your project root:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3'&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;laravel.test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;${APP_PORT:-8080}:80'&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;${VITE_PORT:-5173}:${VITE_PORT:-5173}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures Sail reads the correct ports from &lt;code&gt;.env&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 5: Bring Down Old Containers
&lt;/h2&gt;

&lt;p&gt;Before starting Sail with Podman, remove any existing containers:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./vendor/bin/sail down &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Issue:&lt;/strong&gt; Cached containers may still try to bind old ports (like 1007).&lt;br&gt;
&lt;strong&gt;Solution:&lt;/strong&gt; The &lt;code&gt;-v&lt;/code&gt; flag removes volumes and forces Sail to reload the updated &lt;code&gt;.env&lt;/code&gt; and override files.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Step 6: Start Sail
&lt;/h2&gt;

&lt;p&gt;Start Sail as usual:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./vendor/bin/sail up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Verify the ports:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose ps
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0.0.0.0:8080-&amp;gt;80/tcp
0.0.0.0:5173-&amp;gt;5173/tcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now your Laravel app and Vite dev server run on &lt;strong&gt;safe, unprivileged ports&lt;/strong&gt; with rootless Podman.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 7: Common Issues and Fixes
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Issue&lt;/th&gt;
&lt;th&gt;Error&lt;/th&gt;
&lt;th&gt;Solution&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Cannot connect to Podman&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Cannot connect to Podman socket&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Ensure machine is started and SSH connection works with &lt;code&gt;-i&lt;/code&gt; identity key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host key verification&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Host key verification failed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Add Podman machine key to &lt;code&gt;~/.ssh/known_hosts&lt;/code&gt; or use &lt;code&gt;ssh -i ...&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rootless port binding&lt;/td&gt;
&lt;td&gt;&lt;code&gt;rootlessport cannot expose privileged port 1007&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Make sure all ports ≥1024 in &lt;code&gt;.env&lt;/code&gt; (&lt;code&gt;APP_PORT&lt;/code&gt;, &lt;code&gt;VITE_PORT&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cached containers&lt;/td&gt;
&lt;td&gt;Containers still try old ports&lt;/td&gt;
&lt;td&gt;Run &lt;code&gt;./vendor/bin/sail down -v&lt;/code&gt; to remove old containers and volumes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Step 8: Success!
&lt;/h2&gt;

&lt;p&gt;Your Laravel Sail setup now runs completely on Podman, without needing Docker Desktop, using rootless ports, and with all services (MySQL, Redis, Meilisearch, Mailhog, Vite) running correctly.&lt;/p&gt;




&lt;p&gt;This workflow ensures &lt;strong&gt;Podman compatibility on macOS&lt;/strong&gt;, addresses common pitfalls with &lt;strong&gt;rootless port restrictions&lt;/strong&gt;, and guarantees Laravel Sail runs smoothly in a Docker-free environment.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>docker</category>
      <category>podman</category>
    </item>
    <item>
      <title>🧩 Mastering the Manager Pattern in Laravel — Build Pluggable, Scalable Architectures</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Mon, 27 Oct 2025 11:29:18 +0000</pubDate>
      <link>https://forem.com/bhaidar/mastering-the-manager-pattern-in-laravel-build-pluggable-scalable-architectures-47kp</link>
      <guid>https://forem.com/bhaidar/mastering-the-manager-pattern-in-laravel-build-pluggable-scalable-architectures-47kp</guid>
      <description>&lt;p&gt;One of the most powerful, yet least discussed, features in Laravel’s design is its &lt;strong&gt;Manager pattern&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s what gives Laravel its flexibility to easily switch between different &lt;code&gt;drivers&lt;/code&gt; like Redis, File, S3, Mailgun, or Database queues — all through configuration.&lt;/p&gt;

&lt;p&gt;Let’s break down how it works, why it’s elegant, and how you can use it in your own applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 What’s a Manager?&lt;/strong&gt;&lt;br&gt;
A &lt;strong&gt;Manager&lt;/strong&gt; is a class that knows how to build and manage multiple “drivers”, each implementing a common interface but doing things differently.&lt;/p&gt;

&lt;p&gt;Example from Laravel’s core:&lt;br&gt;
&lt;code&gt;CacheManager&lt;/code&gt; handles file, redis, database&lt;br&gt;
&lt;code&gt;MailManager&lt;/code&gt; handles smtp, mailgun, sendmail&lt;br&gt;
&lt;code&gt;QueueManager&lt;/code&gt; handles sync, database, redis&lt;/p&gt;

&lt;p&gt;All of these extend &lt;code&gt;Illuminate\Support\Manager&lt;/code&gt;, which gives them methods like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$manager-&amp;gt;driver('redis');
$manager-&amp;gt;driver('file');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The framework caches drivers, manages dependencies, and lets you easily switch by changing .env — no code changes needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Real Example — PaymentManager&lt;/strong&gt;&lt;br&gt;
Imagine your app supports multiple payment gateways — &lt;strong&gt;Stripe&lt;/strong&gt;, &lt;strong&gt;PayPal&lt;/strong&gt;, and &lt;strong&gt;AppSumo&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of cluttering your code with conditionals, create a clean PaymentManager to handle them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Create your PaymentManager&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;namespace App\Managers;


use Illuminate\Support\Manager;

class PaymentManager extends Manager
{
    protected function createStripeDriver()
    {
        return new \App\Services\Payments\StripeService();
    }

    protected function createPaypalDriver()
    {
        return new \App\Services\Payments\PaypalService();
    }

    protected function createAppsumoDriver()
    {
        return new \App\Services\Payments\AppsumoService();
    }

    public function getDefaultDriver()
    {
        return config('app.payment_driver', 'stripe');
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each createXDriver() method builds a specific driver.&lt;br&gt;
Laravel will call the correct one automatically based on the name you pass to driver().&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Example Drivers&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;namespace App\Services\Payments;

interface PaymentContract
{
    public function charge($user, $amount);
}

class StripeService implements PaymentContract
{
    public function charge($user, $amount)
    {
        // Stripe API logic
    }
}

class PaypalService implements PaymentContract
{
    public function charge($user, $amount)
    {
        // PayPal API logic
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each driver follows the same interface (PaymentContract).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Using the Manager&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$paymentManager = app(App\Managers\PaymentManager::class);
$payment = $paymentManager-&amp;gt;driver(config('app.payment_driver'));
$payment-&amp;gt;charge($user, 100);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, you can easily switch between payment providers by editing your .env:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PAYMENT_DRIVER=paypal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No code changes required. Your architecture remains clean, scalable, and maintainable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚙️ Why This Pattern Rocks&lt;/strong&gt;&lt;br&gt;
✅ Config-driven: No conditionals, just configuration&lt;br&gt;
✅ Extensible: Add new drivers anytime&lt;br&gt;
✅ Testable: Mock a driver in your tests easily&lt;br&gt;
✅ Proven: It's used across Laravel’s core services&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Bonus — When to Use a Manager&lt;/strong&gt;&lt;br&gt;
Use this pattern when you have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple implementations of the same interface (e.g., notifications, analytics, storage)&lt;/li&gt;
&lt;li&gt;Dynamic runtime switching (e.g., per-tenant configuration)&lt;/li&gt;
&lt;li&gt;Need for test isolation and maintainable abstractions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🧠 Final Thoughts&lt;/strong&gt;&lt;br&gt;
The Manager pattern is part of what makes Laravel both beautiful and enterprise-ready.&lt;/p&gt;

&lt;p&gt;Once you understand it, you can architect systems that are modular, testable, and scalable, just like Laravel itself.&lt;/p&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>designpatterns</category>
      <category>architecture</category>
    </item>
    <item>
      <title>💥 Supercharge your Laravel API calls with Http::pool()</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Tue, 21 Oct 2025 06:24:54 +0000</pubDate>
      <link>https://forem.com/bhaidar/supercharge-your-laravel-api-calls-with-httppool-2cdp</link>
      <guid>https://forem.com/bhaidar/supercharge-your-laravel-api-calls-with-httppool-2cdp</guid>
      <description>&lt;p&gt;Did you know you can send &lt;strong&gt;multiple HTTP requests in parallel&lt;/strong&gt; in Laravel, instead of one after another?&lt;/p&gt;

&lt;p&gt;That’s what &lt;code&gt;Http::pool()&lt;/code&gt; does. It’s built on top of Guzzle and can massively boost performance when fetching data from several APIs at once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧠 The idea&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Normally, you might do this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$response1 = Http::get('https://api.example.com/users');
$response2 = Http::get('https://api.example.com/posts');
$response3 = Http::get('https://api.example.com/comments');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each waits for the previous one.&lt;br&gt;
If each takes 1 second → total ≈ 3 seconds.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;Http::pool()&lt;/code&gt;, Laravel runs them &lt;strong&gt;all at once&lt;/strong&gt; — so the total time ≈ the longest single request (around 1 second here).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;use Illuminate\Support\Facades\Http;

$responses = Http::pool(fn ($pool) =&amp;gt; [
    $pool-&amp;gt;as('users')-&amp;gt;get('https://api.example.com/users'),
    $pool-&amp;gt;as('posts')-&amp;gt;get('https://api.example.com/posts'),
    $pool-&amp;gt;as('comments')-&amp;gt;get('https://api.example.com/comments'),
]);

$users = $responses['users'];
$posts = $responses['posts'];
$comments = $responses['comments'];

$usersData = $users-&amp;gt;json();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;⚙️ How it works&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;pool()&lt;/code&gt; method accepts a closure.&lt;/li&gt;
&lt;li&gt;Inside, you define multiple requests.&lt;/li&gt;
&lt;li&gt;Laravel runs them concurrently using Guzzle promises.&lt;/li&gt;
&lt;li&gt;Returns an array of responses (each is a standard Response instance).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🧩 Dynamic example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$urls = [
    'https://api.example.com/products/1',
    'https://api.example.com/products/2',
    'https://api.example.com/products/3',
];

$responses = Http::pool(fn ($pool) =&amp;gt;
    collect($urls)-&amp;gt;map(fn($url) =&amp;gt; $pool-&amp;gt;get($url))-&amp;gt;all()
);

foreach ($responses as $response) {
    dump($response-&amp;gt;json());
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;🛠 When to use it&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Fetch data from multiple APIs simultaneously&lt;br&gt;
✅ Speed up microservice calls&lt;br&gt;
✅ Reduce latency in dashboards or data aggregators&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📚 Laravel Docs&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://laravel.com/docs/http-client#concurrent-requests" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 Have you used &lt;code&gt;Http::pool()&lt;/code&gt;before?&lt;br&gt;
Share your favorite use case or performance boost story 👇&lt;/p&gt;

&lt;h1&gt;
  
  
  Laravel #WebDevelopment #FullStackDev #Performance #PHP #LaravelTips
&lt;/h1&gt;

</description>
      <category>laravel</category>
      <category>api</category>
      <category>performance</category>
      <category>php</category>
    </item>
    <item>
      <title>Essential Composer CLI Commands Cheat Sheet</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Fri, 03 Oct 2025 19:37:45 +0000</pubDate>
      <link>https://forem.com/bhaidar/essential-composer-cli-commands-cheat-sheet-4eko</link>
      <guid>https://forem.com/bhaidar/essential-composer-cli-commands-cheat-sheet-4eko</guid>
      <description>&lt;p&gt;Composer is the dependency manager for PHP that helps you manage packages and libraries in your projects.&lt;/p&gt;

&lt;p&gt;Below is a handy list of commonly used Composer CLI commands with one-line explanations to keep as a quick reference.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Installation and Updates&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer self-update&lt;/code&gt; → Updates Composer itself to the latest version.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer diagnose&lt;/code&gt; → Checks your system for common issues with Composer setup.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Project Setup&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer init&lt;/code&gt; → Starts an interactive session to create a composer.json file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer create-project vendor/package [dir&lt;/code&gt;] → Creates a new project from a package (e.g., Laravel, Symfony).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Dependencies Management&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer install&lt;/code&gt; → Installs dependencies listed in composer.lock (or composer.json if no lock file exists).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer update&lt;/code&gt; → Updates all dependencies to the latest versions according to composer.json.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer require vendor/package&lt;/code&gt; → Installs and adds a package to your project.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer remove vendor/package&lt;/code&gt; → Removes a package and updates composer.json.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Autoloading&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer dump-autoload&lt;/code&gt; → Regenerates the autoloader for faster class loading.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer dump-autoload -o&lt;/code&gt; → Optimizes autoloader by converting PSR-0/4 autoloading rules into a class map.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Information &amp;amp; Debugging&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer show&lt;/code&gt; → Lists all installed packages in the current project.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer show vendor/package&lt;/code&gt; → Shows detailed information about a specific package.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer outdated&lt;/code&gt; → Displays packages that have updates available.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer why vendor/package&lt;/code&gt; → Shows which package requires a given dependency.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer why-not vendor/package&lt;/code&gt; → Explains why a package cannot be installed or updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Scripts &amp;amp; Custom Commands&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer run-script script-name&lt;/code&gt; → Runs a script defined in composer.json.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer test&lt;/code&gt; → Shortcut to run the test script defined in your composer.json.&lt;/li&gt;
&lt;li&gt;Global Usage&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer global require vendor/package&lt;/code&gt; → Installs a package globally (available system-wide).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer global show&lt;/code&gt; → Lists globally installed Composer packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Cache &amp;amp; Config&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;composer clear-cache&lt;/code&gt; → Clears Composer’s cache.&lt;br&gt;
&lt;code&gt;composer config key value&lt;/code&gt; → Sets a configuration option (local or global).&lt;br&gt;
&lt;code&gt;composer config --list&lt;/code&gt; → Shows all current Composer configuration settings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Version Control&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;composer install --no-dev&lt;/code&gt; → Installs only production dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer install --dev&lt;/code&gt; → Installs development dependencies.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;composer update --lock&lt;/code&gt; → Updates only the composer.lock file without changing dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Handy Flags&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;--no-scripts&lt;/code&gt; → Skips running scripts defined in composer.json.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--no-progress&lt;/code&gt; → Hides progress display for CI/CD pipelines.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--dry-run&lt;/code&gt; → Simulates a command without executing it.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>php</category>
      <category>laravel</category>
      <category>symfony</category>
    </item>
    <item>
      <title>Learn how to deploy a Nuxt3 App with SSR on Laravel Forge</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Mon, 31 Mar 2025 18:55:21 +0000</pubDate>
      <link>https://forem.com/bhaidar/learn-how-to-deploy-a-nuxt3-app-with-ssr-on-laravel-forge-29a5</link>
      <guid>https://forem.com/bhaidar/learn-how-to-deploy-a-nuxt3-app-with-ssr-on-laravel-forge-29a5</guid>
      <description>&lt;div class="ltag__link--embedded"&gt;
  &lt;div class="crayons-story "&gt;
  &lt;a href="https://dev.to/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c" class="crayons-story__hidden-navigation-link"&gt;Deploying a Nuxt 3 App with SSR on Laravel Forge&lt;/a&gt;


  &lt;div class="crayons-story__body crayons-story__body-full_post"&gt;
    &lt;div class="crayons-story__top"&gt;
      &lt;div class="crayons-story__meta"&gt;
        &lt;div class="crayons-story__author-pic"&gt;

          &lt;a href="/bhaidar" class="crayons-avatar  crayons-avatar--l  "&gt;
            &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F127567%2Ff131b7c5-65e0-4f76-be20-363ec27aa152.png" alt="bhaidar profile" class="crayons-avatar__image"&gt;
          &lt;/a&gt;
        &lt;/div&gt;
        &lt;div&gt;
          &lt;div&gt;
            &lt;a href="/bhaidar" class="crayons-story__secondary fw-medium m:hidden"&gt;
              Bilal Haidar
            &lt;/a&gt;
            &lt;div class="profile-preview-card relative mb-4 s:mb-0 fw-medium hidden m:inline-block"&gt;
              
                Bilal Haidar
                
              
              &lt;div id="story-author-preview-content-2369420" class="profile-preview-card__content crayons-dropdown branded-7 p-4 pt-0"&gt;
                &lt;div class="gap-4 grid"&gt;
                  &lt;div class="-mt-4"&gt;
                    &lt;a href="/bhaidar" class="flex"&gt;
                      &lt;span class="crayons-avatar crayons-avatar--xl mr-2 shrink-0"&gt;
                        &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F127567%2Ff131b7c5-65e0-4f76-be20-363ec27aa152.png" class="crayons-avatar__image" alt=""&gt;
                      &lt;/span&gt;
                      &lt;span class="crayons-link crayons-subtitle-2 mt-5"&gt;Bilal Haidar&lt;/span&gt;
                    &lt;/a&gt;
                  &lt;/div&gt;
                  &lt;div class="print-hidden"&gt;
                    
                      Follow
                    
                  &lt;/div&gt;
                  &lt;div class="author-preview-metadata-container"&gt;&lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;

          &lt;/div&gt;
          &lt;a href="https://dev.to/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c" class="crayons-story__tertiary fs-xs"&gt;&lt;time&gt;Mar 31 '25&lt;/time&gt;&lt;span class="time-ago-indicator-initial-placeholder"&gt;&lt;/span&gt;&lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class="crayons-story__indention"&gt;
      &lt;h2 class="crayons-story__title crayons-story__title-full_post"&gt;
        &lt;a href="https://dev.to/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c" id="article-link-2369420"&gt;
          Deploying a Nuxt 3 App with SSR on Laravel Forge
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;div class="crayons-story__tags"&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/nextjs"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;nextjs&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/laravelforge"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;laravelforge&lt;/a&gt;
            &lt;a class="crayons-tag  crayons-tag--monochrome " href="/t/ssr"&gt;&lt;span class="crayons-tag__prefix"&gt;#&lt;/span&gt;ssr&lt;/a&gt;
        &lt;/div&gt;
      &lt;div class="crayons-story__bottom"&gt;
        &lt;div class="crayons-story__details"&gt;
            &lt;a href="https://dev.to/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c#comments" class="crayons-btn crayons-btn--s crayons-btn--ghost crayons-btn--icon-left flex items-center"&gt;
              Comments


              &lt;span class="hidden s:inline"&gt;Add Comment&lt;/span&gt;
            &lt;/a&gt;
        &lt;/div&gt;
        &lt;div class="crayons-story__save"&gt;
          &lt;small class="crayons-story__tertiary fs-xs mr-2"&gt;
            3 min read
          &lt;/small&gt;
            
              &lt;span class="bm-initial"&gt;
                

              &lt;/span&gt;
              &lt;span class="bm-success"&gt;
                

              &lt;/span&gt;
            
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;/div&gt;


</description>
      <category>nextjs</category>
      <category>laravelforge</category>
      <category>ssr</category>
    </item>
    <item>
      <title>Deploying a Nuxt 3 App with SSR on Laravel Forge</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Mon, 31 Mar 2025 18:51:42 +0000</pubDate>
      <link>https://forem.com/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c</link>
      <guid>https://forem.com/bhaidar/deploying-a-nuxt-3-app-with-ssr-on-laravel-forge-3i8c</guid>
      <description>&lt;p&gt;Deploying a Nuxt 3 application with Server-Side Rendering (SSR) on Laravel Forge requires specific configurations to ensure that Nuxt is properly served. This guide provides a step-by-step walkthrough to deploy your Nuxt 3 SSR app on Forge, configure Nginx, and manage Nuxt processes using PM2.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Prepare Your Nuxt 3 App for Deployment
&lt;/h2&gt;

&lt;p&gt;Before deploying, ensure your Nuxt app is properly configured for SSR. Update your &lt;code&gt;nuxt.config.js&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineNuxtConfig&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;ssr&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Enable Server-Side Rendering&lt;/span&gt;
  &lt;span class="na"&gt;nitro&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;prerender&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;crawlLinks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// Prevent Nitro from crawling and generating routes&lt;/span&gt;
      &lt;span class="na"&gt;routes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="c1"&gt;// No pre-rendered routes&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="c1"&gt;// ... other config here&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Why this matters?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;When &lt;strong&gt;SSR is enabled&lt;/strong&gt;, Nuxt does &lt;strong&gt;not&lt;/strong&gt; serve static files from &lt;code&gt;/dist&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Instead, the SSR application is served from &lt;code&gt;.output/public/server&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;This means &lt;strong&gt;all requests are handled dynamically by Nuxt&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;We need PM2 to manage the Nuxt server, ensuring it runs continuously.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Step 2: Create a New Static App on Laravel Forge
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Log in to your &lt;a href="https://forge.laravel.com/" rel="noopener noreferrer"&gt;Laravel Forge&lt;/a&gt; account.&lt;/li&gt;
&lt;li&gt;Create a &lt;strong&gt;new site&lt;/strong&gt; and select &lt;strong&gt;Static App&lt;/strong&gt; as the site type.&lt;/li&gt;
&lt;li&gt;Add your domain (e.g., &lt;code&gt;yourdomain.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Assign an SSL certificate (&lt;strong&gt;Let's Encrypt&lt;/strong&gt; or manually).&lt;/li&gt;
&lt;li&gt;Once SSL is active, edit the Nginx configuration file.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Editing Nginx Configuration on Forge
&lt;/h3&gt;

&lt;p&gt;Rather than editing the Nginx config directly on the server, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Navigate to your site on Forge.&lt;/li&gt;
&lt;li&gt;Locate the &lt;strong&gt;Edit Files&lt;/strong&gt; dropdown on the top-right side of the page.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Edit Nginx Configuration&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Replace the existing configuration with the following, ensuring you replace:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;YOUR_DOMAIN_NAME&lt;/code&gt; with your actual domain.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;YOUR_DOMAIN_FOLDER&lt;/code&gt; with the correct site directory.&lt;/li&gt;
&lt;li&gt;Keep the &lt;strong&gt;SSL ID values&lt;/strong&gt; assigned by Forge for your certificate.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight nginx"&gt;&lt;code&gt;&lt;span class="c1"&gt;# FORGE CONFIG (DO NOT REMOVE!)&lt;/span&gt;
&lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="n"&gt;forge-conf/YOUR_DOMAIN_FOLDER/before/*&lt;/span&gt;;

&lt;span class="k"&gt;map&lt;/span&gt; &lt;span class="nv"&gt;$sent_http_content_type&lt;/span&gt; &lt;span class="nv"&gt;$expires&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;"text/html"&lt;/span&gt;                 &lt;span class="s"&gt;epoch&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;"text/html&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="kn"&gt;charset=utf-8"&lt;/span&gt;  &lt;span class="s"&gt;epoch&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;default&lt;/span&gt;                     &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;server&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="mi"&gt;443&lt;/span&gt; &lt;span class="s"&gt;ssl&lt;/span&gt; &lt;span class="s"&gt;http2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;listen&lt;/span&gt; &lt;span class="s"&gt;[::]:443&lt;/span&gt; &lt;span class="s"&gt;ssl&lt;/span&gt; &lt;span class="s"&gt;http2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;server_name&lt;/span&gt; &lt;span class="s"&gt;YOUR_DOMAIN_NAME&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;# FORGE SSL (DO NOT REMOVE!)&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_certificate&lt;/span&gt; &lt;span class="n"&gt;/etc/nginx/ssl/YOUR_DOMAIN_NAME/YOUR_SSL_ID/server.crt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_certificate_key&lt;/span&gt; &lt;span class="n"&gt;/etc/nginx/ssl/YOUR_DOMAIN_NAME/YOUR_SSL_ID/server.key&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;ssl_protocols&lt;/span&gt; &lt;span class="s"&gt;TLSv1.2&lt;/span&gt; &lt;span class="s"&gt;TLSv1.3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_ciphers&lt;/span&gt; &lt;span class="s"&gt;ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_prefer_server_ciphers&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;ssl_dhparam&lt;/span&gt; &lt;span class="n"&gt;/etc/nginx/dhparams.pem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;X-Frame-Options&lt;/span&gt; &lt;span class="s"&gt;"SAMEORIGIN"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;X-XSS-Protection&lt;/span&gt; &lt;span class="s"&gt;"1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="kn"&gt;mode=block"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;add_header&lt;/span&gt; &lt;span class="s"&gt;X-Content-Type-Options&lt;/span&gt; &lt;span class="s"&gt;"nosniff"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;charset&lt;/span&gt; &lt;span class="s"&gt;utf-8&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;gzip&lt;/span&gt;            &lt;span class="no"&gt;on&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;gzip_types&lt;/span&gt;      &lt;span class="nc"&gt;text/plain&lt;/span&gt; &lt;span class="nc"&gt;application/xml&lt;/span&gt; &lt;span class="nc"&gt;text/css&lt;/span&gt; &lt;span class="nc"&gt;application/javascript&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;gzip_min_length&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;# FORGE CONFIG (DO NOT REMOVE!)&lt;/span&gt;
    &lt;span class="kn"&gt;include&lt;/span&gt; &lt;span class="nc"&gt;forge-conf/YOUR&lt;/span&gt;&lt;span class="s"&gt;_DOMAIN_FOLDER/server/*&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="n"&gt;/&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;expires&lt;/span&gt; &lt;span class="nv"&gt;$expires&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;Host&lt;/span&gt;               &lt;span class="nv"&gt;$host&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Real-IP&lt;/span&gt;          &lt;span class="nv"&gt;$remote_addr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-For&lt;/span&gt;    &lt;span class="nv"&gt;$proxy_add_x_forwarded_for&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_set_header&lt;/span&gt; &lt;span class="s"&gt;X-Forwarded-Proto&lt;/span&gt;  &lt;span class="nv"&gt;$scheme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_redirect&lt;/span&gt;              &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_read_timeout&lt;/span&gt;          &lt;span class="mi"&gt;1m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_connect_timeout&lt;/span&gt;       &lt;span class="mi"&gt;1m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kn"&gt;proxy_pass&lt;/span&gt;                  &lt;span class="s"&gt;http://127.0.0.1:3000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;# Set the address of the Node.js server&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kn"&gt;access_log&lt;/span&gt; &lt;span class="no"&gt;off&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kn"&gt;error_log&lt;/span&gt;  &lt;span class="n"&gt;/var/log/nginx/YOUR_DOMAIN_NAME-error.log&lt;/span&gt; &lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kn"&gt;location&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt; &lt;span class="sr"&gt;/\.(?!well-known).*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kn"&gt;deny&lt;/span&gt; &lt;span class="s"&gt;all&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;# FORGE CONFIG (DO NOT REMOVE!)&lt;/span&gt;
&lt;span class="k"&gt;include&lt;/span&gt; &lt;span class="n"&gt;forge-conf/YOUR_DOMAIN_FOLDER/after/*&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After saving changes in Forge, restart Nginx by clicking &lt;strong&gt;Apply Changes&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Set Up Deployment Script on Forge
&lt;/h2&gt;

&lt;p&gt;Navigate to your site on Laravel Forge and go to the &lt;strong&gt;Deployment&lt;/strong&gt; tab. Update the deployment script with the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/bin/bash&lt;/span&gt;
&lt;span class="nb"&gt;cd&lt;/span&gt; /home/forge/YOUR_DOMAIN_NAME

&lt;span class="c"&gt;# Pull latest changes&lt;/span&gt;
git pull origin &lt;span class="nv"&gt;$FORGE_SITE_BRANCH&lt;/span&gt;

&lt;span class="c"&gt;# Clean installation files&lt;/span&gt;
&lt;span class="nb"&gt;rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; node_modules
&lt;span class="nb"&gt;rm &lt;/span&gt;package-lock.json

&lt;span class="c"&gt;# Install dependencies with platform-specific flags&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ROLLUP_SKIP_NODE_CHECK&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true
&lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;--platform&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;linux &lt;span class="nt"&gt;--arch&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;x64

&lt;span class="c"&gt;# Build for SSR&lt;/span&gt;
npm run build

&lt;span class="c"&gt;# Restart Nuxt using PM2&lt;/span&gt;
pm2 delete nuxt-app &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;true&lt;/span&gt;  &lt;span class="c"&gt;# Ensure old process is removed&lt;/span&gt;
pm2 start .output/server/index.mjs &lt;span class="nt"&gt;--name&lt;/span&gt; &lt;span class="s2"&gt;"nuxt-app"&lt;/span&gt;

&lt;span class="c"&gt;# Save PM2 process so it persists after a reboot&lt;/span&gt;
pm2 save

&lt;span class="c"&gt;# Restart PHP-FPM (if needed for other Laravel services)&lt;/span&gt;
&lt;span class="o"&gt;(&lt;/span&gt; flock &lt;span class="nt"&gt;-w&lt;/span&gt; 10 9 &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;exit &lt;/span&gt;1
    &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'Restarting FPM...'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nb"&gt;sudo&lt;/span&gt; &lt;span class="nt"&gt;-S&lt;/span&gt; service &lt;span class="nv"&gt;$FORGE_PHP_FPM&lt;/span&gt; reload &lt;span class="o"&gt;)&lt;/span&gt; 9&amp;gt;/tmp/fpmlock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click &lt;strong&gt;Save&lt;/strong&gt; and then &lt;strong&gt;Deploy Now&lt;/strong&gt; to start the process.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Finalizing Your Deployment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Ensure that your &lt;strong&gt;Web Directory&lt;/strong&gt; in Laravel Forge is set to:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/public
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Manually restart all services to ensure everything is working:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;service nginx restart
pm2 restart nuxt-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open your domain in the browser (&lt;code&gt;https://yourdomain.com&lt;/code&gt;) and check that the app is loading correctly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Monitor logs if there are any issues:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;tail&lt;/span&gt; &lt;span class="nt"&gt;-f&lt;/span&gt; /var/log/nginx/YOUR_DOMAIN_NAME-error.log
pm2 logs nuxt-app 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By following these steps, you have successfully deployed a &lt;strong&gt;Nuxt 3 SSR application&lt;/strong&gt; on &lt;strong&gt;Laravel Forge&lt;/strong&gt;. This setup ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nuxt 3 runs in &lt;strong&gt;server-side rendering mode&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Nginx properly proxies requests to the Nuxt SSR server.&lt;/li&gt;
&lt;li&gt;PM2 keeps the Nuxt process running reliably.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This guide should serve as a &lt;strong&gt;complete reference&lt;/strong&gt; for anyone deploying &lt;strong&gt;Nuxt 3 SSR&lt;/strong&gt; on Laravel Forge. 🚀&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>laravelforge</category>
      <category>ssr</category>
    </item>
    <item>
      <title>Implementing Infinite Scrolling with Laravel, Inertia.js v2.0, and Vue 3</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Wed, 11 Dec 2024 12:21:48 +0000</pubDate>
      <link>https://forem.com/bhaidar/implementing-infinite-scrolling-with-laravel-inertiajs-v20-and-vue-3-3il</link>
      <guid>https://forem.com/bhaidar/implementing-infinite-scrolling-with-laravel-inertiajs-v20-and-vue-3-3il</guid>
      <description>&lt;p&gt;In this comprehensive guide, we'll explore how to implement infinite scrolling in a Laravel application using Inertia.js v2.0 and Vue 3. We'll cover both the frontend and backend implementation, with special attention to handling full page refreshes and maintaining scroll position.&lt;/p&gt;

&lt;h2&gt;
  
  
  Table of Contents
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the Components&lt;/li&gt;
&lt;li&gt;Frontend Implementation&lt;/li&gt;
&lt;li&gt;Backend Implementation&lt;/li&gt;
&lt;li&gt;Real-World Example: Blog Posts with Categories&lt;/li&gt;
&lt;li&gt;Best Practices and Considerations&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Understanding the Components
&lt;/h2&gt;

&lt;p&gt;The infinite scrolling implementation relies on three main components:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Inertia.js v2.0's WhenVisible Component&lt;/strong&gt;: This component handles the intersection observer logic to detect when we need to load more content.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Laravel's Pagination&lt;/strong&gt;: Handles the server-side pagination logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vue 3's Composition API&lt;/strong&gt;: Manages our frontend state and reactivity.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Frontend Implementation
&lt;/h2&gt;

&lt;p&gt;Let's start with a Vue component that implements infinite scrolling for a blog posts listing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vue"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt; &lt;span class="na"&gt;setup&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;computed&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;usePage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WhenVisible&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@inertiajs/vue3&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;LoadingSpinner&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/components/LoadingSpinner.vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;BlogPostCard&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@/components/BlogPostCard.vue&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;usePage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hasFeaturePost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;featuredPost&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;categoryName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;computed&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="k"&gt;script&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;template&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"bg-gray-50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="c"&gt;&amp;lt;!-- Featured Post Section --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt;
            &lt;span class="na"&gt;v-if=&lt;/span&gt;&lt;span class="s"&gt;"hasFeaturePost"&lt;/span&gt;
            &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"py-8 text-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;h2&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mb-4 text-3xl font-bold"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    Featured Post: &lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;featuredPost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

        &lt;span class="c"&gt;&amp;lt;!-- Posts Grid --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"max-w-7xl px-4 py-8 mx-auto sm:px-6 lg:px-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;h1&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"text-2xl font-bold mb-6"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="si"&gt;{{&lt;/span&gt; &lt;span class="nx"&gt;categoryName&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;`Posts in ${categoryName&lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;All Posts&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="si"&gt;}}&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
            &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
                    &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;post in page.props.posts&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                    &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;post.id&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                    &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;relative flex flex-col&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;blog&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;card&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;post&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;
                &lt;span class="c"&gt;&amp;lt;!--&lt;/span&gt; &lt;span class="nx"&gt;Infinite&lt;/span&gt; &lt;span class="nx"&gt;Scroll&lt;/span&gt; &lt;span class="nx"&gt;Handler&lt;/span&gt; &lt;span class="o"&gt;--&amp;gt;&lt;/span&gt;
                &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;WhenVisible&lt;/span&gt;
                    &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;always&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page.props.postsPagination?.current_page &amp;lt; page.props.postsPagination?.last_page&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                    &lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{
                        data: {
                            page: page.props.postsPagination.current_page + 1,
                        &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;,
                        only: ['posts', 'postsPagination'],
                    &lt;/span&gt;&lt;span class="err"&gt;}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;
                        &lt;span class="nx"&gt;v&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;page.props.postsPagination?.current_page &amp;gt;= page.props.postsPagination?.last_page&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                        &lt;span class="kd"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-center py-6 text-gray-600 col-span-1 md:col-span-2 lg:col-span-3&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
                    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
                        &lt;span class="nx"&gt;You&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ve reached the end!
                    &amp;lt;/div&amp;gt;
                    &amp;lt;div
                        v-else
                        class="col-span-1 md:col-span-2 lg:col-span-3"
                    &amp;gt;
                        &amp;lt;loading-spinner /&amp;gt;
                    &amp;lt;/div&amp;gt;
                &amp;lt;/WhenVisible&amp;gt;
            &amp;lt;/div&amp;gt;
        &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Frontend Features
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WhenVisible Component&lt;/strong&gt;: This component from Inertia.js v2.0 automatically triggers a request when the element becomes visible in the viewport.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pagination Parameters&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;{
    data: {
        page: page.props.postsPagination.current_page + 1,
    },
    only: ['posts', 'postsPagination'],
}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;data&lt;/code&gt;: Specifies the next page to load&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;only&lt;/code&gt;: Optimizes the request by only fetching required data&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Loading States&lt;/strong&gt;: The component handles both loading and end-of-content states elegantly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Backend Implementation
&lt;/h2&gt;

&lt;p&gt;Here's the Laravel controller implementation that handles both regular pagination and full-page load scenarios:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;?php&lt;/span&gt;

&lt;span class="kn"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;App\Http\Controllers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\Post&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;App\Models\Category&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Illuminate\Pagination\LengthAwarePaginator&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;use&lt;/span&gt; &lt;span class="nc"&gt;Inertia\Inertia&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BlogController&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Controller&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;?Category&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Inertia&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Blog/Index'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="s1"&gt;'category'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="s1"&gt;'featuredPost'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getFeaturedPost&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
            &lt;span class="s1"&gt;'posts'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getPaginatedPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="s1"&gt;'postsPagination'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$this&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;getPaginatedPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;toArray&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getPaginatedPosts&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;?Category&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kt"&gt;?LengthAwarePaginator&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nv"&gt;$currentPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'page'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="nv"&gt;$perPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'per_page'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'author'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'category'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Apply any additional filters&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sort'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;orderBy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sort'&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'direction'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'desc'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;latest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// Handle full page load vs. infinite scroll request&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Inertia'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Full page load - fetch all pages up to current&lt;/span&gt;
            &lt;span class="nv"&gt;$allResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

            &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;$currentPage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nv"&gt;$pageResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$perPage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'*'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;'page'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="nv"&gt;$allResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$allResults&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$pageResults&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;LengthAwarePaginator&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nv"&gt;$allResults&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
                    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;when&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$q&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$q&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'category_id'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$category&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
                &lt;span class="nv"&gt;$perPage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="nv"&gt;$currentPage&lt;/span&gt;
            &lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$perPage&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;getFeaturedPost&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'author'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'category'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;featured&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;latest&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Key Backend Features
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pagination Handling&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nb"&gt;header&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'X-Inertia'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Full page load logic&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Regular pagination for infinite scroll&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Full Page Load&lt;/strong&gt;: When a user refreshes or directly visits a page, we fetch all previous pages to maintain the correct scroll position:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nv"&gt;$currentPage&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nv"&gt;$pageResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;paginate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$perPage&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'*'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="s1"&gt;'page'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$page&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nv"&gt;$allResults&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$allResults&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;concat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$pageResults&lt;/span&gt;&lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;items&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Efficient Querying&lt;/strong&gt;: The implementation includes relationship eager loading and scoped queries:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;with&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s1"&gt;'author'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'category'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt;&lt;span class="nf"&gt;published&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Implementing infinite scrolling with Laravel and Inertia.js v2.0 provides a smooth user experience while maintaining good performance and SEO practices. The combination of Vue 3's Composition API and Inertia.js's WhenVisible component makes it easy to implement and maintain.&lt;/p&gt;

&lt;p&gt;Remember to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test the implementation thoroughly, especially for edge cases&lt;/li&gt;
&lt;li&gt;Monitor performance metrics&lt;/li&gt;
&lt;li&gt;Consider implementing a fallback for users with JavaScript disabled&lt;/li&gt;
&lt;li&gt;Keep accessibility in mind when implementing infinite scroll&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This implementation can be adapted for various use cases beyond blog posts, such as product listings, image galleries, or any other content that benefits from infinite scrolling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://v2.inertiajs.com/" rel="noopener noreferrer"&gt;Inertia.js Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://laravel.com/docs" rel="noopener noreferrer"&gt;Laravel Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue 3 Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3.org/WAI/ARIA/apg/patterns/feed/examples/feed/" rel="noopener noreferrer"&gt;Web Accessibility Guidelines for Infinite Scroll&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>laravel</category>
      <category>vue</category>
      <category>inertiajs</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Understanding Laravel Cashier's Core Traits: A Deep Dive</title>
      <dc:creator>Bilal Haidar</dc:creator>
      <pubDate>Thu, 28 Nov 2024 18:45:07 +0000</pubDate>
      <link>https://forem.com/bhaidar/understanding-laravel-cashiers-core-traits-a-deep-dive-5693</link>
      <guid>https://forem.com/bhaidar/understanding-laravel-cashiers-core-traits-a-deep-dive-5693</guid>
      <description>&lt;p&gt;Laravel Cashier provides several powerful traits that handle Stripe integrations. Today, we'll explore three core traits and their public methods: ManagesSubscriptions, ManagesCustomer, and ManagesInvoices. Understanding these traits is crucial for implementing subscription-based billing in your Laravel applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  ManagesSubscriptions Trait
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Subscription Creation and Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;newSubscription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$prices&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Creates new subscription builder instance. Type defines the subscription name (e.g., 'default'), and prices can be single ID or array.&lt;/p&gt;

&lt;h3&gt;
  
  
  Trial Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;onTrial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;No parameters: Checks ONLY generic (model-level) trial&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;$type&lt;/code&gt;: Checks subscription-specific trial&lt;/li&gt;
&lt;li&gt;With both: Checks if specific price is on trial&lt;/li&gt;
&lt;li&gt;Returns boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;hasExpiredTrial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;No parameters: Checks generic trial expiration&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;$type&lt;/code&gt;: Checks specific subscription trial expiration&lt;/li&gt;
&lt;li&gt;With both: Verifies specific price trial expiration&lt;/li&gt;
&lt;li&gt;Returns boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;onGenericTrial&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks model-level trial status&lt;/li&gt;
&lt;li&gt;Returns true if trial_ends_at exists and is future&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;scopeOnGenericTrial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Scope to filter customers on generic trial&lt;/li&gt;
&lt;li&gt;Used in query builder&lt;/li&gt;
&lt;li&gt;Requires query builder instance
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;hasExpiredGenericTrial&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks if model-level trial has expired&lt;/li&gt;
&lt;li&gt;Returns true if trial_ends_at exists and is past&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;scopeHasExpiredGenericTrial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Scope to filter customers with expired generic trials&lt;/li&gt;
&lt;li&gt;Used in query builder&lt;/li&gt;
&lt;li&gt;Requires query builder instance
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;trialEndsAt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;No parameters: Returns generic trial end date if on generic trial&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;$type&lt;/code&gt;: Returns subscription-specific trial end date&lt;/li&gt;
&lt;li&gt;Returns Carbon instance or null&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Subscription Status Checking
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;subscribed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$price&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Just &lt;code&gt;$type&lt;/code&gt;: Checks valid subscription existence&lt;/li&gt;
&lt;li&gt;With &lt;code&gt;$price&lt;/code&gt;: Checks specific price subscription&lt;/li&gt;
&lt;li&gt;Returns boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets subscription by type&lt;/li&gt;
&lt;li&gt;Returns Subscription model or null
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;subscriptions&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets all subscriptions&lt;/li&gt;
&lt;li&gt;Returns HasMany relationship&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;hasIncompletePayment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks for incomplete payment on subscription&lt;/li&gt;
&lt;li&gt;Returns boolean
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;subscribedToProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$products&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$products&lt;/code&gt;: Single product ID or array&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$type&lt;/code&gt;: Subscription type to check&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;Checks if subscribed to ANY of given products
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;subscribedToPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$prices&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'default'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;$prices&lt;/code&gt;: Single price ID or array&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;$type&lt;/code&gt;: Subscription type to check&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;Checks if subscribed to ANY of given prices
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;onProduct&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$product&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks for valid subscription with specific product&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;More specific than subscribedToProduct
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;onPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks for valid subscription with specific price&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;More specific than subscribedToPrice
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;taxRates&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets tax rates for subscription&lt;/li&gt;
&lt;li&gt;Returns array&lt;/li&gt;
&lt;li&gt;Empty by default, meant to be overridden
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;priceTaxRates&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets tax rates for individual subscription items&lt;/li&gt;
&lt;li&gt;Returns array&lt;/li&gt;
&lt;li&gt;Empty by default, meant to be overridden&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ManagesCustomer Trait
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Customer Identification
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripeId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Returns Stripe customer ID or null&lt;/li&gt;
&lt;li&gt;No parameters needed&lt;/li&gt;
&lt;li&gt;Returns string|null
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;hasStripeId&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks if customer has Stripe ID&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;No parameters needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Customer Creation and Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;createAsStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creates new Stripe customer&lt;/li&gt;
&lt;li&gt;Options affect customer metadata, email, name, etc.&lt;/li&gt;
&lt;li&gt;Throws exception if customer already exists&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;updateStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Updates existing Stripe customer&lt;/li&gt;
&lt;li&gt;Options determine what gets updated&lt;/li&gt;
&lt;li&gt;Returns updated Stripe Customer object&lt;/li&gt;
&lt;li&gt;Requires existing customer
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;createOrGetStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets existing customer or creates new one&lt;/li&gt;
&lt;li&gt;Options affect creation if needed&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object&lt;/li&gt;
&lt;li&gt;More forgiving than createAsStripeCustomer
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;updateOrCreateStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Updates existing or creates new customer&lt;/li&gt;
&lt;li&gt;Options affect both update and creation&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object&lt;/li&gt;
&lt;li&gt;Combines update and create functionality
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;syncStripeCustomerDetails&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Syncs local details to Stripe&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object&lt;/li&gt;
&lt;li&gt;Uses model attributes for sync
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;syncOrCreateStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Syncs if exists or creates new customer&lt;/li&gt;
&lt;li&gt;Options affect creation if needed&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;asStripeCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$expand&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets Stripe customer object&lt;/li&gt;
&lt;li&gt;Expand parameter determines related data&lt;/li&gt;
&lt;li&gt;Returns Stripe Customer object&lt;/li&gt;
&lt;li&gt;Requires existing customer&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Customer Attributes
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripeName&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets name for Stripe sync&lt;/li&gt;
&lt;li&gt;Returns string|null&lt;/li&gt;
&lt;li&gt;Default returns $this-&amp;gt;name
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripeEmail&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets email for Stripe sync&lt;/li&gt;
&lt;li&gt;Returns string|null&lt;/li&gt;
&lt;li&gt;Default returns $this-&amp;gt;email
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripePhone&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets phone for Stripe sync&lt;/li&gt;
&lt;li&gt;Returns string|null&lt;/li&gt;
&lt;li&gt;Default returns $this-&amp;gt;phone
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripeAddress&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets address for Stripe sync&lt;/li&gt;
&lt;li&gt;Returns array|null&lt;/li&gt;
&lt;li&gt;Empty by default
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripePreferredLocales&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets preferred locales for Stripe&lt;/li&gt;
&lt;li&gt;Returns array&lt;/li&gt;
&lt;li&gt;Empty by default
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;stripeMetadata&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets metadata for Stripe&lt;/li&gt;
&lt;li&gt;Returns array&lt;/li&gt;
&lt;li&gt;Empty by default&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Discount Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets active customer discount&lt;/li&gt;
&lt;li&gt;Returns Discount object or null&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;applyCoupon&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$coupon&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Applies coupon to customer&lt;/li&gt;
&lt;li&gt;Void return&lt;/li&gt;
&lt;li&gt;Requires coupon ID
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;applyPromotionCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$promotionCodeId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Applies promotion code to customer&lt;/li&gt;
&lt;li&gt;Void return&lt;/li&gt;
&lt;li&gt;Requires promotion code ID
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;findPromotionCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds promotion code&lt;/li&gt;
&lt;li&gt;Returns PromotionCode object or null&lt;/li&gt;
&lt;li&gt;Options affect search
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;findActivePromotionCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds active promotion code&lt;/li&gt;
&lt;li&gt;Returns PromotionCode object or null&lt;/li&gt;
&lt;li&gt;Options affect search&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Balance Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;balance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets formatted customer balance&lt;/li&gt;
&lt;li&gt;Returns string&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;rawBalance&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets raw customer balance&lt;/li&gt;
&lt;li&gt;Returns integer&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;balanceTransactions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$limit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets customer balance transactions&lt;/li&gt;
&lt;li&gt;Returns Collection&lt;/li&gt;
&lt;li&gt;Limit affects returned count
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;creditBalance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Credits customer balance&lt;/li&gt;
&lt;li&gt;Returns CustomerBalanceTransaction&lt;/li&gt;
&lt;li&gt;Amount is required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;debitBalance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Debits customer balance&lt;/li&gt;
&lt;li&gt;Returns CustomerBalanceTransaction&lt;/li&gt;
&lt;li&gt;Amount is required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;applyBalance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Applies balance adjustment&lt;/li&gt;
&lt;li&gt;Returns CustomerBalanceTransaction&lt;/li&gt;
&lt;li&gt;Amount is required&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tax Management
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;taxIds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets customer tax IDs&lt;/li&gt;
&lt;li&gt;Returns Collection&lt;/li&gt;
&lt;li&gt;Options affect retrieval
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;createTaxId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creates new tax ID&lt;/li&gt;
&lt;li&gt;Returns Stripe TaxId&lt;/li&gt;
&lt;li&gt;Both parameters required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;deleteTaxId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Deletes tax ID&lt;/li&gt;
&lt;li&gt;Void return&lt;/li&gt;
&lt;li&gt;Requires tax ID
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;findTaxId&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds specific tax ID&lt;/li&gt;
&lt;li&gt;Returns Stripe TaxId or null&lt;/li&gt;
&lt;li&gt;Requires tax ID&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tax Status Checking
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;isNotTaxExempt&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks if customer is not tax exempt&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;isTaxExempt&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks if customer is tax exempt&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;No parameters needed
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;reverseChargeApplies&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Checks if reverse charge applies&lt;/li&gt;
&lt;li&gt;Returns boolean&lt;/li&gt;
&lt;li&gt;No parameters needed&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Billing Portal
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;billingPortalUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$returnUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets Stripe billing portal URL&lt;/li&gt;
&lt;li&gt;Returns string&lt;/li&gt;
&lt;li&gt;ReturnUrl optional
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;redirectToBillingPortal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$returnUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Redirects to Stripe billing portal&lt;/li&gt;
&lt;li&gt;Returns RedirectResponse&lt;/li&gt;
&lt;li&gt;ReturnUrl optional&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ManagesInvoices Trait
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Invoice Items
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;tab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Adds invoice item&lt;/li&gt;
&lt;li&gt;Returns Stripe InvoiceItem&lt;/li&gt;
&lt;li&gt;Description and amount required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;tabPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$quantity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Adds price-based item&lt;/li&gt;
&lt;li&gt;Returns Stripe InvoiceItem&lt;/li&gt;
&lt;li&gt;Price ID required&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Invoice Creation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;invoiceFor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$amount&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$tabOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$invoiceOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creates immediate invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object&lt;/li&gt;
&lt;li&gt;Description and amount required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;invoicePrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$quantity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$tabOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$invoiceOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creates price-based invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object&lt;/li&gt;
&lt;li&gt;Price ID required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;invoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Generates invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object&lt;/li&gt;
&lt;li&gt;Options affect creation
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;createInvoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Creates Stripe invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object&lt;/li&gt;
&lt;li&gt;Options affect creation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Invoice Retrieval
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;upcomingInvoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets upcoming invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object or null&lt;/li&gt;
&lt;li&gt;Options affect preview
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;findInvoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds specific invoice&lt;/li&gt;
&lt;li&gt;Returns Invoice object or null&lt;/li&gt;
&lt;li&gt;Requires invoice ID
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;findInvoiceOrFail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Finds invoice or throws exception&lt;/li&gt;
&lt;li&gt;Returns Invoice object&lt;/li&gt;
&lt;li&gt;Requires invoice ID&lt;/li&gt;
&lt;li&gt;Throws NotFoundHttpException or AccessDeniedHttpException
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;downloadInvoice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nv"&gt;$filename&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets invoice PDF&lt;/li&gt;
&lt;li&gt;Returns Response&lt;/li&gt;
&lt;li&gt;ID required, filename optional
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;invoices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$includePending&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$parameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets all invoices&lt;/li&gt;
&lt;li&gt;Returns Collection&lt;/li&gt;
&lt;li&gt;Parameters affect filtering
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;invoicesIncludingPending&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$parameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets all invoices including pending&lt;/li&gt;
&lt;li&gt;Returns Collection&lt;/li&gt;
&lt;li&gt;Shorthand for invoices(true)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nf"&gt;cursorPaginateInvoices&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$perPage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;array&lt;/span&gt; &lt;span class="nv"&gt;$parameters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[],&lt;/span&gt; &lt;span class="nv"&gt;$cursorName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'cursor'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nv"&gt;$cursor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Gets paginated invoices&lt;/li&gt;
&lt;li&gt;Returns CursorPaginator&lt;/li&gt;
&lt;li&gt;Multiple parameters affect pagination&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Key Observations
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Parameter Sensitivity&lt;/strong&gt;: Methods often have different behaviors based on parameter presence.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Return Types&lt;/strong&gt;: Methods consistently return specific types (boolean, objects, collections).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default Values&lt;/strong&gt;: Many parameters have reasonable defaults but can be overridden.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trait Interdependence&lt;/strong&gt;: Methods often rely on other trait methods.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stripe Integration&lt;/strong&gt;: Most methods interact with Stripe's API either directly or indirectly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Always check parameter requirements for desired behavior.&lt;/li&gt;
&lt;li&gt;Handle potential exceptions, especially for *OrFail methods.&lt;/li&gt;
&lt;li&gt;Use proper type hinting when extending these traits.&lt;/li&gt;
&lt;li&gt;Test different parameter combinations thoroughly.&lt;/li&gt;
&lt;li&gt;Consider caching frequent calls to reduce API requests.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;These traits form the backbone of Laravel Cashier's functionality. Understanding the full scope of available methods and their parameter behaviors is crucial for proper implementation. Always consult the official documentation alongside this reference for the most up-to-date information.&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>php</category>
      <category>stripe</category>
      <category>ecommerce</category>
    </item>
  </channel>
</rss>
