Create Creation Form
Developmentcreate-creation-formCreate Creation Form is an Agent Skill for development published in the OpenCTI-Platform/opencti repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Use when: scaffolding a creation form drawer with Formik validation and a Relay mutation for a new entity
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/OpenCTI-Platform/opencti/blob/HEAD/.github/skills/create-creation-form/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/create-creation-form, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Create Creation Form (Drawer)
Prerequisites
- Mutation: GraphQL mutation for creating the entity.
- Fields: List of fields to display.
Procedure
Step 0 — Find an Existing Example
Use the Codebase Pattern Finder agent to locate a similar existing creation form in opencti-platform/opencti-front/src/private/components/ (look for files ending in Creation.tsx). Model the new form after the existing one to stay idiomatic.
Step 1 — Define Mutation & Validation
Use Yup for validation schema.
const creationMutation = graphql`
mutation MyEntityCreationMutation($input: MyEntityAddInput!) {
myEntityAdd(input: $input) {
...MyEntityLine_node
}
}
`;
const validationSchema = Yup.object().shape({
name: Yup.string().required(t('This field is required')),
});
Step 2 — Create Component Structure
Return a Drawer containing a Formik form.
export const MyEntityCreation: React.FC<Props> = ({ paginationOptions }) => {
const [commit] = useApiMutation(creationMutation);
const onSubmit = (values, { setSubmitting, resetForm }) => {
commit({
variables: {
input: values,
},
updater: (store) => {
// Use utils/store helper
insertNode(store, 'Pagination_myEntities', paginationOptions, 'myEntityAdd');
},
onCompleted: () => {
setSubmitting(false);
resetForm();
},
});
};
return (
<Drawer title={t_i18n('Create entity')}>
<Formik initialValues={{ name: '' }} validationSchema={validationSchema} onSubmit={onSubmit}>
<Form>
<Field component={TextField} name="name" label={t_i18n('Name')} />
<Button type="submit">{t_i18n('Create')}</Button>
</Form>
</Formik>
</Drawer>
);
};