Creating slides

From dtyq/magic · View interactive version

Creating slides is an AI agent skill from the GitHub repository dtyq/magic. Slide/PPT creation skill that provides complete slide creation, editing, and management capabilities. Use when users need to create slides, make presentations, edit slide content, configure slide transitions, or manage slide projects. CRITICAL - When user message contains [@slide_project:...] mentio

How to use this skill

Skill file

Creating Slides Skill

Provides complete HTML slide creation capabilities, including project creation, content design, technical specifications, workflows, and best practices.

Core Capabilities


Code Execution Method (Critical)

All Python code examples in this skill must be executed via the run_sdk_snippet tool in Agent environment.

create_slide_project and create_slide are Code Mode only. Call them with

sdk.tool.call, never as directly mounted tools. Before executing, read

slide tool contracts for overwrite behavior, notes,

page registration, and the difference between a saved file and successful layout QA.

Correct example:

# Correct! Must use run_sdk_snippet to execute
run_sdk_snippet(
    python_code="""
from sdk.tool import tool
result = tool.call('create_slide_project', {
    "project_path": "my-project",
    "slides_array": []
})
"""
)

All code blocks in this document starting with from sdk.tool import tool follow this rule: pass them via the python_code parameter of run_sdk_snippet for execution.


Default Requirements

When user has no explicit requirements, follow these defaults:


In-slide builds

When the user requests click-controlled reveals, read

in-page-builds.md. Builds are optional and never required:

the default is no builds. Only when several substantial content blocks on a page are best

presented one at a time may you consider adding them yourself, or offer them to the user,

