# Scaffolding a Service

## Background

An app will likely depend on one or more services. Scaffolding a service will by default create the following workflows: record, mock, and test. It additionally will enable creating custom workflows for individual services. To learn more:

{% content-ref url="../../../core-concepts/scaffold/service" %}
[service](https://docs.stoobly.com/core-concepts/scaffold/service)
{% endcontent-ref %}

## Steps to Scaffold a Service

1. Run the scaffold service create command in the root of your app directory:

```sh
stoobly-agent scaffold service create \
    --hostname <SERVICE-HOSTNAME> \
    --scheme <SERVICE-SCHEME> \
    --port <SERVICE-PORT> \
    <SERVICE-NAME>
```

{% hint style="info" %}
By default, all three workflows (mock, record, test) are created if you don't specify `--workflow` options. Use `--workflow` only when you want to create a subset of workflows.
{% endhint %}

For example:

```sh
stoobly-agent scaffold service create \
    --hostname api.sampleapis.com \
    --scheme https \
    --port 443 \
    sampleapis
```

After running the command, the following files and folder will be created:

```sh
$ ls -a .stoobly/services/sampleapis
.config.yml .docker-compose.base.yml mock record test
```

Run the `scaffold service list` command to list all services. You should see your new service called "samplesapis" as well as others used by Scaffold:

```
$ stoobly-agent scaffold service list

name                      detached    hostname                     port    priority  proxy_mode                                scheme
build                     False                                     443           0
entrypoint                False                                     443          10
gateway                   False                                     443           1
sampleapis                False       api.sampleapis.com            443           5  reverse:https://api.sampleapis.com        https
stoobly-ui                False                                     443           1
```

2. (Optional) For custom container services, define them using the scaffold Docker Compose yaml file. See the following guide:

{% content-ref url="customizing-a-workflow/customizing-container-services" %}
[customizing-container-services](https://docs.stoobly.com/guides/how-to-integrate-e2e-testing/how-to-scaffold-an-app/customizing-a-workflow/customizing-container-services)
{% endcontent-ref %}

## Next Steps

Now that your service is created, you can now run workflows!

{% content-ref url="../how-to-run-a-workflow" %}
[how-to-run-a-workflow](https://docs.stoobly.com/guides/how-to-integrate-e2e-testing/how-to-run-a-workflow)
{% endcontent-ref %}

Or to further customize a workflow, see:

{% content-ref url="customizing-a-workflow" %}
[customizing-a-workflow](https://docs.stoobly.com/guides/how-to-integrate-e2e-testing/how-to-scaffold-an-app/customizing-a-workflow)
{% endcontent-ref %}
