ワンクリックで
add-inject
Create a game UI injection that modifies existing game elements with proper cleanup
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Create a game UI injection that modifies existing game elements with proper cleanup
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | add-inject |
| description | Create a game UI injection that modifies existing game elements with proper cleanup |
| aliases | ["new-inject","create-inject","add-qol"] |
/add-inject <featureName>
Note: This creates a game UI injection (modifies existing game UI). For Gemini HUD UI, use /add-component or /add-section.
What game UI element does this modify?
Brief description:
Which game UI elements are targeted?
Examples:
- Inventory panel
- Shop interface
- Player stats display
- Game toolbar
- Chat window
What modifications are made?
[ ] Add new elements (buttons, indicators, overlays)
[ ] Modify existing elements (styles, text, attributes)
[ ] Add event listeners (click handlers, observers)
[ ] Inject data displays (stats, timers, counters)
Does it need game data?
A) Static data → MGData
B) Real-time state → Globals
C) Both
D) None
Does it display game sprites? → MGSprite.toCanvas()
Does it need persistent state?
A) Yes - User preferences saved
B) No - Stateless
src/ui/inject/qol/<featureName>/
├── index.ts # Public API (init, destroy, isEnabled)
├── inject.ts # DOM injection logic
├── styles.css.ts # Scoped styles (optional)
└── state.ts # Persistent state (optional)
/**
* <FeatureName> Game UI Injection
*
* <Description of what it modifies>
*/
import { injectElements, removeElements } from './inject';
// ─────────────────────────────────────────────────────────────────────────────
// State
// ─────────────────────────────────────────────────────────────────────────────
let injected = false;
const cleanups: (() => void)[] = [];
// ─────────────────────────────────────────────────────────────────────────────
// Public API
// ─────────────────────────────────────────────────────────────────────────────
export const <FeatureName>Inject = {
/**
* Inject into game UI
* Idempotent - safe to call multiple times
*/
init(): void {
if (injected) return;
injected = true;
const cleanup = injectElements();
if (cleanup) cleanups.push(cleanup);
console.log('[<FeatureName>Inject] Initialized');
},
/**
* Remove all injected elements
* Idempotent - safe to call multiple times
*/
destroy(): void {
if (!injected) return;
cleanups.forEach(fn => fn());
cleanups.length = 0;
removeElements();
injected = false;
console.log('[<FeatureName>Inject] Destroyed');
},
/**
* Check if injection is active
*/
isEnabled(): boolean {
return injected;
},
};
/**
* <FeatureName> DOM Injection Logic
*/
import { <featureName>Css } from './styles.css';
// If using sprites:
// import { MGSprite } from '../../../../modules/sprite';
// If using game data:
// import { MGData } from '../../../../modules/data';
// If using globals:
// import { getMyInventory } from '../../../../globals/variables/myInventory';
// ─────────────────────────────────────────────────────────────────────────────
// Constants
// ─────────────────────────────────────────────────────────────────────────────
const CONTAINER_SELECTOR = '.game-ui-container'; // Adjust to target element
const INJECT_CLASS = 'gemini-qol-<featureName>';
// ─────────────────────────────────────────────────────────────────────────────
// Injection
// ─────────────────────────────────────────────────────────────────────────────
export function injectElements(): (() => void) | null {
const container = document.querySelector(CONTAINER_SELECTOR);
if (!container) {
console.warn('[<FeatureName>Inject] Container not found');
return null;
}
const cleanups: (() => void)[] = [];
// Inject styles
const style = document.createElement('style');
style.textContent = <featureName>Css;
style.setAttribute('data-gemini', '<featureName>');
document.head.appendChild(style);
cleanups.push(() => style.remove());
// Create injected element
const wrapper = document.createElement('div');
wrapper.className = INJECT_CLASS;
// ... build element
container.appendChild(wrapper);
cleanups.push(() => wrapper.remove());
// Add event listeners (track for cleanup!)
const handleClick = () => { /* ... */ };
wrapper.addEventListener('click', handleClick);
cleanups.push(() => wrapper.removeEventListener('click', handleClick));
// Subscribe to globals (track for cleanup!)
// const unsub = getMyInventory().subscribe((inv) => { /* update UI */ });
// cleanups.push(unsub);
// Return combined cleanup
return () => {
cleanups.forEach(fn => fn());
};
}
export function removeElements(): void {
// Remove all injected elements by class
document.querySelectorAll(`.${INJECT_CLASS}`).forEach(el => el.remove());
// Remove injected styles
document.querySelectorAll('style[data-gemini="<featureName>"]').forEach(el => el.remove());
}
/**
* <FeatureName> Injection Styles
*
* Scoped to .gemini-qol-<featureName>
*/
export const <featureName>Css = `
.gemini-qol-<featureName> {
/* Use CSS variables when possible */
position: absolute;
z-index: 100;
}
.gemini-qol-<featureName>__button {
background: var(--color-primary, #4a9eff);
color: var(--color-text, #fff);
border: none;
border-radius: 4px;
padding: 8px 12px;
cursor: pointer;
min-height: 44px; /* Touch-friendly */
}
.gemini-qol-<featureName>__button:hover {
opacity: 0.9;
}
`;
/**
* <FeatureName> Injection State
*/
import { storageGet, storageSet } from '../../../../utils/storage';
const STORAGE_KEY = 'inject:<featureName>:config';
export interface <FeatureName>Config {
enabled: boolean;
// ... other settings
}
const DEFAULT_CONFIG: <FeatureName>Config = {
enabled: true,
};
export function loadConfig(): <FeatureName>Config {
return storageGet(STORAGE_KEY, DEFAULT_CONFIG);
}
export function saveConfig(config: <FeatureName>Config): void {
storageSet(STORAGE_KEY, config);
}
If this injection is standalone (not part of a feature):
src/ui/inject/qol/index.tsexport { <FeatureName>Inject } from './<featureName>';
import { <FeatureName>Inject } from '../../ui/inject/qol/<featureName>';
// Initialize
<FeatureName>Inject.init();
// Cleanup
<FeatureName>Inject.destroy();
index.ts with init(), destroy(), isEnabled()inject.ts with injectElements(), removeElements()styles.css.ts with scoped classesstate.ts (if persistent)init() is idempotent (guard against double-inject)destroy() removes ALL injected elementsgemini-qol-<name>MGData.get() (no hardcoded data)MGSprite.toCanvas() (no hardcoded sprite paths)src/ui/components/ or src/ui/hud/If the injection is part of a feature:
// In src/features/<featureName>/index.ts
import { <FeatureName>Inject } from '../../ui/inject/qol/<featureName>';
function init(): void {
// ... feature init
<FeatureName>Inject.init();
}
function destroy(): void {
<FeatureName>Inject.destroy();
// ... feature cleanup
}
.claude/rules/ui/ui.inject.mdsrc/ui/inject/qol/*/src/utils/storage.tsCreate a new card part within a section with factory/class pattern, Card wrapper, and proper cleanup
Add a new Jotai atom to the state system with type definitions, registry, and Store API access
Create a reusable UI component with factory pattern, theme compatibility, and proper cleanup
Scaffold a new toggleable feature with full structure, storage, API exposure, and bootstrap registration
Create a reactive global variable that derives from atoms with subscription support
Create a new core infrastructure module with standard API, lazy init, and proper structure