What are Optic Skills?

Optic Skills provide a programmatic approach for describing your coding conventions and automating routine programming tasks. Useful Optic Skills can be shared with friends, teammates and the entire Optic community.

The simplest Skills are ~200 lines of code and allow Optic to work with a specific library or framework.

Skills can be built on top of one another allowing basic Skills to be built up into larger ones. These larger Skills can help you develop for an entire stack, write code like one of your favorite developers, or codify the best practices which make sense on your team.

Parts of a Skill

  • Generators - provide a programmatic interface for working with different kinds of code. Each generator allows Optic to understand, write and maintain a certain kind of code.
  • Relationships - help Optic understand the connections between different kinds of code. Once Optic understands these relationships it can help you write and maintain the interconnected parts of your code base. For instance, a relationship between your API endpoints and HTTP Requests can be used to automatically keep your frontends and backends in sync.
  • Abstractions - are used to represent a concept in programming that exists across programming languages such as APIs, validation, requests, or forms. You'll learn more about why these are important soon.
  • Rules (experimental) - allow you to write high level linting rules that aren't possible w/ AST based linters ie "POST endpoints must use authentication"

Working with the Skills SDK


  • An up-to-date version of Optic
  • Node && npm

The skills SDK & CLI tool can be installed by running:

npm install optic-skills-sdk -g

Once installed, you can use the CLI to make a new skill package. First create a new directory for the skill ie my-example-skill and run the following two commands from inside of that directory:

opticsdk init
npm install

That will create a directory structure like this:

├── .babelrc
├── lib
├── package.json
└── src
    ├── example-skill.skill.js  //boilerplate configuration for the skill
    └── example-skill.test.js   //boilerplate tests, use 'npm run test'

And enable the following commands to be run from within the skill's directory:

*npm run test - Run the tests for this skill. Files ending '.test.js' will be included

*opticsdk publishlocal - Publishes this skill to your local Optic registry for use in your own projects

*opticsdk publish - Publishes this skill on the public Optic registry

Creating a Skill

Skills are identified with the author's user or team name, an identifier and a semantic version. Skill packages can then be referenced by {author}:{identifer}@{version}.

By default a Skill contains no abstractions, generators, relationships, rules or dependencies. For readability, we suggest you set these up in other files and import them to wherever you define your Skill package.

export default Skill('optic', 'express', '0.4.0', {
	abstractions: [],
	generators: [parameters, headers, responses, endpoint],
	relationships: [],
	rules: [],
	dependencies: {
		'optic:rest': '0.4.0'

Next Step