# Automatic flags in monorepo

**URL:** <https://community.codecov.com/t/automatic-flags-in-monorepo/3394>\
**Category:** Support\
**Tags:** github\
**Created:** [December 13, 2021, 10:43am UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394 "2021-12-13T10:43:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![NivStav-RecoLabs](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/nivstav-recolabs/32/2254_2.png) [@NivStav-RecoLabs](https://community.codecov.com/u/NivStav-RecoLabs)\
**Post date:** [December 13, 2021, 10:43am UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394/1 "2021-12-13T10:43:04Z")

</div>

### Description

The recommended Flag setup according to the documentation is `Automatic Flag Management`  
[Flags](https://docs.codecov.com/docs/flags#recommended-automatic-flag-management).  
However, there’s no real usage example included and I couldn’t find examples in other places.

We have many packages in our monorepo, each running their own tests and coverage upload.  
I’ve pre-defined them in a long list inside `codecov.yml`, each with its respective path, but it’s not sustainable and doesn’t look particularly good.  
It’s my understanding that `Automatic Flags` should solve this, but I don’t understand how `CodeCov` will know will understand the scope of each run.

Does anyone have an example of a monorepo using automatic flags?

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [December 13, 2021, 9:31pm UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394/2 "2021-12-13T21:31:58Z")

</div>

@NivStav-RecoLabs I don’t have one immediately on hand, but I think that should help your case. Can I help with the `yaml` while I search one down/create one from scratch?

---

<div class="post-metadata">

**Author:** ![NivStav-RecoLabs](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/nivstav-recolabs/32/2254_2.png) [@NivStav-RecoLabs](https://community.codecov.com/u/NivStav-RecoLabs)\
**Post date:** [December 14, 2021, 2:51pm UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394/3 "2021-12-14T14:51:49Z")

</div>

Thanks for the reply @tom !  
The yaml is very basic:

```auto
...
flag_management:
  default_rules:
    carryforward: true

flags: 
  packageA:
    paths:
    - src/packageA/
  packageB:
    paths:
    - src/packageB/
  packageC:
    paths:
    - src/packageC/
# this pattern repeats

```

---

<div class="post-metadata">

**Author:** ![tom](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/tom/32/8_2.png) [@tom](https://community.codecov.com/u/tom)\
**Post date:** [December 15, 2021, 7:45pm UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394/4 "2021-12-15T19:45:05Z")

</div>

Hi @NivStav-RecoLabs, I’m investigating how we handle `paths`. I think you should be able to get this to work by removing the entire `flags` section. As long as you are uploading your coverage reports with the applicable flag name, it should work.

---

<div class="post-metadata">

**Author:** ![NivStav-RecoLabs](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.codecov.com/nivstav-recolabs/32/2254_2.png) [@NivStav-RecoLabs](https://community.codecov.com/u/NivStav-RecoLabs)\
**Post date:** [December 30, 2021, 9:10pm UTC](https://community.codecov.com/t/automatic-flags-in-monorepo/3394/5 "2021-12-30T21:10:23Z")

</div>

Hi @tom , I removed the explicit flags from the config file and flags are properly displayed and carried forward.  
Diffs are also showing properly.

Thanks for the help!
