Microsoft MakeCode

Best way to maintain a common file?

Trying to figure out the cleanest way to have a shared functions file across multiple projects. seems like there isn’t an easy way. I’ve found 2 options.

  1. Add a custom.ts and then copy that around to other projects.

  2. Create a project with all of the function in it inside a namespace i.e.
    namespace common {
    // code
    Save the code then in a new project where they want to use that code select extensions and then selected the common uf2 file.

Both options feel prone to mistakes (especial having 11-14 year old kids doing it). I think a feature of being able to add a common.ts just like custom.ts would be nice. I’ve tried hand editing the pxt.json but doesn’t seem to allow referencing any files outside of the current location.

1 Like

One way to do this is by using our Github support! More information on it can be found here:

@peli is the expert

We are actively working on integrate support for GitHub and authoring a project with multiple collaborators (using the traditional, commit/merge/branch flows). Unfortunately, it is not yet available in LEGO.

For a FLL type of use case, my proposal is to have a 3 tier solution

  • the top level is programmed by most of the pupils using Blocks (or javaScript)
  • the middle level is programmed by some of the pupils to do mission specific tasks using JavaScript
  • the bottom level is programmed by experienced pupils for general purpose functions that are not yet supported by the standard library

My brute force method has been to use external text editor with copy/paste operation for the whole content of custom.ts file. This method doesn’t allow an easy separation between project specific functions and general functions.

1 Like

I think I’m eventually going to hit this issue too in the MakeCode Arcade world.

I would like a set of students to be able to work independently on the same project for to allow some degree of personalistation and individual approach but then to later introduce some extra (Blocks) code to help them along in the next phase. Is there a simple way to import a few bits of (Blocks) code into an existing project?

We have been working on better GitHub integration in arcade and EV3 beta. You can bundle your custom blocks in a GitHub repo and have the students add it as an extension.

I’ve only briefly dabbled with extensions, can they add instantiated Blocks to the existing code?

I just found some old notes on this. I was also thinking about the scenario of having two children working on a project where one might be doing the majority of the coding and the other working on the art work and then they want to bring the two together periodically to integrate the work.

It feels like some sort of file-based solution plus drag and drop approach would work better for non-technical students and ones without github accounts but I’ve not road tested this yet.

Please add an option to import a .ts and export a .ts instead of just creating a new custom.ts. this would be a huge help for us. We have two kids that are the primary programmers and write libraries and then try to share them for other projects. Both of the students modify custom.ts and then try to diff in their changes. It is not a very good solution. I’ll look into the GIT hub integration on the latest beta but still feels like collaborate will be difficult.
As far as making an extension is there any access control? Seems like it would be too tempting for teams to use libraries they didn’t write.

Once you use a GitHub repository, you can select to add any file name you want. The GitHub integration also support 3-way merge and conflict resolution so it should be much more helpful for your case.
No, there is no access control. Students can use any library they want. So it might be tempting for them to pick a random library, but they might loose more time trying to understand/debug it – or they might learn to reuse other people’s work.
Drag and drop is a good idea. Please file this at

I built an escape room recently for a birthday so I ended up with 6 repose (1 per device in the room). You can see the root library at .
Note that the GitHub support is still nascent and we are very interested in your feedback if you decide to use it.

I just added GitHub: microsoft/pxt-arcade: Enable user to import code into an existing project with drag and drop #1713 for this.

Other related discussions: