Session initialization sequence for community-patterns development. Use at the start of every Claude Code session. Checks for upstream updates, loads workspace configuration, and ensures dev servers are running.
Follow these steps IN ORDER on every session:
Always check for updates from upstream first:
# Check if updates are available
git fetch upstream 2>/dev/null || echo "No upstream configured"
git status
# If behind upstream/main, pull updates
# Example output: "Your branch is behind 'upstream/main' by 3 commits"
If updates available:
# Pull updates (will update CLAUDE.md, GETTING_STARTED.md, examples, etc.)
git pull --rebase upstream main
# If rebase succeeds
git push origin main
# If conflicts (rare - user files are in their namespace)
# Show conflicts and help resolve
Why this matters:
After updating community-patterns, also update labs/ and patterns/ (if they exist):
# Get parent directory
PARENT_DIR="$(git rev-parse --show-toplevel)/.."
# Update labs (required)
if [ -d "$PARENT_DIR/labs" ]; then
echo "Updating labs repository..."
cd "$PARENT_DIR/labs"
git fetch origin
git pull --rebase origin main
cd -
else
echo "⚠️ labs/ not found - user may need to clone it"
fi
# Update patterns (optional)
if [ -d "$PARENT_DIR/patterns" ]; then
echo "Updating patterns repository..."
cd "$PARENT_DIR/patterns"
git fetch origin
git pull --rebase origin main
cd -
fi
Tell user:
Updated dependency repositories (labs and patterns if available).
[If found updates]: Pulled latest updates! This includes:
- Updated documentation
- New example patterns
- [list what changed if significant]
[If no updates]: Already up to date with upstream.
If it's been a while since last check, check for reference repo updates:
# Get parent directory
PARENT_DIR="$(git rev-parse --show-toplevel)/.."
# Check if labs or patterns need updating
cd "$PARENT_DIR/labs" && git fetch origin && git status
cd "$PARENT_DIR/patterns" && git fetch origin && git status 2>/dev/null
If updates available, update automatically:
# Pull updates
cd "$PARENT_DIR/labs" && git pull origin main
# Restart both servers using the labs script
$PARENT_DIR/labs/scripts/restart-local-dev.sh --force
echo "Both dev servers restarted with latest labs updates"
echo "Toolshed (backend): http://localhost:8000"
echo "Shell (frontend): http://localhost:5173"
echo "Logs: $PARENT_DIR/labs/packages/toolshed/local-dev-toolshed.log"
echo " $PARENT_DIR/labs/packages/shell/local-dev-shell.log"
Important Notes:
Why we need this: Your GitHub username is used for:
patterns/$GITHUB_USER/ directory is yoursLoad cached configuration:
# Read workspace config (created during first-time setup)
if [ -f .claude-workspace ]; then
GITHUB_USER=$(grep "^username=" .claude-workspace | cut -d= -f2)
IS_FORK=$(grep "^is_fork=" .claude-workspace | cut -d= -f2)
echo "Loaded workspace: patterns/$GITHUB_USER/"
echo "Repository type: $([ "$IS_FORK" = "true" ] && echo "fork" || echo "upstream")"
else
echo "ERROR: .claude-workspace not found - run GETTING_STARTED.md first"
exit 1
fi
If .claude-workspace doesn't exist (shouldn't happen after setup):
# Detect from origin remote URL (most reliable)
ORIGIN_URL=$(git remote get-url origin)
GITHUB_USER=$(echo "$ORIGIN_URL" | sed -E 's/.*[:/]([^/]+)\/community-patterns.*/\1/')
# Detect if this is a fork (has upstream remote)
if git remote get-url upstream >/dev/null 2>&1; then
IS_FORK=true
else
IS_FORK=false
fi
# Create workspace config file
cat > .claude-workspace << EOF
username=$GITHUB_USER
is_fork=$IS_FORK
setup_complete=true
EOF
echo "Created .claude-workspace for: $GITHUB_USER"
echo "Repository type: $([ "$IS_FORK" = "true" ] && echo "fork" || echo "upstream")"
Confirm with user:
Ready to work! Your workspace: patterns/$GITHUB_USER/
What would you like to work on today?
About is_fork configuration:
is_fork=true): User has their own fork with upstream remote
pointing to jkomoros/community-patterns
upstream/main before creating PRsis_fork=false): User working directly on
jkomoros/community-patterns (e.g., jkomoros or collaborators)
origin/main before creating PRsgit remote - it won't
change during developmentIMPORTANT: Two servers must be running:
First, check if servers are already running:
# Check both ports
TOOLSHED_RUNNING=$(lsof -ti:8000 > /dev/null 2>&1 && echo "yes" || echo "no")
SHELL_RUNNING=$(lsof -ti:5173 > /dev/null 2>&1 && echo "yes" || echo "no")
if [ "$TOOLSHED_RUNNING" = "yes" ] && [ "$SHELL_RUNNING" = "yes" ]; then
echo "✓ Both dev servers already running:"
echo " - Toolshed (backend): http://localhost:8000"
echo " - Shell (frontend): http://localhost:5173"
echo ""
echo "Servers are ready. No need to start them."
elif [ "$TOOLSHED_RUNNING" = "yes" ]; then
echo "✓ Toolshed already running on port 8000"
echo "✗ Shell not running - will start it"
NEED_SHELL=1
elif [ "$SHELL_RUNNING" = "yes" ]; then
echo "✓ Shell already running on port 5173"
echo "✗ Toolshed not running - will start it"
NEED_TOOLSHED=1
else
echo "✗ No dev servers running - will start both"
NEED_TOOLSHED=1
NEED_SHELL=1
fi
If servers are already running, STOP HERE and skip the rest of this step.
Tell the user: "I can see your dev servers are already running. Skipping server startup."
Only if servers need to be started, run this:
# Get labs directory
LABS_DIR="$(git rev-parse --show-toplevel)/../labs"
# Use the labs restart script (handles starting servers properly)
if [ "$NEED_TOOLSHED" = "1" ] || [ "$NEED_SHELL" = "1" ]; then
$LABS_DIR/scripts/restart-local-dev.sh --force
echo "Dev servers started. Access at http://localhost:8000"
echo "Logs:"
echo " - Toolshed: $LABS_DIR/packages/toolshed/local-dev-toolshed.log"
echo " - Shell: $LABS_DIR/packages/shell/local-dev-shell.log"
fi
Why this matters:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer