# 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="/pages/CV2FP4ZBSIpH9GCwJxyX" %}
[Service](/core-concepts/scaffold/service.md)
{% 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="/pages/Vw5dn4e0eSOSrbyxkj0m" %}
[Customizing Container Services](/guides/how-to-integrate-e2e-testing/how-to-scaffold-an-app/customizing-a-workflow/customizing-container-services.md)
{% endcontent-ref %}

## Next Steps

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

{% content-ref url="/pages/7J10qWFxe9zweKA3YQtH" %}
[How to Run a Workflow](/guides/how-to-integrate-e2e-testing/how-to-run-a-workflow.md)
{% endcontent-ref %}

Or to further customize a workflow, see:

{% content-ref url="/pages/JuFHfkdezPzzSUX9Qzra" %}
[Customizing a Workflow](/guides/how-to-integrate-e2e-testing/how-to-scaffold-an-app/customizing-a-workflow.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.stoobly.com/guides/how-to-integrate-e2e-testing/how-to-scaffold-an-app/scaffolding-a-service.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
