Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计提醒

htmx-developmentHTMX 开发

Agent Skill

htmx-development 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

376

周安装

16

GitHub Stars

23

下载量

132
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:htmx-development(HTMX 开发)
来源仓库:https://github.com/camoa/claude-skills
仓库路径:skills/htmx-development
安装命令:
npx skills add https://github.com/camoa/claude-skills --skill htmx-development
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/camoa/claude-skills --skill htmx-development

简介

用于处理 HTMX 项目的协作信息与代码变更追踪。

  • 适合在 Codex、Claude、Cursor、Gemini CLI 中管理 Issue 与 Pull Request。
  • 通过 GitHub 仓库安装,需确认访问令牌与仓库权限。
  • 建议定期同步远程分支以避免合并冲突。
  • 涉及敏感操作时应启用二次确认与日志记录。

SKILL.md

HTMX Development

Drupal 11.3+ HTMX implementation and AJAX migration guidance.

When to Use

  • Implementing dynamic content updates in Drupal
  • Building forms with dependent fields
  • Migrating existing AJAX to HTMX
  • Adding infinite scroll, load more, real-time validation
  • NOT for: Traditional AJAX maintenance (use ajax-reference.md)

Decision: HTMX vs AJAX

Choose HTMXChoose AJAX
New featuresExisting AJAX code
Declarative HTML preferredComplex command sequences
Returns HTML fragmentsDialog commands needed
Progressive enhancement neededContrib expects AJAX

Hybrid OK: Both systems coexist. Migrate incrementally.

Quick Start

1. Basic HTMX Element

use Drupal\Core\Htmx\Htmx;
use Drupal\Core\Url;

$build['button'] = [
  '#type' => 'button',
  '#value' => t('Load'),
];

(new Htmx())
  ->get(Url::fromRoute('my.content'))
  ->onlyMainContent()
  ->target('#result')
  ->swap('innerHTML')
  ->applyTo($build['button']);

2. Controller Returns Render Array

public function content() {
  return ['#markup' => '<p>Content loaded</p>'];
}

3. Route (Optional HTMX-Only)

my.content:
  path: '/my/content'
  options:
    _htmx_route: TRUE  # Always minimal response

Core Patterns

Pattern Selection

Use CasePatternKey Methods
Dependent dropdownForm partial updateselect(), target(), swap('outerHTML')
Load moreAppend contentswap('beforeend'), trigger('click')
Infinite scrollAuto-loadswap('beforeend'), trigger('revealed')
Real-time validationBlur checktrigger('focusout'), field update
Multi-step wizardURL-based stepspushUrl(), route parameters
Multiple updatesOOB swapswapOob('outerHTML:#selector')

Dependent Dropdown

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['category'] = ['#type' => 'select', '#options' => $this->getCategories()];

  (new Htmx())
    ->post(Url::fromRoute('<current>'))
    ->onlyMainContent()
    ->select('#edit-subcategory--wrapper')
    ->target('#edit-subcategory--wrapper')
    ->swap('outerHTML')
    ->applyTo($form['category']);

  $form['subcategory'] = ['#type' => 'select', '#options' => []];

  // Handle trigger
  if ($this->getHtmxTriggerName() === 'category') {
    $form['subcategory']['#options'] = $this->getSubcategories(
      $form_state->getValue('category')
    );
  }

  return $form;
}

Reference: core/modules/config/src/Form/ConfigSingleExportForm.php

Multiple Element Updates

// Primary element updates via target
// Secondary element updates via OOB
(new Htmx())
  ->swapOob('outerHTML:[data-secondary]')
  ->applyTo($form['secondary'], '#wrapper_attributes');

URL History

(new Htmx())
  ->pushUrlHeader(Url::fromRoute('my.route', $params))
  ->applyTo($form);

Htmx Class Reference

Request Methods

  • get(Url) / post(Url) / put(Url) / patch(Url) / delete(Url)

