iblai-vibe-agent-safety
Skill222 starsChanged 13 days agoMITView on GitHub
Add the agent Safety tab (the moderation check on user messages, the safety check on agent replies, the reply each one sends, and a host-provided list of flagged prompts) to your Next.js app. Use when the user mentions moderation, safety prompts, guardrails, inappropriate content, blocked messages, or flagged prompts. For the REST contract and the moderation logs see /iblai-api-agent-safety.
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- iblai/baseword for word, first seen Nov 22, 2026
Other versions1 project uses a version of this.
Word for word · 1
- iblai/base★ 222100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository166 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- iblai-vibe-pr-reviewSkill
- iblai-api-agent-accessSkill
- iblai-api-agent-auditSkill
- iblai-api-agent-chatSkill
- iblai-api-agent-createSkill
- iblai-api-agent-datasetSkill
- iblai-api-agent-disclaimerSkill
- iblai-api-agent-embedSkill
- iblai-api-agent-evalSkill
- iblai-api-agent-historySkill
- iblai-api-agent-llmSkill
- iblai-api-agent-mcpSkill
- iblai-api-agent-memorySkill
- iblai-api-agent-privacySkill
- iblai-api-agent-promptSkill
- iblai-api-agent-safetySkill
- iblai-api-agent-sandboxSkill
- iblai-api-agent-sessionSkill
- iblai-api-agent-settingSkill
- iblai-api-agent-skillSkill
- iblai-api-agent-supportSkill
- iblai-api-agent-toolSkill
- iblai-api-agent-voiceSkill
- iblai-api-inferenceSkill
- iblai-api-searchSkill
- iblai-vibe-agent-accessSkill
- iblai-vibe-agent-analyticsSkill
- iblai-vibe-agent-apiSkill
- iblai-vibe-agent-assistantSkill
- iblai-vibe-agent-auditSkill
- iblai-vibe-agent-billingSkill
- iblai-vibe-agent-chat-sidebarSkill
- iblai-vibe-agent-chatSkill
- iblai-vibe-agent-createSkill
- iblai-vibe-agent-datasetSkill
- iblai-vibe-agent-disclaimerSkill
- iblai-vibe-agent-embedSkill
- iblai-vibe-agent-evalsSkill
- iblai-vibe-agent-graderSkill
- iblai-vibe-agent-historySkill
- iblai-vibe-agent-llmSkill
- iblai-vibe-agent-ltiSkill
- iblai-vibe-agent-mcpSkill
- iblai-vibe-agent-memorySkill
- iblai-vibe-agent-privacySkill
- iblai-vibe-agent-promptSkill
- iblai-vibe-agent-sandboxSkill
- iblai-vibe-agent-screenshareSkill
- iblai-vibe-agent-searchSkill
- iblai-vibe-agent-settingSkill
- iblai-vibe-agentSkill
- iblai-vibe-agent-skillsSkill
- iblai-vibe-agent-supportSkill
- iblai-vibe-agent-taskSkill
- iblai-vibe-agent-toolSkill
- iblai-vibe-agent-virtual-machineSkill
- iblai-vibe-agent-voiceSkill
- iblai-vibe-incognitoSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Add the agent Safety tab -- the two guardrails on an agent's chats.
- Very specific: line 52
Look for iblai.env in the project root with PLATFORM, DOMAIN, and TOKEN.
- Very specific: line 301
Every change is one field on PUT /api/ai-mentor/orgs/{org}/users/{username}/mentors/{uuid}/settings/:
- Very specific: line 325
All from @iblai/iblai-js/data-layer.
- Very specific: line 330
Run /iblai-vibe-ops-test before telling the user the work is ready, and give every page, control and state this skill added its own …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/iblai-vibe-agent-safety
Add the agent Safety tab -- the two guardrails on an agent's chats.
Scope: per agent. The Moderation Prompt checks each user message
before the agent sees it; the Safety Prompt checks each reply before the
user sees it. Each has an Active switch, and each has a response sent
instead when it trips. This is one tab in the agent-settings family indexed
by /iblai-vibe-agent; it shares the AgentSettingsProvider wrapper with
every other tab.
Safety -- four cards (Moderation Prompt, Safety Prompt, Moderation
Response, Safety Response), each with Edit and Copy; the two prompt
cards have the Active switch. View Flagged Prompts shows only when you
pass a FlaggedPromptsModal and showFlaggedPrompts is true (Step 2).
Edit -- a rich-text editor for the prompt or response; Save writes it to the agent.
Image: Safety tab -- Edit Safety Prompt
Flagged prompts -- the modal your app supplies. This one is the minimal modal from Step 2: the user messages the Moderation Prompt stopped, with who sent each, when, the message, and the reason.
Image: Safety tab -- flagged prompts
Common setup (brand, conventions, env files, verification): see docs/skill-setup.md.
Prerequisites
- Auth set up (
/iblai-vibe-auth, or vibe-starter). AgentSettingsProviderwraps the route (/iblai-vibe-agent§1).@iblai/iblai-js@^3.1.0(resolves@iblai/web-containers2.1.0). Check withpnpm why @iblai/web-containers.- A real agent UUID. Ask the user; never invent one.
- To list flagged prompts, the user needs the agent's
#view_moderation_logsgrant (org admins have it).
Step 1: Check Environment
Look for iblai.env in the project root with PLATFORM, DOMAIN, and
TOKEN. If it is missing, tell the user:
"You need an iblai.env with your platform configuration. Download the
template and fill in your values:
curl -o iblai.env https://raw.githubusercontent.com/iblai/vibe/refs/heads/main/iblai.env"
Step 2: Mount AgentSafetyTab
The four cards need nothing but the provider: <AgentSafetyTab />. The
flagged-prompts list is not part of the SDK tab -- the host injects it.
These are the pieces a full mount wires:
FlaggedPromptsModal-- your modal; it getsisOpen,onClose,mentorId,tenantKey,username.showFlaggedPrompts-- whether to show the button. Gate it on the/mentors/<agent db id>/#view_moderation_logsgrant.renderPromptContent-- how the cards render prompt text (plain text by default, so line breaks and Markdown are lost). Pass a Markdown renderer to keep them.executeGatedActionon the provider -- wraps the two Active switches, for a paywall or free-trial check. Prompt edits are not gated.
A minimal flagged-prompts modal, built on the starter's Dialog:
// app/(app)/agents/[mentorId]/safety/flagged-prompts-modal.tsx
"use client";
import { useGetModerationLogsQuery } from "@iblai/iblai-js/data-layer";
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
type FlaggedPromptsModalProps = {
isOpen: boolean;
onClose: () => void;
mentorId: string;
tenantKey: string;
username: string;
};
type ModerationLog = {
id: number;
username: string;
email: string | null;
prompt: string;
reason: string;
target_system: string;
date_created: string;
};
export function FlaggedPromptsModal({
isOpen,
onClose,
mentorId,
tenantKey,
username,
}: FlaggedPromptsModalProps) {
const { data, isLoading } = useGetModerationLogsQuery(
{
org: tenantKey,
userId: username,
mentor: mentorId,
page: 1,
pageSize: 20,
ordering: "-date_created",
},
{ skip: !isOpen },
);
const logs = (data?.results ?? []) as unknown as ModerationLog[];
return (
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
<DialogContent className="sm:max-w-2xl">
<DialogHeader>
<DialogTitle>Flagged prompts</DialogTitle>
<DialogDescription>
{data?.count ?? 0} messages stopped by the Moderation Prompt.
</DialogDescription>
</DialogHeader>
<div className="max-h-[60vh] space-y-3 overflow-y-auto">
{isLoading && <p className="text-sm text-gray-500">Loading…</p>}
{!isLoading && logs.length === 0 && (
<p className="py-8 text-center text-sm text-gray-500">No flagged prompts for this agent.</p>
)}
{logs.map((log) => (
<div key={log.id} className="rounded-md border border-gray-200 p-3">
<div className="flex justify-between gap-4 text-xs text-gray-500">
<span>{log.email ?? log.username}</span>
<span>
{log.target_system} · {new Date(log.date_created).toLocaleString()}
</span>
</div>
<p className="mt-2 text-sm text-gray-900">{log.prompt}</p>
<p className="mt-1 text-xs text-gray-600">{log.reason}</p>
</div>
))}
</div>
</DialogContent>
</Dialog>
);
}userId is the signed-in user (the path segment), which the request needs;
@iblai/data-layer 1.45.0 added it to the hook's argument type, so older
releases need a @ts-expect-error on that line. username in that type
filters to the flagged user instead. mentor filters to this agent. Add
search, a date range and paging the same way. This list holds Moderation
System rows only:
replies the Safety Prompt blocked are served by …/safety-logs/ (same query
and row shape), which useGetSafetyLogsQuery reads with the same arguments
(@iblai/data-layer 1.45.0 or later; useDeleteSafetyLogMutation deletes
one).
The page loads the agent's grants, gates the button, and passes the paywall gate through a nested provider:
// app/(app)/agents/[mentorId]/safety/page.tsx
"use client";
import { useEffect, useState } from "react";
import {
AgentSafetyTab,
AgentSettingsProvider,
useAgentSettings,
} from "@iblai/iblai-js/web-containers/next";
import {
useGetMentorSettingsQuery,
useGetRbacPermissionsMutation,
} from "@iblai/iblai-js/data-layer";
import { checkRbacPermission } from "@iblai/iblai-js/web-utils";
import { FlaggedPromptsModal } from "./flagged-prompts-modal";
// Module scope: the provider memoizes on this function, so an inline arrow
// would rebuild the context on every render.
const executeGatedAction = (action: () => unknown) => action();
export default function AgentSafetyPage() {
const settings = useAgentSettings();
const { tenantKey, mentorId, username } = settings;
const [grants, setGrants] = useState<object>({});
const [getRbacPermissions] = useGetRbacPermissionsMutation();
const { data } = useGetMentorSettingsQuery({
mentor: mentorId,
org: tenantKey,
// @ts-expect-error userId is accepted at runtime
userId: username,
});
const mentorDbId = (data as { mentor_id?: number } | undefined)?.mentor_id;
useEffect(() => {
if (!mentorDbId) return;
getRbacPermissions({
requestBody: { platform_key: tenantKey, resources: [`/mentors/${mentorDbId}/`] },
})
.unwrap()
.then((permissions) => setGrants({ ...permissions }))
.catch(() => {});
}, [mentorDbId, tenantKey, getRbacPermissions]);
return (
<div className="flex h-full flex-col bg-white">
<AgentSettingsProvider
{...settings}
rbacPermissions={grants}
executeGatedAction={executeGatedAction}
>
<AgentSafetyTab
FlaggedPromptsModal={FlaggedPromptsModal}
showFlaggedPrompts={checkRbacPermission(
grants,
`/mentors/${mentorDbId}/#view_moderation_logs`,
)}
renderPromptContent={(content) => (
<p className="whitespace-pre-wrap text-sm text-gray-700">{content}</p>
)}
/>
</AgentSettingsProvider>
</div>
);
}Replace executeGatedAction with your paywall or trial check (run action
once the user may proceed), defined outside the component or memoized. The grant path uses the agent's numeric
mentor_id, not the UUID. Without a FlaggedPromptsModal the button never
shows, whatever showFlaggedPrompts says (it defaults to true).
Step 3: Customize Labels (Optional)
The tab renders with the default agent-facing copy
(AGENT_SAFETY_TAB_LABELS, localized through the SDK's i18n). Pass a partial
labels object to change any string:
import { AgentSafetyTab } from "@iblai/iblai-js/web-containers/next";
<AgentSafetyTab
labels={{
header: { title: "Guardrails" },
actions: { viewFlaggedPrompts: "Blocked messages" },
}}
/>;Label groups (SafetyTabLabels): header (title, description),
prompts -- moderation and safety (title, tooltip, activeLabel,
inactiveLabel), moderationResponse and safetyResponse (title) --
actions (edit, viewFlaggedPrompts), and toasts (updateSuccess,
updateError).
Step 4: Use MCP Tools for Customization
get_component_info("AgentSafetyTab")
get_component_info("AgentSettingsProvider")<AgentSafetyTab> Props
Import from @iblai/iblai-js/web-containers/next.
| Prop | Type | Required | Description |
FlaggedPromptsModal | ComponentType<{ isOpen, onClose, mentorId, tenantKey, username }> | No | Your flagged-prompts modal. Without it there is no button |
showFlaggedPrompts | boolean | No | Show View Flagged Prompts. Defaults to true; gate it on #view_moderation_logs |
renderPromptContent | (content: string) => ReactNode | No | Render card text (e.g. Markdown). Defaults to plain text |
labels | DeepPartial<SafetyTabLabels> | No | Override user-visible strings |
Identity, enableRBAC (per-field permissions on the cards) and
executeGatedAction come from AgentSettingsProvider.
Related Exports
From @iblai/iblai-js/web-containers/next:
AGENT_SAFETY_TAB_LABELS-- the default label bundle.SafetySelectedPrompt,SafetyEditFormValues-- the edit dialog's prompt and form types.AgentSafetyTabProps,SafetyTabLabels-- types.
How it saves
Every change is one field on
PUT /api/ai-mentor/orgs/{org}/users/{username}/mentors/{uuid}/settings/:
| Control | Field |
| Moderation Prompt switch / Save | enable_moderation / moderation_system_prompt |
| Safety Prompt switch / Save | enable_safety_system / safety_system_prompt |
| Moderation Response Save | moderation_response |
| Safety Response Save | safety_response |
The flagged-prompts modal above reads
GET /api/ai-mentor/orgs/{org}/users/{username}/moderation-logs/?mentor=<uuid>
(rows: prompt, reason, target_system, date_created, and who sent it).
Safety Prompt catches are at …/safety-logs/?mentor=<uuid> instead.
Platform data
| Hook | Purpose |
useGetMentorSettingsQuery / useEditMentorMutation | Read and save the prompts, responses and switches |
useGetModerationLogsQuery / useDeleteModerationLogMutation | Flagged prompts, for your modal |
useGetSafetyLogsQuery / useDeleteSafetyLogMutation | Replies the Safety Prompt blocked (@iblai/data-layer 1.45.0 or later) |
useGetRbacPermissionsMutation | Load the #view_moderation_logs grant (Step 2) |
All from @iblai/iblai-js/data-layer. REST twin:
/iblai-api-agent-safety.
Step 5: Verify
Run /iblai-vibe-ops-test before telling the user the work is ready, and give
every page, control and state this skill added its own checkpoint — one Playwright
test titled <ID> · … in e2e/journeys/, listed in e2e/coverage.json;
pnpm e2e:coverage must pass:
pnpm build-- must pass with zero errors.pnpm test-- vitest must pass.- Touch test
/agents/<uuid>/safetyin the browser as/iblai-vibe-ops-testsays, signed in as an org admin: the four cards and View Flagged Prompts render; with moderation Active, send the agent a clearly harmful request in chat -- it shows up in the modal; read the console; check the phone width.
Important Notes
- Switches save at once: flipping Active changes the agent for everyone who chats with it. Try changes on a test agent.
- Moderation runs before the agent, safety after: a moderated message never reaches the agent; a reply that fails the safety check is replaced by the Safety Response.
- Shared provider: mount
AgentSettingsProvideronce at the layout level (/iblai-vibe-agent§1); the page above nests a second one only to add grants and the gate. - Peer deps:
sonnerand@iblai/iblai-web-mentor(pnpm add sonner @iblai/iblai-web-mentor). - Brand guidelines: BRAND.md
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

