--- title: Trait Definition --- In this section we will introduce how to define a custom trait with CUE. Make sure you've learned the basic knowledge about [Definition Concept](../../getting-started/definition.md) and [how to manage definition](../cue/definition-edit.md). ## Generate a Trait scaffold A trait can be something similar to component, while they're attached operational resources. - Kubernetes API resources like ingress, service, rollout. - The composition of these operational resources. - A patch of data, for example, patch sidecar to workload. Let's use `vela def init` to create a basic trait scaffold: ``` vela def init my-route -t trait --desc "My ingress route trait." > myroute.cue ``` The content of the scaffold expected to be: ```cue // $ cat myroute.cue "my-route": { annotations: {} attributes: { appliesToWorkloads: [] conflictsWith: [] podDisruptive: false workloadRefPath: "" } description: "My ingress route trait." labels: {} type: "trait" } template: { patch: {} parameter: {} } ``` :::caution There's a bug in vela CLI(`<=1.4.2`), the `vela def init` command will generate `definitionRef: ""` in `attributes` which is wrong, please remove that line. ::: ## Define a trait to compose resources Unlike component definition, KubeVela requires objects in traits **MUST** be defined in `outputs` section (not `output`) in CUE template with format as below: ```cue outputs: { : {