一键导入
create-hook
Create a new agentick lifecycle hook or custom hook. Use when asked to add a hook, create reactive behavior, or implement lifecycle logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Create a new agentick lifecycle hook or custom hook. Use when asked to add a hook, create reactive behavior, or implement lifecycle logic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Create a new agentick tool using createTool. Use when asked to add a tool, create a tool, or implement tool functionality.
Add a new package to the agentick monorepo. Use when creating a new @agentick/* package.
Build, typecheck, and test the agentick monorepo. Use when asked to verify changes, run checks, or ensure nothing is broken.
Test an agentick agent with mock model responses. Use when asked to write tests, test an agent, or verify agent behavior.
Create a new model adapter for agentick. Use when asked to add support for a new model provider (Anthropic, Mistral, Cohere, etc).
Create a new agentick JSX component. Use when asked to add a component, create a UI primitive, or build a reusable agent building block.
| name | create-hook |
| description | Create a new agentick lifecycle hook or custom hook. Use when asked to add a hook, create reactive behavior, or implement lifecycle logic. |
Agentick hooks follow React conventions — they're functions starting with use that compose state and lifecycle behavior.
Before creating a new hook, check if an existing one covers your use case:
| Hook | Purpose |
|---|---|
useState | Local state (standard React) |
useEffect | Side effects (standard React) |
useSignal | Reactive signal state |
useKnob | Model-visible, model-settable reactive state |
useOnMount | Run once on first tick |
useOnUnmount | Cleanup on component removal |
useOnTickStart | Run at start of tick 2+ |
useOnTickEnd | Run at end of every tick |
useContinuation | Control whether execution continues |
useAfterCompile | Run after each compilation |
useOnMessage | React to individual messages |
useComState | Subscribe to COM state changes |
useData | Reactive data cache with serialization |
packages/core/src/hooks/:// packages/core/src/hooks/my-hook.ts
import { useState, useEffect } from "react";
import { useCom } from "./context";
export function useMyHook(initialValue: string) {
const ctx = useCom();
const [value, setValue] = useState(initialValue);
useEffect(() => {
// Setup logic
return () => {
// Cleanup logic
};
}, []);
return [value, setValue] as const;
}
// packages/core/src/hooks/index.ts
export { useMyHook } from "./my-hook";
// packages/core/src/index.ts — add to the hooks re-exports
export { useMyHook } from "./hooks";
All lifecycle callbacks follow "data first, ctx last":
useOnMount((ctx) => {});
useOnTickStart((tickState, ctx) => {});
useOnTickEnd((result, ctx) => {});
useAfterCompile((compiled, ctx) => {});
useContinuation((result, ctx) => boolean | void); // result.shouldContinue shows framework default
useOnMessage((message, ctx, state) => {});
import { useCom } from "./context";
export function useMyHook() {
const ctx = useCom();
// ctx.setState(key, value) — persist to session
// ctx.getState(key) — read from session
// ctx.emit(event, data) — emit events
}
packages/core/src/hooks/packages/core/src/hooks/index.tspackages/core/src/hooks/lifecycle.tspackages/core/src/hooks/signal.tspackages/core/src/hooks/knob.tspackages/core/src/hooks/context.tsimport { describe, it, expect, afterEach } from "vitest";
import { createApp } from "@agentick/core";
import { createTestAdapter, renderAgent, cleanup } from "@agentick/core/testing";
describe("useMyHook", () => {
afterEach(() => cleanup());
it("works in a component", async () => {
const adapter = createTestAdapter({ defaultResponse: "ok" });
function TestAgent() {
const [val] = useMyHook("initial");
return (
<>
<Model model={adapter} />
<System>Value: {val}</System>
<Timeline />
</>
);
}
const app = createApp(TestAgent);
const result = await app.run({
messages: [{ role: "user", content: [{ type: "text", text: "test" }] }],
}).result;
expect(result).toBeDefined();
});
});
After creating, run:
pnpm --filter @agentick/core typecheck
pnpm --filter @agentick/core test