drupal-state

Store and retrieve runtime operational data in Drupal via the State API.

67|13|Updated Apr 15, 2026
One-click install
npx skills add https://github.com/edutrul/drupal-ai --skill drupal-state
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: drupal-state
Source: https://github.com/edutrul/drupal-ai/tree/main/.claude/skills/drupal-state
Command: npx skills add https://github.com/edutrul/drupal-ai --skill drupal-state

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

State is for runtime operational data that should persist across requests but is not configuration. Use Config for user-managed settings. Use State for internal operational data (last cron run, migration status, etc.).

Core Features & Use Cases

  • Store and retrieve values using StateInterface get/set/delete, and batch operations getMultiple/setMultiple/deleteMultiple.
  • Enforce namespaced keys like my_module.last_run to avoid collisions.
  • Provide persistent runtime information such as cron times, migration offsets, and feature flags.

Quick Start

Inject StateInterface and start storing and retrieving runtime data using namespaced keys (e.g., my_module.last_run) with get, set, and delete methods.

Frequently Asked Questions about drupal-state

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
When should I use Drupal State API instead of configuration for storing data?β–Ό

Drupal State API stores runtime operational data like cron times and migration offsets that persist across requests but aren't user-managed. Use State for internal operational data and Config for user-managed settings.

How do I store and retrieve runtime state values in Drupal?β–Ό

Inject Drupal's StateInterface and use the get, set, and delete methods to store and retrieve runtime state values. For batch operations, use getMultiple, setMultiple, and deleteMultiple to handle several values at once.

Do I need to namespace keys when using the Drupal State API?β–Ό

Yes, you should use namespaced keys like my_module.last_run when storing state values. This pattern prevents key collisions and keeps your module's runtime data properly organized within the shared state storage.

Can I use Drupal State API to track cron run times and migration offsets?β–Ό

Yes, Drupal State API is designed for persistent runtime information such as cron run times, migration offsets, and feature flags. These values persist across requests and can be accessed via StateInterface methods.

What's the difference between Drupal State API and the Configuration system?β–Ό

Drupal State API is for internal operational data that persists across requests but is not user-managed, such as last cron run timestamps. Configuration is for user-managed settings that may be exported and synchronized across environments.

Does Drupal State API support batch operations for multiple values?β–Ό

Yes, Drupal State API supports batch operations through getMultiple, setMultiple, and deleteMultiple methods. These allow you to efficiently retrieve, store, or remove several state values in a single call alongside the standard get, set, and delete methods.