following the "Proactive use" section there (which also covers remembering the user's habit). Use only its declarative element

attributes; keep HTML static and preserve the existing slide creation/editing workflow.

Proactive builds must follow its "Proactive use" rules: original element animations take

priority, attributes must be exactly as documented, and the user is told what was added.

Never promise native PowerPoint animations.

Slide transitions

When the user requests page transitions, read slide-transitions.md

and the current magic.project.js, then call update_slide_transitions through

sdk.tool.call inside run_sdk_snippet (Code Mode only). Collect default and page settings

in one operations batch and save once. An unknown outcome requires rereading before further

writes to that configuration. Keep slide HTML static.

Do not add transitions without a request. Preserve existing settings, including explicit none,

during content editing, template replacement, and regeneration. These settings apply to the

online player; do not promise native PowerPoint transitions or standalone index.html playback.

Technical Specifications

Size and Implementation

Speaker notes contract

Every generated slide must contain one inert speaker-notes block outside the visual slide DOM:

<template data-magic-slide-notes data-format="plain-text" data-version="1">
Speaker notes for this page.
</template>

Generate concise, presentation-ready notes from the page purpose, visible content, audience, and narrative flow. Keep the block outside the rendered canvas. When editing an existing slide, preserve the block and update it whenever the page's message changes. Do not place speaker notes in visible slide elements or remove an existing block unless the user explicitly asks to clear it.

Inter-slide Links

CSS Frameworks and Resources

Technical Constraints

Tailwind Mandatory Specification

Font Size Specification (1920×1080 canvas requires large fonts)

Visual Hierarchy

Font size contrast (main title differs from body by 3-4 levels) + weight contrast (title font-bold/black) + color contrast (title text-gray-900, body text-gray-600/700) + spatial contrast (important elements mb-8/10/12) + decorative elements (number labels, color blocks, vertical bars)


Design Principles

Content Design Mindset

Image Requirements

Design Style

Default style: Minimalist business style

Style selection: Based on content theme and target audience, derive from minimalist business style, imitate popular PPT design styles including but not limited to:

Layout Design Core Principles

Use predefined grid (grid-cols-2/3, grid-rows-2) with gap-4/6/8 unified spacing, flexibly control element space occupation through col-span-2, row-span-2, avoid pixel values defining grid size, use fr units or percentages; Flex layout uses TailwindCSS proportional width classes (w-1/2, w-1/3, w-2/3) prohibited hardcoded pixels, leverage flex-1, justify-between, items-center to achieve responsive layout and balanced content distribution.

Height Control Technique (Critical)

[Hard Requirement] Page height must strictly not exceed 1080px, this is a non-negotiable specification!

If content is too much for a single page, must split into multiple pages, absolutely not allowed to let single page exceed 1080px height.

Reasonable slide height control is extremely important. A simple effective approach is using Grid horizontal card layout, maximize horizontal space use, control similar left-right content amounts, aligned arrangement, overall neat typography.

During conception, page preceding elements should choose height-sensitive elements (usually need sufficient space), subsequent elements/content use height-insensitive elements (usually can adapt to remaining space, like charts), so only need to consider preceding element heights, set subsequent element/content heights to fill remaining height.

While ensuring page is visually full, absolutely don't cram too much readable substantive content in one page.

Please think through above points step by step during design, ensure perfect page layout and height control. Unless user has conflicting requirements, must default to this approach for page layout and height control.

Image Usage Technique

Images are very dangerous, hard-to-control elements in slide creation. Need to plan space with similar aspect ratio to place images, carry images through container elements, let images fill container. Container width and height should use relative units (like percentages, fr units) or Grid layout's automatic allocation mechanism, not fixed, often miscalculated pixel values, otherwise images often overflow canvas causing layout chaos.

Content-related images may also be used as local section backgrounds to add depth. Put an independent overlay layer above the background image and keep text/cards in a separate foreground layer. Do not apply opacity to a container that also holds text.

<div
  class="relative"
  style="background-image:url('images/xxx.jpg');
     background-size:cover;background-position:center;"
>
  <div class="absolute inset-0" style="background:rgba(14,20,32,0.60);"></div>
  <div class="relative z-10"><!-- content --></div>
</div>

Use background images selectively. Avoid repeating the same full-image treatment on most consecutive slides; alternate with charts, cards, diagrams, or clean graphic pages.

Default Design Mindset

Slides overall have premium feel, use rich decorative elements, conform to industry mainstream aesthetic practices, but don't introduce too much complexity. Note slide height control and neat typography, don't cram too much content in one page, this is key.


ECharts Configuration Requirements

Multi-axis alignment:

Visual requirements:


Data Analysis Processing

When scenarios involve data analysis, write Python scripts for analysis:


Slide HTML Template

Reference the following template to create slide pages. Each page is an independent HTML file, style should be consistent but can have appropriate variations, comments are for your understanding only, omit in actual development.

<!DOCTYPE html>
<html lang="zh">
  <head>
    <meta charset="utf-8" />
    <meta content="width=device-width, initial-scale=1.0" name="viewport" />
    <title>Slide Title</title>
    <script src="https://cdn.tailwindcss.com/3.4.17"></script>
    <link
      href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css"
      rel="stylesheet"
    />
    <link
      href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap"
      rel="stylesheet"
    />
    <style>
      html,
      body {
        width: 1920px;
        height: 1080px; /* DO NOT set height or max-height, allow extreme cases to exceed */
        font-family:
          "Noto Sans SC",
          -apple-system,
          BlinkMacSystemFont,
          "Segoe UI",
          "PingFang SC",
          "Hiragino Sans GB",
          "Microsoft YaHei",
          sans-serif;
        /* more styles can be added here... */
      }

      .slide-container {
        width: 1920px;
        height: 1080px;
        /* padding: Adjust according to design needs */
        /* more styles can be added here... */
      }
    </style>
  </head>
  <body>
    <div class="slide-container">
      <!-- Page content goes here -->
    </div>
    <!--
    IMPORTANT: This script must be included in every generated slide page.
    Simply copy this line as-is - no need to read or understand the script content.
    It enables keyboard navigation and title synchronization with the parent page.
    -->
    <script src="slide-bridge.js"></script>
  </body>
</html>

Quick Start

Reminder: All code examples below must be executed via run_sdk_snippet(python_code="..."). Refer to the "Code Execution Method" section at the top of this document.

Create Slide Project

For the planned project example, first prepare production_plan as the complete

Markdown described in Production plan format.

Its three page entries must match cover.html, product-intro.html, and key-features.html.

from sdk.tool import tool

# Create empty project (add pages later)
result = tool.call('create_slide_project', {
    "project_path": "ChatGPT-Evolution-Report",
    "slides_array": [],
    "slide_images_content": "",
    "todo_list": ""
})

# Create a project skeleton with images and a complete design plan
result = tool.call('create_slide_project', {
    "project_path": "Product-Launch",
    "slides_array": ["cover.html", "product-intro.html", "key-features.html"],
    "slide_images_content": """# Slide Image Library

## Project Info
- Search topic: Product Launch
- Collected at: 2025-01-22 10:30:00
- Total images: 5

## Image Categories

### Cover / Hero

![product-hero.jpg](https://example.com/image1.jpg)
- Index: 1
- Size: 1920x1080px (16:9, horizontal)
- Visual Analysis: Modern tech product close-up, white background, professional lighting
- Use Case: Cover hero image
- Search Keywords: product hero image modern technology
""",
    "todo_list": production_plan
})
print(result.content)

Create Single Slide Page

from sdk.tool import tool

result = tool.call('create_slide', {
    "file_path": "ChatGPT-Evolution-Report/OpenAI-Milestones.html",
    "content": """<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <title>OpenAI Milestones</title>
    <script src="https://cdn.tailwindcss.com/3.4.17"></script>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css" rel="stylesheet"/>
    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap" rel="stylesheet"/>
    <style>
        html, body {
            width: 1920px;
            height: 1080px;
            font-family: 'Noto Sans SC', sans-serif;
        }
        .slide-container {
            width: 1920px;
            height: 1080px;
        }
    </style>
</head>
<body>
    <div class="slide-container bg-gradient-to-br from-blue-50 to-white flex items-center justify-center">
        <div class="text-center">
            <h1 class="text-7xl font-bold text-gray-900 mb-8">OpenAI Milestones</h1>
            <p class="text-3xl text-gray-600">Key moments in AI development</p>
        </div>
    </div>
    <script src="slide-bridge.js"></script>
</body>
</html>""",
    "max_width": 1920,
    "max_height": 1080,
    "analysis_js": """
const issues = [];
const container = document.querySelector('.slide-container');
if (container) {
    const {x, y, width, height} = container.getBoundingClientRect();
    if (y + height > maxHeight) {
        issues.push(`Container bottom overflow: ${Math.round(y+height)} > ${maxHeight}`);
    }
}
return issues.length > 0 ? issues.join(', ') : 'Layout check passed';
""",
    "insert_after_slide": ""
})

# Second page
result = tool.call('create_slide', {
    "file_path": "ChatGPT-Evolution-Report/Development-Timeline.html",
    "content": """...""",
    "max_width": 1920,
    "max_height": 1080,
    "analysis_js": """...""",
    "insert_after_slide": "OpenAI-Milestones.html"
})

# Third page
result = tool.call('create_slide', {
    "file_path": "ChatGPT-Evolution-Report/Technical-Breakthroughs.html",
    "content": """...""",
    "max_width": 1920,
    "max_height": 1080,
    "analysis_js": """...""",
    "insert_after_slide": "Development-Timeline.html"
})

Search Image Materials

from sdk.tool import tool

result = tool.call('image_search', {
    "search_group_name": "product-report-images",
    "requirements": [
        {
            "name": "Product Interface",
            "query": "Example App product interface screenshot",
            "visual_understanding_prompt": "Confirm the image shows the product interface and recognizable features.",
            "requirement_explanation": "Use a product interface screenshot to illustrate the main features.",
            "expected_aspect_ratio": "16:9",
            "count": 5
        },
        {
            "name": "Technology Background",
            "query": "AI technology abstract background",
            "visual_understanding_prompt": "Assess whether the content is suitable as a technology-themed background.",
            "requirement_explanation": "Use an abstract technology image as a slide background.",
            "expected_aspect_ratio": "16:9",
            "count": 3
        }
    ]
})
print(result.content)

Web Content Retrieval

from sdk.tool import tool

# Search web pages
search_result = tool.call('web_search', {
    "search_group_name": "industry-report",
    "requirements": [
        {
            "name": "Industry Overview",
            "query": "enterprise AI software industry report",
            "limit": 10,
            "language": "en-US",
            "region": "US"
        },
        {
            "name": "Recent Developments",
            "query": "enterprise AI software product updates",
            "limit": 10,
            "language": "en-US",
            "region": "US",
            "time_period": "month"
        }
    ]
})
print(search_result.content)

# Read high-value webpages (refer to separate documentation for this tool)
# read_result = tool.call('read_webpages_as_markdown', {...})

Core Tools and Parameters

create_slide_project - Create Slide Project

| Parameter | Required | Type | Description |

| ---------------------- | -------- | ------ | ------------------------------------------------------------------------------- |

| project_path | Yes | string | Project relative path (folder name), e.g., "ChatGPT-Development-Report" |

| slide_count | No | number | Requested page count, default 0; does not create page HTML |

| slides_array | No | array | Ordered slide filenames; defaults to empty array [] |

| slide_images_content | No | string | Image material library content (Markdown format), empty means not creating file |

| todo_list | No | string | Task planning content (Markdown format), empty means not creating file |

Tool Functions:

create_slide - Create Slide Page

| Parameter | Required | Type | Description |

| -------------------- | -------- | ------ | --------------------------------------------------------------------------------- |

| file_path | Yes | string | Slide file path (relative to working directory), e.g., "project-name/page.html" |

| content | Yes | string | Complete HTML content |

| speaker_notes | No | string | Omit to preserve existing notes or create an empty block; "" clears notes; text replaces them |

| max_width | Yes | number | Expected max width (usually 1920) |

| max_height | Yes | number | Expected max height (usually 1080) |

| analysis_js | Yes | string | Layout analysis JavaScript function body (without function declaration) |

| insert_after_slide | Yes | string | New slide position: "" for first page, filename to insert after; ignored for existing slides |

Tool Functions:

analysis_js Instructions:

insert_after_slide Instructions:

image_search - Batch Search Images

| Parameter | Required | Type | Description |

| ------------------ | -------- | ------ | -------------------------------------------- |

| search_group_name | Yes | string | Short name you create for related searches. Reuse the exact name within a group and choose a new name for a separate group. Images are deduplicated within each group; do not use the platform conversation ID. |

| requirements | Yes | array | Non-empty list of search requirement objects; each item runs one search |

Each requirements item contains:

Key Principles:

web_search - Web Search

| Parameter | Required | Type | Description |

| ------------------ | -------- | ------ | -------------------------------------------- |

| search_group_name | Yes | string | Short name you create for related searches. Reuse the exact name within a group and choose a new name for a separate group. This labels results without deduplication; do not use the platform conversation ID. |

| requirements | Yes | array | Non-empty list of search requirement objects; each item runs one search |

Each requirements item contains:


Project Architecture

Slide projects use separated architecture design:

Project Name/
├── index.html          # Presentation controller - handles page navigation, keyboard control, scaling adaptation
├── magic.project.js    # Project config - stores slides array and other config info
├── slide-bridge.js     # Inter-slide communication script
├── images/             # Image resource folder
├── Slide Page 1.html   # Specific slide page
├── Slide Page 2.html   # Specific slide page
└── ...

Architecture Working Principles:

  1. index.html is the core controller of presentation system, containing:
  1. magic.project.js stores project config, including slides array defining slide page path list
  2. slide-bridge.js is inter-slide communication script, auto-generated by create_slide_project tool, no need to read
  3. Each HTML file in project root is a completely independent slide page:
  1. Each slide project must be a complete self-contained project, therefore:

Tool Usage Principles

Tool Restrictions for Slide Creation

Primary Tools (use when creating slides):

Prohibited Tools (don't use when creating slides):

Exceptions:

Tool Selection Principles

Creating Pages: Always use create_slide

Editing Pages:

Project Initialization: Use create_slide_project


Magic Project Mechanism

Core Concept: Folder containing magic.project.js = Frontend recognizes as Magic Project

magic.project.js Operation Constraints:

Frontend Rendering Differentiation:

User Operations:

Project Types: type options include audio, slide, etc. Entire folder called "super deliverable".


Tool Parameter Format Specifications

create_slide_project Parameter Formats

slide_images_content Format Requirements

The slide_images_content parameter should contain complete slide-images.md file content, formatted as follows:

# Slide Image Material Library

## Project Information

- Search Topic: ChatGPT Evolution and Technological Breakthroughs
- Collection Time: 2025-01-22 10:30:00
- Total Images: 15

## Image Categories

### Cover/Hero Images

![{filename.png}]({image URL})

- Index: 1
- Size: {width}x{height}px ({ratio}, {horizontal/vertical/square})
- Visual Analysis: {AI analysis result, excluding size info, describe in detail with minimum words, at least 50 characters}
- Use Case: {recommended usage scenario}
- Search Keywords: {keywords used}

![{filename.png}]({image URL})

- Index: 2
- Size: {width}x{height}px ({ratio}, {horizontal/vertical/square})
- Visual Analysis: {AI analysis result, excluding size info, describe in detail with minimum words, at least 50 characters}
- Use Case: {recommended usage scenario}
- Search Keywords: {keywords used}

### Background Images

![{filename.png}]({image URL})

- Index: 3
  [Each image follows same format, use standard Markdown image syntax with sequential numbering...]

### Product/Content Display Images

![{filename.jpg}]({image URL})

- Index: N
  [Continue with same format, ensure index increments sequentially...]

### Icon/Decorative Images

![{filename.jpg}]({image URL})

- Index: N+1
  [Continue with same format, ensure index increments sequentially...]

Important Notes:

  1. Use standard Markdown image format: ![filename](url)
  2. filename serves as image alt text and also as filename when downloading
  3. filename must include file extension, e.g., .jpg, .png, .webp, etc.
  4. filename should prioritize user's preferred language, be concise and clear, e.g., "trump-assassination-attempt.jpg", "chatgpt-viral-phenomenon.png", "tesla-q4-earnings.jpg"
todo_list Format Requirements

Pass the complete slide-todo.md Markdown, with project information, an overall

design scheme, and a content plan and design specification for every page.

An outline alone is insufficient. Record the palette, typography, shared layout,

decorations, and reusable styling; for each page specify its content, layout,

media and asset readiness, static emphasis, text limits, and visual hierarchy.

When using a template, derive colors and decorations from its actual theme.css

and ensure text and accent colors contrast with the selected backgrounds.

Read Production plan format

for the complete example before preparing this parameter. Adapt it to the user's

language, selected theme, content, and actual page count.

magic.project.js Format Description (slide type)

magic.project.js is a JSONP format project configuration file that defines slide project structure and page list.

File Structure:

window.magicProjectConfig = {
  version: "1.0.0",
  type: "slide",
  name: "Project Name",
  slides: ["cover.html", "contents.html", "content-page.html"],
};
window.magicProjectConfigure(window.magicProjectConfig);

Field Descriptions:

slides Array Characteristics:

Modification Examples:

Use edit_file tool to modify slides array content:

Note: Ensure valid JSONP syntax after modification (valid JavaScript code)


image_search Keyword Strategy

Basic Principles

When using image_search tool, query keywords must be diversified, try 2-3 different keyword combinations for each requirement.

Keyword Language Selection Principles

Judge language based on search intent and information source, try multilingual combinations:

Search Strategy Framework

  1. Core word: Most direct topic word
  2. Qualifier: Core word + attribute/function/scenario
  3. Combination: Multiple related elements combined
  4. Variant: Synonym/abbreviation/colloquialism/multilingual variant

Search Examples

Search iPhone official images:

Search Chinese netizens' comments about Musk (screenshots):

Search international news images about Musk:

Search WeChat function interface:

Search international reports about WeChat:

Search Tesla Shanghai factory (mixed):

Wrong Examples (Avoid)

Keyword Diversification Principles


Create Specific Slide Workflow

If user requests creating specific slides or requests imitating/referencing to generate slides, reference partial workflow of complete creation workflow to flexibly complete user's creation needs.

Best Practices

1. Use create_slide_project to Create Project
2. Use create_slide Through Code Mode to Create Slides
3. Special Handling for Imitate/Reference Scenarios

Complete Creation Workflow

If user has no special requirements, follow this workflow step by step to complete slide creation task:

1. Internet Search

2. Image Search and Content Planning

3. Project Initialization

Call create_slide_project, it will help you complete the following in one go:

4. Slide Content Development

Page-by-page creation workflow:

for each slide:

5. Project Delivery


Edit Slide Workflow

If user requests editing slides, reference the following workflow:

0. Locate target file (when user specifies by page number/index)

1. Workflow reference

2. Edit method selection

3. Tool usage principles


Move or Rename Slide Workflow

If user requests modifying slide file names or paths, reference the following workflow:

  1. Use list_dir tool to get complete project folder hierarchy, determine reasonable adjustment plan
  2. View magic.project.js file in slide project, understand slides array content
  3. Use shell_exec(command="mv old_path new_path") command to move or rename files, use edit_file to update slides array in magic.project.js. In the same configuration update, migrate the matching transitions.slides key from the old path to the new path. Deletion removes its override; copying copies only an explicit override, while an inherited setting stays inherited.

Flexible Project Management


PPTX File Processing Rules


User Terminology

Users have terminology to describe actions for specified pages:

Example: Refactor slide.html

If user doesn't specify page, ask for clarification, proceed after user confirmation.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.