mcpField
M
meridian-scenario-planner

meridian-scenario-planner

github.com/googleMarketing & growth1.6k57 installsUpdated 1d ago
Repository

About meridian-scenario-planner

A skill for building Meridian Scenario Planner data from a fitted model and exporting it as a proto file for handoff to the Colab notebook. It guides agents through configuration and requires user approval at each stage.

Key features

  1. 01Load a serialized Meridian model
  2. 02Configure Scenario Planner specifications
  3. 03Generate and save proto data
  4. 04Provide the Colab notebook handoff
  5. 05Pause for approval at checkpoints

Use cases

  1. 01Prepare fitted-model data for Scenario Planner
  2. 02Set planning periods and budget shift limits
  3. 03Export a proto file for Colab use

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/google/meridian --skill meridian-scenario-planner

After installing, type/meridian-scenario-plannerin Claude Code to confirm it loaded.

Bundled filesreferences/script_template.md

Details

From the project README

Meridian Scenario Planner Generation

This skill guides the agent to generate Scenario Planner data, serialize it as a proto file for Colab handoff (zero GCP setup required), and provide the link to the Meridian Looker Studio Scenario Planner Colab notebook.

Prerequisites

  • The agent must have access to a fitted Meridian model (serialized as meridian_model.binpb).
  • Important

    meridian_model.binpb is a binary file. Do NOT try to read its content directly using file viewing tools or grep, as this will produce invalid UTF-8 errors. Always use meridian_serde.load_meridian() in a Python script to load it.

Core Workflow

Interactivity Checkpoint Rule

Throughout this workflow, you will encounter CRITICAL INTERACTIVE CHECKPOINTs. At each checkpoint, you MUST:

  1. Present the current proposed configurations, paths, or status to the user for approval.
  2. Ask the user if they are ready to proceed using the available user-interaction tool (e.g., ask_question), structured as a multiple-choice question. Do NOT use raw chat text.
  3. Wait for their response before proceeding.
    • MANDATORY: You MUST pause at every checkpoint regardless of the initial prompt instructions (even if the user request contains phrases like "run autonomously", "execute directly", "fix autonomously", etc.). The initial request does NOT bypass these interactive checkpoints.
    • Note: If the user replies to a checkpoint with a generic approval (e.g., "proceed", "do what you think is best"), proceed with the proposed defaults.

1. Initial Setup
  • Prompt the user for the path to the serialized model file (meridian_model.binpb by default).
  • Prompt the user for the output proto path (default: model_build/scenario_planner_data.binpb).
  • Prompt the user for the desired path for the generated Python script. If unspecified, default to model_build/run_scenario_planner.py (or relative to the model directory).
  • CRITICAL INTERACTIVE CHECKPOINT: Present the gathered paths to the user and obtain confirmation before configuring spec parameters.
2. Configure Scenario Planner Spec & Interactive Checkpoint
  • Prompt the user for the following Scenario Planner spec configurations (or confirm defaults):
    • optimization_name (String, e.g., "Scenario Planner")
    • include_non_paid_channels (Boolean, default: True)
    • Time breakdown: yearly (default: False), quarterly (default: True), monthly (default: False)
    • min_spend_shift_ratio (Float 0-1, default: 1.0)
    • max_spend_shift_ratio (Float > 0, default: 1.0)
    • use_optimal_frequency (Boolean, default: True)
    • max_frequency (Float > 0, default: 10.0)
  • CRITICAL INTERACTIVE CHECKPOINT: Present the proposed Scenario Planner spec configurations to the user and obtain approval before continuing to load the model.
3. Add Model Loading Code
  • Use meridian_serde.load_meridian() to load the model.
  • See script_template.md for code template.
  • CRITICAL INTERACTIVE CHECKPOINT: Present the model load path configuration and proposed Python code snippet to the user, and obtain approval before continuing to data generation.
4. Add Scenario Planner Data Generation & Colab Handoff Code
  • Create specs for ModelFitSpec, MarketingAnalysisSpec, and BudgetOptimizationSpec using the user-provided configurations.
  • Use mmm_ui_gen.create_mmm_ui_data_proto() to create the proto, including the requested time breakdown generators.
  • Serialize and save the proto to disk (e.g. model_build/scenario_planner_data.binpb).
  • Instruct the user to upload the saved file to the Meridian Scenario Planner Colab notebook: https://colab.research.google.com/github/google/meridian/blob/main/demo/Meridian_Scenario_Planner_Beta.ipynb
  • See script_template.md for code template.
  • CRITICAL INTERACTIVE CHECKPOINT: Present the proposed scenario planner spec configuration and export code snippet to the user, and obtain approval before continuing to execution.
5. Pre-execution Checkpoint
  • CRITICAL INTERACTIVE CHECKPOINT: Ask the user for final confirmation to execute the scenario planner generation script now.
6. Execution & Script Setup
  • Write the accumulated Python script to the user-specified path. If your file-writing tool can ask the user to review the written file, don't request that review: the pre-execution checkpoint already asks for approval, and an extra prompt pauses the workflow.
  • You can use the full script template in script_template.md as a guide.
  • Execute the script with the Python interpreter of the environment where google-meridian is installed: the one the user named; else python3 if a virtual environment is already active (VIRTUAL_ENV or CONDA_PREFIX is set); else the project directory's virtual environment (.venv/ or venv/, e.g., .venv/bin/python3) if there is one; else python3. If import meridian fails, ask the user which environment to use instead of searching the machine or installing packages unprompted.
  • If the script keeps running in the background, wait for it to finish and check its final output before reporting results.
  • CRITICAL: Do NOT delete the generated script, output proto files, or deliverables at the end of the task. These are the deliverables requested by the user and must be preserved.

Comments

Markdown supported