agentleFS
OKHP3OKHP3/skillz/.agents/skills/okhp3-replit-multi-artifact/SKILL.md

okhp3-replit-multi-artifact

Skill3 starsChanged 2 months agoMITView on GitHub

Navigate and build in a Replit pnpm multi-artifact monorepo without silent failures. Covers the non-obvious rules that cause blank previews, port conflicts, workflow naming errors, and broken cross-artifact imports: BASE_URL prefix discipline, PORT env var reading, managed workflow naming, pnpm catalog drift, and workspace:* shared library wiring. Activate for "add an artifact", "create a new app", "preview path", "port conflict", "blank preview", "shared package", "workflow naming", "pnpm catalog", "cross-artifact", or any time a second artifact is being added to an existing Replit project.

  • Reads credentials

The file

Show its rules and text

We split this skill into the rules it gives an agent

16 rules. About 0 are common, 4 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never call createArtifact twice for the same slug: If artifacts/<slug>/ already exists, the call fails.

    line 69
  2. Very specific:

    Every route and API call in an artifact must prepend import.meta.env.BASE_URL (Vite artifacts) or the equivalent base path helper.

    line 75
  3. Very specific:

    For Expo apps: use the getApiUrl() helper from the Expo scaffold, which reads the dev domain environment variable.

    line 93
  4. Very specific:

    Every artifact's dev server must read the port from the PORT environment variable, not from a hard-coded number.

    line 99
  5. Distinctive:

    Every registered artifact service already has a managed workflow:

    line 130
  6. Very specific:

    Only use configureWorkflow for long-running processes that are not represented by a registered artifact service.

    line 156
  7. Very specific:

    Check the root pnpm-workspace.yaml for a catalog: block.

    line 168
  8. Very specific:

    Run pnpm install from the workspace root after changing pins.

    line 170
  9. Distinctive:

    If a specific version is required (e.g.

    line 171
  10. Very specific:

    Create the library as a package in lib/<name>/ or artifacts/<name>/ with its own package.json declaring "name": "@workspace/<name>".

    line 181
  11. Very specific:

    Run pnpm install from the workspace root so the symlink is created.

    line 186
  12. Distinctive:

    Import from the package name, not a relative path:

    line 187
  13. Distinctive:

    When the preview pane is blank or shows a connection error, work through this list in order:

    line 200
  14. Very specific:

    If all seven are clean and the preview is still blank, read the debug-workflow-ports-issues skill.

    line 212
  15. Very specific:

    When creating a new artifact, createArtifact() handles:

    line 218
  16. Very specific:

    After createArtifact() returns, read the artifact kind's bootstrap skill (see the table above) before writing any code.

    line 224

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

okhp3-replit-multi-artifact

OverKill Hill P³ · overkillhill.com · github.com/OKHP3

Each of the following rules has caused a multi-turn debugging session in a real project. None of them is in the artifact creation walkthrough. This skill exists because knowing the rule before you hit the failure is worth four turns of debugging.


Scope

In scopeOut of scope
BASE_URL prefix ruleArtifact bootstrapping — read the artifacts skill
PORT env var disciplineWorkflow restart mechanics — read the workflows skill
Managed workflow namingPackage installation — read the package-management skill
pnpm catalog driftSecrets / env vars — read the environment-secrets skill
Cross-artifact shared libraries
Blank-preview debug checklist

Artifact kinds and their skills

KindBootstrap skill to readNotes
web (React/Vite)react-viteOpenAPI-first for fullstack; skip codegen for frontend-only
slidesslidesRead BEFORE creating — it runs pre-generation questions
videovideo-jsDelegate entire build to a DESIGN subagent
mobileexpoAsyncStorage by default; no backend on first build
designdesign-system-creationOnly on explicit ask; drives tokens.json
api(none)Pre-configured; do not re-create
mockup-sandboxmockup-sandboxPre-installed; do not call createArtifact

Never call createArtifact twice for the same slug. If artifacts/<slug>/ already exists, the call fails.


Rule 1: BASE_URL prefix — the most common silent failure

Every route and API call in an artifact must prepend import.meta.env.BASE_URL (Vite artifacts) or the equivalent base path helper.

Why. Replit uses path-based routing. Each artifact is mounted at a unique preview path (e.g. /my-app). A root-relative URL like /api/users escapes the artifact's path prefix and hits the wrong route — or a 404. The failure is silent: the URL looks correct in code, the app loads, but API calls return unexpected responses.

Correct:

// artifacts/my-app/src/api/client.ts
const BASE = import.meta.env.BASE_URL; // includes trailing slash
const res = await fetch(`${BASE}api/users`);

Incorrect (do not do):

const res = await fetch('/api/users'); // root-relative — escapes the artifact's mount path

For Expo apps: use the getApiUrl() helper from the Expo scaffold, which reads the dev domain environment variable.


Rule 2: PORT env var — never hard-code a port

Every artifact's dev server must read the port from the PORT environment variable, not from a hard-coded number.

Why. The system assigns a unique port per artifact to avoid collisions. A hard-coded port in Vite config (e.g. server: { port: 3000 }) will either conflict with another artifact or be wrong for the proxy routing. The result is a blank preview pane with no error.

Correct Vite config:

// vite.config.ts
export default defineConfig({
  server: {
    port: parseInt(process.env.PORT || '5000', 10),
    host: '0.0.0.0',
    allowedHosts: true  // required — preview is proxied through an iframe
  }
});

Correct Express config:

// server.ts
const port = parseInt(process.env.PORT || '3001', 10);
app.listen(port, '0.0.0.0');

allowedHosts: true is required for Vite. The preview is a proxied iframe; requests come from a different origin. Without this, Vite rejects them with a 403 and the preview is blank.


Rule 3: Managed workflow naming — do not replace with configureWorkflow

Every registered artifact service already has a managed workflow:

artifacts/<slug>: <service-name>

Examples:

  • artifacts/api-server: API Server
  • artifacts/chai-chasers: web
  • artifacts/mockup-sandbox: Component Preview Server

Never call configureWorkflow to create a replacement workflow for an artifact service. Managed workflows inject service configuration including PORT, BASE_PATH, and proxy routing. A replacement workflow omits this configuration and creates a conflicting preview path.

To start or restart an artifact service, use the WorkflowsRestart tool directly:

// Correct — use WorkflowsRestart tool
// name: "artifacts/chai-chasers: web"

Or in CodeExecution:

await restartWorkflow({ workflowName: "artifacts/chai-chasers: web" });

Only use configureWorkflow for long-running processes that are not represented by a registered artifact service.


Rule 4: pnpm catalog drift — off-catalog pins break plugin typechecks

The workspace root package.json is an implicit pnpm workspace member. Off-catalog pins in any package's package.json — for packages like vite or @types/node — create duplicate store instances.

Symptom: Vite plugin typecheck passes in isolation but fails when the workspace resolves dependencies. TypeScript sees two copies of the same package with incompatible types.

Fix:

  1. Check the root pnpm-workspace.yaml for a catalog: block.
  2. Any package pinned with an exact version (e.g. "vite": "5.4.19") that also appears in the catalog must use "vite": "catalog:" instead.
  3. Run pnpm install from the workspace root after changing pins.
  4. If a specific version is required (e.g. a CVE override), document it explicitly — do not silently pin.

Why the root matters. pnpm treats the root package.json as a workspace member. Off-catalog pins there affect every other member's dependency resolution.


Rule 5: Cross-artifact shared libraries via workspace:*

To share code between artifacts (e.g. a shared utility library or API client):

  1. Create the library as a package in lib/<name>/ or artifacts/<name>/ with its own package.json declaring "name": "@workspace/<name>".
  2. In the consuming artifact's package.json, add:
    { "dependencies": { "@workspace/<name>": "workspace:*" } }
  3. Run pnpm install from the workspace root so the symlink is created.
  4. Import from the package name, not a relative path:
    import { myUtil } from "@workspace/my-lib";

Why workspace:* and not a relative path. Relative paths across package boundaries break TypeScript project references and Vite's module resolution. workspace:* lets pnpm manage the symlink correctly.

After adding a shared dependency: restart the artifact's workflow so Vite picks up the new symlink.


Blank-preview debug checklist

When the preview pane is blank or shows a connection error, work through this list in order:

CheckCommand / action
1. Is the workflow running?Check the workflow panel or listWorkflows() — state must be running
2. Did it open a port?getWorkflowStatus({ name: "..." }) — look for openPorts
3. Is allowedHosts: true in Vite config?Read vite.config.ts — any host restriction causes 403 from proxy
4. Is the server reading PORT?Read server startup code — hard-coded port = wrong port
5. Is BASE_URL prepended to every route/API call?Grep fetch( for root-relative URLs starting with /
6. After code changes, was the workflow restarted?Restart the workflow — hot-reload does not catch all changes
7. pnpm catalog drift?pnpm why <package> — should show one version, not two

If all seven are clean and the preview is still blank, read the debug-workflow-ports-issues skill.


Artifact registration summary

When creating a new artifact, createArtifact() handles:

  • Creating artifacts/<slug>/ with scaffold files
  • Writing artifact.toml
  • Allocating a service port
  • Registering the managed workflow

After createArtifact() returns, read the artifact kind's bootstrap skill (see the table above) before writing any code. The bootstrap skill tells you what to build and in what order.


About

Built from retrospective analysis of the Glee-fully Chai Chasers Designathon project at overkillhill.com. By Jamie Hill · OverKill Hill P³ · github.com/OKHP3 MIT License — free to use, fork, and adapt. A nod to the source is appreciated.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.