OpenParable
Skip to content
← Back to skills

Livecodes

Apps & Automation
livecodes

Livecodes is an Agent Skill for apps & automation published in the live-codes/livecodes repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Open-source, client-side code playground supporting 90+ languages/frameworks. Runs entirely in the browser with SDK for embedding. Entry point for all LiveCodes skills.

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/live-codes/livecodes/blob/HEAD/.agents/skills/livecodes/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/livecodes, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

LiveCodes Overview

LiveCodes is a feature-rich, open-source, client-side code playground that runs entirely in the browser. No server required. Supports 90+ languages/frameworks with a powerful SDK for embedding in any web application.

CRITICAL: LiveCodes runs CLIENT-SIDE. No server, no build step, no backend. Do not confuse with server-based playgrounds.

CRITICAL: All SDK methods are async (return Promises). Always await them or use .then().

Sub-Skills

TaskSub-Skill
Quick start for beginnerslivecodes/getting-started/SKILL.md
Create embedded playgroundslivecodes/sdk-embedding/SKILL.md
Use SDK methods (run, getCode, setConfig, watch)livecodes/sdk-methods/SKILL.md
Compress/decompress config utilitieslivecodes/sdk-embedding/SKILL.md
Configure via Config object, query paramslivecodes/configuration/SKILL.md
Choose display mode (full, simple, result, etc.)livecodes/display-modes/SKILL.md
Run playgrounds without visible UIlivecodes/headless-mode/SKILL.md
Import/export code (GitHub, gists, files)livecodes/import-export/SKILL.md
Work with 90+ languages and processorslivecodes/language-support/SKILL.md
Import npm packages without bundlerlivecodes/module-resolution/SKILL.md
Write and run tests in the playgroundlivecodes/testing/SKILL.md
Use with React, Vue, Svelte, Solid, Preactlivecodes/framework-wrappers/SKILL.md
Integrate with docs sites (Docusaurus, Astro)livecodes/markdown-integration/SKILL.md
Self-host on your own serverlivecodes/self-hosting/SKILL.md
Preview PRs in LiveCodes (GitHub Action)livecodes/gh-action/SKILL.md

Quick Decision Tree

New to LiveCodes?
  → livecodes/getting-started

Need to embed a playground in your app?
  → livecodes/sdk-embedding

Need to control playground programmatically?
  → livecodes/sdk-methods

Need to configure project content (languages, theme, etc.)?
  → livecodes/configuration

Need to show code readonly or result-only?
  → livecodes/display-modes

Need to run playground without any UI?
  → livecodes/headless-mode

Need to use React/Vue/Svelte/etc.?
  → livecodes/framework-wrappers

Need to import npm packages or external modules?
  → livecodes/module-resolution

Need a specific language (Python, SASS, TypeScript)?
  → livecodes/language-support

Need to run tests in the playground?
  → livecodes/testing

Need to import code from GitHub/URL or export?
  → livecodes/import-export

Need to add playgrounds to markdown docs?
  → livecodes/markdown-integration

Need to host LiveCodes on your own server?
  → livecodes/self-hosting

Need to preview PR changes in playgrounds?
  → livecodes/gh-action

Minimal Working Example

CDN (quickest)

<!doctype html>
<html>
  <head>
    <title>LiveCodes Demo</title>
  </head>
  <body>
    <div id="container"></div>
    <script type="module">
      import { createPlayground } from 'https://cdn.jsdelivr.net/npm/livecodes';

      createPlayground('#container', {
        config: {
          markup: { language: 'html', content: '<h1>Hello LiveCodes!</h1>' },
          style: { language: 'css', content: 'h1 { color: blue; }' },
          script: { language: 'javascript', content: 'console.log("Hello!");' },
        },
      });
    </script>
  </body>
</html>

NPM

npm install livecodes
import { createPlayground } from 'livecodes';

const playground = await createPlayground('#container', {
  config: {
    markup: { language: 'html', content: '<h1>Hello!</h1>' },
  },
});

// SDK methods are async - always await
await playground.run();
const code = await playground.getCode();

React

import { useState } from 'react';
import LiveCodes from 'livecodes/react';

export default function App() {
  const [playground, setPlayground] = useState(null);

  return (
    <>
      <LiveCodes
        config={{ markup: { language: 'html', content: '<h1>Hello!</h1>' } }}
        sdkReady={setPlayground}
      />
      <button onClick={() => playground?.run()}>Run</button>
    </>
  );
}

Common Mistakes

HIGH: SDK methods return Promises - always await

// WRONG - code is a Promise, not actual code
const code = playground.getCode();
console.log(code.markup); // undefined!

// CORRECT - await the Promise
const code = await playground.getCode();
console.log(code.markup.content); // '<h1>Hello!</h1>'

HIGH: Container must exist before createPlayground

// WRONG - container doesn't exist yet
createPlayground('#container', { config }); // throws if #container not in DOM

// CORRECT - ensure container exists
const container = document.querySelector('#container');
if (container) {
  createPlayground('#container', { config });
}

// OR use headless mode if no UI needed
createPlayground({ headless: true, config });

HIGH: Config vs EmbedOptions confusion

// WRONG - appUrl is not a config property
createPlayground('#container', {
  config: {
    appUrl: 'https://my-server.com', // ERROR: wrong place
  },
});

// CORRECT - appUrl is an EmbedOption, not config
createPlayground('#container', {
  appUrl: 'https://my-server.com', // EmbedOptions
  config: {
    // Config
    markup: { language: 'html', content: '<h1>Hi</h1>' },
  },
});

MEDIUM: Different CDN imports create separate module instances

// WRONG - two different React instances
import React from 'react'; // esm.sh
import { createRoot } from 'skypack:react-dom/client'; // Different React!

// CORRECT - use same CDN consistently
import React from 'react';
import { createRoot } from 'react-dom/client'; // Both from esm.sh (default)