Control Methods

  • target(selector) - Where to swap
  • select(selector) - What to extract from response
  • swap(strategy) - How to swap (outerHTML, innerHTML, beforeend, etc.)
  • swapOob(selector) - Out-of-band updates
  • trigger(event) - When to trigger
  • vals(array) - Additional values
  • onlyMainContent() - Minimal response

Response Headers

  • pushUrlHeader(Url) - Update browser URL
  • redirectHeader(Url) - Full redirect
  • triggerHeader(event) - Fire client event
  • reswapHeader(strategy) - Change swap
  • retargetHeader(selector) - Change target

See: references/quick-reference.md for complete tables

Detecting HTMX Requests

In forms (trait included automatically):

if ($this->isHtmxRequest()) {
  $trigger = $this->getHtmxTriggerName();
}

In controllers (add trait):

use Drupal\Core\Htmx\HtmxRequestInfoTrait;

class MyController extends ControllerBase {
  use HtmxRequestInfoTrait;
  protected function getRequest() { return \Drupal::request(); }
}

Migration from AJAX

Quick Conversion

AJAXHTMX
'#ajax' => ['callback' => '::cb'](new Htmx())->post()->applyTo()
'wrapper' => 'id'->target('#id')
return $form['element']Logic in buildForm()
new AjaxResponse()Return render array
ReplaceCommand->swap('outerHTML')
HtmlCommand->swap('innerHTML')
AppendCommand->swap('beforeend')
MessageCommandAuto-included

Migration Steps

  1. Identify #ajax properties
  2. Replace with Htmx class
  3. Move callback logic to buildForm()
  4. Use getHtmxTriggerName() for conditional logic
  5. Replace AjaxResponse with render arrays
  6. Test progressive enhancement

See: references/migration-patterns.md for detailed examples

Validation Checklist

When reviewing HTMX implementations:

  • Htmx class used (not raw attributes)
  • onlyMainContent() for minimal response
  • Proper swap strategy selected
  • OOB used for multiple updates
  • Trigger element detection works
  • Works without JavaScript (progressive)
  • Accessibility: aria-live for dynamic regions
  • URL updates for bookmarkable states

Common Issues

ProblemSolution
Content not swappingCheck target() selector exists
Wrong content extractedCheck select() selector
JS not runningVerify htmx:drupal:load fires
Form not submittingCheck post() and URL
Multiple swaps failAdd swapOob('true') to elements
History brokenUse pushUrlHeader()

References

Bundled (HTMX-Specific)

  • references/quick-reference.md - Command equivalents, method tables
  • references/htmx-implementation.md - Full Htmx class API, detection, JS
  • references/migration-patterns.md - 7 patterns with before/after code
  • references/ajax-reference.md - AJAX commands for understanding existing code

Online Dev-Guides

For deeper Drupal context beyond bundled references, use the dev-guides-navigator plugin:

Invoke /dev-guides-navigator with keywords like "Drupal forms", "routing", "JS development", or "render API". The navigator handles caching and disambiguation — never fetch dev-guides URLs directly.

Relevant topics: drupal/forms (FAPI with HTMX), drupal/routing (HTMX routes), drupal/js-development (behaviors + HTMX events), drupal/render-api (render arrays for HTMX responses).

Key Files in Drupal Core

  • core/lib/Drupal/Core/Htmx/Htmx.php - Main API
  • core/lib/Drupal/Core/Htmx/HtmxRequestInfoTrait.php - Request detection
  • core/lib/Drupal/Core/Render/MainContent/HtmxRenderer.php - Response renderer
  • core/modules/config/src/Form/ConfigSingleExportForm.php - Production example
  • core/modules/system/tests/modules/test_htmx/ - Test examples

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.68%
按下载量换算50

Claude

28.15%
按下载量换算37

Cursor

18.49%
按下载量换算24

Gemini CLI

10.02%
按下载量换算13

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills