home / skills / trentshaines / dotfiles / trent-local-server-prod

trent-local-server-prod skill

/dot_claude/skills/trent-local-server-prod

This skill deploys a local production-configured server split across panes for backend and frontend, enabling prod testing locally.

npx playbooks add skill trentshaines/dotfiles --skill trent-local-server-prod

Review the files below or copy the command above to add this skill to your agents.

Files (1)
skill.md
1.9 KB
---
name: trent-local-server-prod
description: Deploy the duet local development server pointing to production (DECAGON_ENV=prod). Use when the user asks to start the local server against prod, run the dev environment with prod, or test locally against production.
---

# Local Server Deployment (Production)

Deploy the local development server pointing to the production environment by running both backend and frontend in separate tmux panes with `DECAGON_ENV=prod`.

## Instructions

1. Split the current tmux pane horizontally to create a second pane
2. Split again to create a third pane (for the original shell to remain usable)
3. In the first split pane, run the backend with prod env:
   ```bash
   DECAGON_ENV=prod uv pip install -r backend/requirements.in && DECAGON_ENV=prod uvicorn backend.server_cs.server:app --reload
   ```
4. In the second split pane, run the frontend with prod env:
   ```bash
   cd frontend && DECAGON_ENV=prod yarn run dev --webpack
   ```

## Tmux Commands

Use pane IDs for robustness (relative targets like `{right}` fail when other panes exist):

```bash
# Split horizontally for backend, capturing the pane ID
BACKEND_PANE=$(tmux split-window -h -P -F '#{pane_id}')

# Run backend install and server in that pane using its ID
tmux send-keys -t "$BACKEND_PANE" 'DECAGON_ENV=prod uv pip install -r backend/requirements.in && DECAGON_ENV=prod uvicorn backend.server_cs.server:app --reload' Enter

# Split the backend pane vertically for frontend, capturing the pane ID
FRONTEND_PANE=$(tmux split-window -v -t "$BACKEND_PANE" -P -F '#{pane_id}')

# Run frontend in the new pane using its ID
tmux send-keys -t "$FRONTEND_PANE" 'cd frontend && DECAGON_ENV=prod yarn run dev --webpack' Enter
```

## Expected Result

- Backend API running at http://localhost:8000 (with hot reload, pointing to prod)
- Frontend Next.js dev server running at http://localhost:3000 (pointing to prod)
- Original pane remains available for other commands

Overview

This skill deploys a local development environment that points to the production configuration (DECAGON_ENV=prod). It launches backend and frontend processes in separate tmux panes so you can run, test, and iterate locally while targeting production resources. The original tmux pane stays available for other commands.

How this skill works

The skill automates splitting the current tmux window into three panes and runs the backend and frontend dev servers with DECAGON_ENV=prod. It installs backend Python requirements and starts uvicorn with reload enabled, and starts the Next.js frontend dev server with yarn. Pane IDs are captured and used to send commands reliably.

When to use it

  • You need to test local changes against production services or data.
  • You want to run backend and frontend concurrently while pointing both to prod.
  • You need hot-reload backend while evaluating production environment behavior.
  • You prefer using tmux to manage persistent panes for dev workflows.
  • You must keep an interactive pane available for debugging or auxiliary commands.

Best practices

  • Run this from the project root so relative paths (backend/, frontend/) resolve correctly.
  • Ensure tmux is installed and you are inside a tmux session before running pane-splitting commands.
  • Verify credentials and access to production resources are appropriate and safe for local testing.
  • Use the original pane for monitoring logs, running migrations, or running one-off commands.
  • Stop services and clean up panes when finished to avoid accidental prod-side effects.

Example use cases

  • Reproduce a production-only bug locally while using production data endpoints.
  • Validate frontend behavior when backend is served with production configuration.
  • Develop backend fixes with hot reload while keeping the frontend connected to prod.
  • Run quick integration checks after a change to configuration that only affects prod.

FAQ

Do I need to be in a tmux session?

Yes. The commands split and target tmux panes; start a tmux session first (tmux new -s session_name).

Will this modify production systems?

No code is deployed to production, but local servers will point to production resources. Be careful with any write operations.

What ports will the servers use?

Backend runs at http://localhost:8000 and frontend runs at http://localhost:3000 by default.