Index of every page on this site: llms.txt
All skills
comet-ml avatar

/opik-frontend

@9b3d88e
by Cometcomet-ml/opik23k stars
1,964
Run it yourself

React frontend patterns for Opik. Use when working in apps/opik-frontend, on components, state, or data fetching.

Use this Skill: https://skilld.dev/gh/comet-ml/opik/opik-frontend

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

forms.md

≈593 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Form Handling Patterns

React Hook Form + Zod Setup

import { useForm } from "react-hook-form";
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";

// Define schema
const formSchema = z.object({
  name: z.string().min(1, "Name is required"),
  email: z.string().email("Invalid email"),
  description: z.string().optional(),
});

type FormData = z.infer<typeof formSchema>;

// Use in component
const form = useForm<FormData>({
  resolver: zodResolver(formSchema),
  defaultValues: {
    name: "",
    email: "",
    description: "",
  },
});

Form JSX Structure

<Form {...form}>
  <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
    <FormField
      control={form.control}
      name="name"
      render={({ field }) => (
        <FormItem>
          <FormLabel>Name</FormLabel>
          <FormControl>
            <Input {...field} />
          </FormControl>
          <FormMessage />
        </FormItem>
      )}
    />

    <Button type="submit" disabled={form.formState.isSubmitting}>
      {form.formState.isSubmitting && <Spinner className="mr-2" />}
      Submit
    </Button>
  </form>
</Form>

Dynamic Form Fields

const { fields, append, remove } = useFieldArray({
  control: form.control,
  name: "items",
});

{fields.map((field, index) => (
  <div key={field.id} className="flex gap-2">
    <FormField
      control={form.control}
      name={`items.${index}.name`}
      render={({ field }) => (
        <FormItem>
          <FormControl>
            <Input {...field} placeholder="Name" />
          </FormControl>
          <FormMessage />
        </FormItem>
      )}
    />
    <Button type="button" variant="outline" onClick={() => remove(index)}>
      Remove
    </Button>
  </div>
))}

<Button type="button" onClick={() => append({ name: "", value: "" })}>
  Add Item
</Button>

Conditional Validation

const formSchema = z
  .object({
    type: z.enum(["user", "admin"]),
    permissions: z.array(z.string()).optional(),
  })
  .refine(
    (data) => {
      if (data.type === "admin" && (!data.permissions || data.permissions.length === 0)) {
        return false;
      }
      return true;
    },
    {
      message: "Admin users must have at least one permission",
      path: ["permissions"],
    },
  );

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts8mo4 checks · Risk SAFE
  • Gen Agent Trust Hub8mo

    This skill provides a comprehensive set of architectural guidelines and coding standards for developing the Opik React frontend. It promotes industry-standard best practices, such as using Zod for form validation and TanStack Query for data fetching, and contains no security vulnerabilities or malicious patterns.

  • Socket8mo

    No alerts

  • Snyk8mo

    Risk: LOW · No issues

  • Runlayer8mo

    7 files scanned · No issues

Signed by skilld at 9b3d88e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 4 months ago

README badge

README badge for comet-ml/opik/opik-frontend