It is quite likely that Scotland will in the coming years leave the UK. If this happens, Scotland will very probably subsequently join the EU, since one of the biggest grievances Scots have with Westminster was that they forced Scotland out of the EU against its will.
If Scotland does join the EU, what sort of member will it be? It should not make the mistake the UK did, of being a reluctant member of the EU, always complaining about being put upon by those nasty foreigners. No, if it does rejoin, Scotland should seek to be an enthusiastic member of the EU, to get the most out of membership.
Enhanced co-operation
Scotland should seek EU members to co-operate with for specific activities within the EU that not all EU members may want to take part in.
There is in fact a mechanism within the EU do do this, called "Enhanced Co-operation":
Enhanced cooperation allows for a minimum of nine member states (which amounts to almost one-third at the moment) to co-operate within the structures of the EU without all member states. This allows them to move at different speeds, and towards different goals, than those outside the enhanced cooperation area.
[Enhanced cooperation] needs a minimum of nine Member States, who file a request with the European Commission. If the Commission accepts it then it has to be approved by a qualified majority of all member states to proceed [i.e. 55% of the states forming 65% of the population]. A member may not veto the establishment of enhanced cooperation except for foreign policy.
The problem with this is it is very restrictive: it requires at least 9 EU member states ant permission from the EC using a qualified majority. And if the enhanced co-operation covers foreign policy, every state has a veto.
This is ridiculously restrictive, but there is a solution: states simply co-operate together without getting the EC's approval. Lots of this already does on, for example the Visegrád Group consisting of Czechia, Hungary, Poland and Slovakia, who co-operate together on a whole host of issues.
So the way to go is for Scotland to seek groupings of like-minded states outside of the EU's enhanced co-operation mechanism (if those groupings then wish to enter the mechanism fine, but they work perfectly well without it).
Areas of co-operation
So, in what areas could Scotland profitably collaborate with other countries? Here's a few ideas:
Foreign Policy
Common Foreign Policy group -- where each member agrees to abide by a common foreign policy, provided that policy is agreed by a qualified majority (55% of countries containing 65% of population, plus 50% of the countries' MEPs) of the group.
Common Defence Procurement group -- where the members of the group pledge to preferentially buy weapons from each other, and all members agree they will supply any of their weapons to any other member.
Defence Alliance -- where all members agree that an attack on one is an attack on all and that they will go to war against the aggressor.
Since these three areas are strongly interlinked, it may make sense to merge some or all of them.
Democracy and Voting
These aim to reduce the EU's democratic deficit and produce in the populace a feeling of pro-EU patriotism.
Common Voting group -- where all members of the group allows resident citizens of other countries in the group to vote in their national parliamentary elections.
Directly Elected EU President group -- where the members all hold a democratic election, concurrent with the EU parliament election, to choose their nominee for the presidency of the European Commission and Council (nominating the same person for both jobs, which would effectively merge them).
Technological independence
If country A's computing and communications infrastructure is controlled by entities in country B, then A cannot remain truly independent of B. From this I conclude that the EU needs to achieve technological independence throughout its computing and communications infrastructure. This needs to be done at several levels:
Integrated circuits for example CPUs, graphics and AI co-processors.
Assemblies of circuits such as circuit boards, computers, mobile phones.
Operating Systems. There needs to be an EU operating system, with versions for servers, desktop/laptop computers, tablets and phones. It needs to be open source, developed within the EU, be secure against hacking, and enable secure encrypted communications by default. It makes sense for this to be based on Linux.
Network infrastructure, including colocation, internet hosting services, cloud services like AWS or Azure, etc.
Social Media, e.g. Facebook, Twitter, YouTube, TikTok etc.
Internet-based services and APIs such as Google search, Gmail, Google Maps (and its API).
Ideally the whole EU should be involved in initiatives at all these levels, making sure that all computing hardware/software/services used in the EU are produced and controlled in the EU. But if the whole EU doesn't want to do this, then those states that do want to do this should do it themselves. For some of these levels, such as operating systems, it would make sense for non-EU countries to be involved too, since like the EU they would benefit from having their computer infrastructure not controlled by foreign entities.