Creating Completely New Custom Rulesets | MuleSoft Documentation
# Creating Completely New Custom Rulesets
To create a completely new custom ruleset that isn’t based on an existing one, use one of the following approaches:
  * Search the MuleSoft Ideas Portal for ideas for new rulesets. If you don’t find your idea there, consider submitting your idea in the MuleSoft Ideas Portal.
  * Generate a ruleset using Anypoint CLI commands by scaffolding it from a specification’s data schema. See Generating Rulesets from a Specification.
  * Create a ruleset using the ruleset development CLI commands, see Create Rulesets Using the Ruleset Development CLI.
  * Create a ruleset using the ruleset modeling language, see Create Rulesets Using the Modeling Language.


After you create the ruleset, see Validating and Publishing Custom Rulesets.
As with custom code and configurations, rulesets are not considered supported MuleSoft products. For help with issues with custom rulesets, post an issue in the AMF Custom Validator Github repository.   
---  
## Generating Rulesets from a Specification
You can generate a starter ruleset from specifications' data schemas using the following command sequence:
  1. Inspect API Specifications for API Type
  2. Initialize Rulesets from Data Schemas


### Inspect API Specifications for API Type
Use the following command to inspect API specifications for API type. This helps you determine which data schema to use.
### governance:api:inspect
`> governance:api:inspect [flags] <api-specification>`
Inspects the API specification passed in `api-specification` and lists all its schemas, such as headers, requests, and response payloads. You can use this schema information in the `governance:ruleset:init` command. See governance:ruleset:init.
This command accepts the default flags.
**Example command:**
```
anypoint-cli-v4 governance:api:inspect my-healthcare-api.yaml
```

**Example schema**
```
types:
 patientmultipleBirthBoolean:
  properties:
   multipleBirthBoolean:
    description: Whether patient is part of a multiple birth
    type: boolean
 patientmultipleBirthInteger:
  properties:
   multipleBirthInteger:
    description: Whether patient is part of a multiple birth
    type: integer
    .
    .
    .
 PatientEntry:
  type: FHIR_commons.Entry
  properties:
   resource: Patient
 PatientBundle:
  type: FHIR_commons.Bundle
  properties:
   entry?: PatientEntry[]
```

**Example output:**
```
 'patientmultipleBirthBoolean',
 'PatientBundle',
 'patientmultipleBirthInteger',
 'PatientEntry'
```

### Initialize Rulesets from Data Schemas
Use the following command to initialize rulesets from data schemas.
### governance:ruleset:init
`> governance:ruleset:init [flags] <schema>`
Initializes a ruleset based on the data schema passed in the `schema` parameter.
In addition to the default flags, this command accepts the following flags:
Flag | Description  
---|---  
`--types <types>` |  The `types` flag gives the target types to export as rules. You can use the `governance:api:inspect` command to identify the types to specify for this flag. See governance:api:inspect.  
`--name <name>` |  The `name` flag is the name of the ruleset. This defaults to `GeneratedRuleset`.  
**Example command:**
```
anypoint-cli-v4 governance:ruleset:init --types patientmultipleBirthBoolean,patientBundle,patientmultipleBirthInteger --name=my-ruleset mydataschema
```

## Create Rulesets Using the Ruleset Development CLI
An open-source version of ruleset development CLI is available on npm. It is provided and documented separately from the Anypoint CLI `governance` commands.
To create rulesets using the ruleset development CLI:
  1. Install `ruleset-development-cli` from npmjs.com.
  2. Follow the AMF Rulesets tutorial to create a ruleset.


## Create Rulesets Using the Modeling Language
To create rulesets using the modeling language, read the AMF Custom Validation section in the AML Open Source project to learn how to write a ruleset using the modeling language.
## See Also
  * Troubleshooting Anypoint CLI